Skip to content

Commit

Permalink
Woohoo! We have a working NewPassManager that generates PFW files. Fo…
Browse files Browse the repository at this point in the history
…rmatting pass
  • Loading branch information
tpatki committed Sep 24, 2024
1 parent 9103cc1 commit b9d1031
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/c/weaver/weave/perfflow_weave_legacy_pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ bool WeavingPass::doInitialization(Module &m)
{
outs() << "WeavePass loaded successfully. \n";

bool changed = false;
bool changed = false;
WeaveCommon weaver;
changed = weaver.modifyAnnotatedFunctions(m);

changed = weaver.modifyAnnotatedFunctions(m);

// auto annotations = m.getNamedGlobal("llvm.global.annotations");
// if (!annotations)
Expand Down
46 changes: 24 additions & 22 deletions src/c/weaver/weave/perfflow_weave_new_pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,43 +42,45 @@ bool NewWeavingPass::runOnModule(Module &M)
// The following loops through each function. This is where we need to check annotation
// (from doInitialization in the legacy pass and add the insertBefore/insertAfter)

WeaveCommon weaver;
WeaveCommon weaver;
changed = weaver.modifyAnnotatedFunctions(M);

for (auto &F : M)
{
if (F.isDeclaration())
continue;
{
continue;
}

if (F.getName().str()=="main")
if (F.getName().str() == "main")
{
outs() << "We found main! We will insert Adiak call here eventually.\n";
continue;
outs() << "We found main! We will insert Adiak call here eventually.\n";
continue;
}

// // Get an IR builder. Sets the insertion point to the top of the function
// IRBuilder<> Builder(&*F.getEntryBlock().getFirstInsertionPt());
// // Get an IR builder. Sets the insertion point to the top of the function
// IRBuilder<> Builder(&*F.getEntryBlock().getFirstInsertionPt());

// // Inject a global variable that contains the function name
// auto FuncName = Builder.CreateGlobalStringPtr(F.getName());

// // Inject a global variable that contains the function name
// auto FuncName = Builder.CreateGlobalStringPtr(F.getName());



// // Printf requires i8*, but PrintfFormatStrVar is an array: [n x i8]. Add
// // a cast: [n x i8] -> i8*
// llvm::Value *FormatStrPtr =
// Builder.CreatePointerCast(PrintfFormatStrVar, PrintfArgTy, "formatStr");
// // Printf requires i8*, but PrintfFormatStrVar is an array: [n x i8]. Add
// // a cast: [n x i8] -> i8*
// llvm::Value *FormatStrPtr =
// Builder.CreatePointerCast(PrintfFormatStrVar, PrintfArgTy, "formatStr");

// // The following is visible only if you pass -debug on the command line
// // *and* you have an assert build.
// LLVM_DEBUG(dbgs() << " Injecting call to printf inside " << F.getName()
// << "\n");
// // The following is visible only if you pass -debug on the command line
// // *and* you have an assert build.
// LLVM_DEBUG(dbgs() << " Injecting call to printf inside " << F.getName()
// << "\n");

// // Finally, inject a call to printf
// Builder.CreateCall(
// Printf, {FormatStrPtr, FuncName, Builder.getInt32(F.arg_size())});
// // Finally, inject a call to printf
// Builder.CreateCall(
// Printf, {FormatStrPtr, FuncName, Builder.getInt32(F.arg_size())});

// InsertedAtLeastOnePrintf = true;
// InsertedAtLeastOnePrintf = true;
}

return changed;
Expand Down

0 comments on commit b9d1031

Please sign in to comment.