Skip to content

Commit 2af15c3

Browse files
authored
Fix to issue #156: multithread end events (#198)
1 parent 418d636 commit 2af15c3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/c/weaver/weave/perfflow_weave_common.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,21 @@ bool weave_ns::WeaveCommon::insertAfter(Module &m, Function &f, StringRef &a,
153153
for (BasicBlock &bb : f)
154154
{
155155
Instruction *inst = bb.getTerminator();
156+
bool valid = false;
156157
if (isa<ReturnInst>(inst) || isa<ResumeInst>(inst))
157158
{
159+
valid = true;
160+
} else if (isa<UnreachableInst>(inst)) {
161+
if (auto *call = dyn_cast<CallInst>(inst->getPrevNode())) {
162+
Function *callee = call->getCalledFunction();
163+
if (callee && callee->getName() == "pthread_exit" || callee->getName() == "exit" || callee->getName() == "abort") {
164+
inst = inst->getPrevNode();
165+
valid = true;
166+
}
167+
}
168+
}
169+
170+
if (valid) {
158171
IRBuilder<> builder(inst);
159172
Value *v1 = builder.CreateGlobalStringPtr(m.getName(), "str");
160173
Value *v2 = builder.CreateGlobalStringPtr(f.getName(), "str");

0 commit comments

Comments
 (0)