diff --git a/src/c/weaver/weave/perfflow_weave_common.cpp b/src/c/weaver/weave/perfflow_weave_common.cpp index 398aa648..4e638300 100644 --- a/src/c/weaver/weave/perfflow_weave_common.cpp +++ b/src/c/weaver/weave/perfflow_weave_common.cpp @@ -153,8 +153,21 @@ bool weave_ns::WeaveCommon::insertAfter(Module &m, Function &f, StringRef &a, for (BasicBlock &bb : f) { Instruction *inst = bb.getTerminator(); + bool valid = false; if (isa(inst) || isa(inst)) { + valid = true; + } else if (isa(inst)) { + if (auto *call = dyn_cast(inst->getPrevNode())) { + Function *callee = call->getCalledFunction(); + if (callee && callee->getName() == "pthread_exit" || callee->getName() == "exit" || callee->getName() == "abort") { + inst = inst->getPrevNode(); + valid = true; + } + } + } + + if (valid) { IRBuilder<> builder(inst); Value *v1 = builder.CreateGlobalStringPtr(m.getName(), "str"); Value *v2 = builder.CreateGlobalStringPtr(f.getName(), "str");