Skip to content

Commit

Permalink
foo
Browse files Browse the repository at this point in the history
zhengyang92 committed Jul 24, 2024
1 parent 662b4a4 commit 1254537
Showing 4 changed files with 16 additions and 10 deletions.
6 changes: 4 additions & 2 deletions include/slice.h
Original file line number Diff line number Diff line change
@@ -19,13 +19,15 @@ class Slice {
llvm::Function &f;
llvm::LoopInfo &LI;
llvm::DominatorTree &DT;
llvm::MemoryDependenceResults &MD;

std::unique_ptr<llvm::Module> m;
llvm::ValueToValueMapTy mapping;

public:
Slice(llvm::Function &f, llvm::LoopInfo &LI, llvm::DominatorTree &DT)
: f(f), LI(LI), DT(DT) {
Slice(llvm::Function &f, llvm::LoopInfo &LI, llvm::DominatorTree &DT,
llvm::MemoryDependenceResults &MD)
: f(f), LI(LI), DT(DT), MD(MD) {
m = std::make_unique<llvm::Module>("", f.getContext());
m->setDataLayout(f.getParent()->getDataLayout());
}
3 changes: 3 additions & 0 deletions lib/slice.cpp
Original file line number Diff line number Diff line change
@@ -192,6 +192,9 @@ Slice::extractExpr(Value &v) {
debug() << "[slicer]" << *phi << " has external or constant income\n";
continue;
}
} else if (LoadInst *LI = dyn_cast<LoadInst>(i)) {


}

// filter unknown operation by operand type
13 changes: 7 additions & 6 deletions pass/online.cpp
Original file line number Diff line number Diff line change
@@ -238,6 +238,7 @@ infer(Function &F, Instruction *I, redisContext *ctx, Enumerator &EN, parse::Par

static bool
optimize_function(llvm::Function &F, LoopInfo &LI, DominatorTree &DT,
llvm::MemoryDependenceResults &MD,
TargetLibraryInfoWrapperPass &TLI) {
// set up debug output
raw_ostream *out_file = &errs();
@@ -352,7 +353,7 @@ optimize_function(llvm::Function &F, LoopInfo &LI, DominatorTree &DT,
continue;

DataLayout DL(F.getParent());
minotaur::Slice S(F, LI, DT);
minotaur::Slice S(F, LI, DT, MD);
auto NewF = S.extractExpr(I);
auto m = S.getNewModule();

@@ -420,12 +421,12 @@ struct SuperoptimizerLegacyPass final : public llvm::FunctionPass {
getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
DominatorTree &DT =
getAnalysis<DominatorTreeWrapperPass>().getDomTree();
/*MemoryDependenceResults &MD =
getAnalysis<MemoryDependenceWrapperPass>().getMemDep();*/
MemoryDependenceResults &MD =
getAnalysis<MemoryDependenceWrapperPass>().getMemDep();

TargetLibraryInfoWrapperPass TLI(Triple(F.getParent()->getTargetTriple()));

return optimize_function(F, LI, DT, TLI);
return optimize_function(F, LI, DT, MD, TLI);
}

bool doInitialization(llvm::Module &module) override {
@@ -465,9 +466,9 @@ struct SuperoptimizerPass : PassInfoMixin<SuperoptimizerPass> {

LoopInfo &LI = FAM.getResult<llvm::LoopAnalysis>(F);
DominatorTree &DT = FAM.getResult<DominatorTreeAnalysis>(F);
// MemoryDependenceResults &MD = FAM.getResult<MemoryDependenceAnalysis>(F);
MemoryDependenceResults &MD = FAM.getResult<MemoryDependenceAnalysis>(F);
TargetLibraryInfoWrapperPass TLI(Triple(F.getParent()->getTargetTriple()));
optimize_function(F, LI, DT, TLI);
optimize_function(F, LI, DT, MD, TLI);
return PA;
}
};
4 changes: 2 additions & 2 deletions tools/minotaur-slice.cpp
Original file line number Diff line number Diff line change
@@ -73,12 +73,12 @@ int main(int argc, char **argv) {
//FAM.registerPass(llvm::LoopInfo());
LoopInfo &LI = FAM.getResult<LoopAnalysis>(F);
DominatorTree &DT = FAM.getResult<DominatorTreeAnalysis>(F);
//MemoryDependenceResults &MD = FAM.getResult<MemoryDependenceAnalysis>(F);
MemoryDependenceResults &MD = FAM.getResult<MemoryDependenceAnalysis>(F);

unsigned count = 0;
for (auto &BB : F) {
for (auto &I : BB) {
Slice S(F, LI, DT);
Slice S(F, LI, DT, MD);
if (I.getType()->isVoidTy())
continue;
S.extractExpr(I);

0 comments on commit 1254537

Please sign in to comment.