Skip to content

Commit

Permalink
fix ifdefs for caliper annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
slabasan committed Sep 27, 2024
1 parent 2b37480 commit 575ebc4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/c/weaver/weave/perfflow_weave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ bool WeavingPass::insertAfter(Module &m, Function &f, StringRef &a,
return true;
}

#ifdef PERFFLOWASPECT_WITH_CALIPER
bool WeavingPass::instrumentCaliper(Module &M, Function &F)
{
IRBuilder<> IRB(M.getContext());
Expand Down Expand Up @@ -134,6 +135,7 @@ bool WeavingPass::instrumentCaliper(Module &M, Function &F)

return RetFound;
}
#endif

bool WeavingPass::insertBefore(Module &m, Function &f, StringRef &a,
int async, std::string &scope, std::string &flow, std::string pcut)
Expand Down Expand Up @@ -220,9 +222,11 @@ bool WeavingPass::doInitialization(Module &m)
auto e = cast<ConstantStruct> (a->getOperand(i));
if (auto *fn = dyn_cast<Function> (e->getOperand(0)->getOperand(0)))
{
#ifdef PERFFLOWASPECT_WITH_CALIPER
// We insert Caliper Instrumentation before weaver.
// Thus weaver will include Caliper overheads
changed |= instrumentCaliper(m, *fn);
#endif

auto anno = cast<ConstantDataArray>(
cast<GlobalVariable>(e->getOperand(1)->getOperand(0))
Expand Down
2 changes: 2 additions & 0 deletions src/c/weaver/weave/perfflow_weave.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ class WeavingPass : public FunctionPass
bool insertBefore (Module &m, Function &f, StringRef &a,
int async, std::string &scope, std::string &flow, std::string pcut);

#ifdef PERFFLOWASPECT_WITH_CALIPER
bool instrumentCaliper(Module &M, Function &F);
#endif
};

}
Expand Down

0 comments on commit 575ebc4

Please sign in to comment.