Skip to content
Snippets Groups Projects
Commit b919d43f authored by Aaron Councilman's avatar Aaron Councilman
Browse files

Fix infinite loop in getFirstNonMarker

parent 0b6dc930
No related branches found
No related tags found
No related merge requests found
...@@ -460,15 +460,19 @@ static Instruction* getFirstNonDebug(BasicBlock* block) { ...@@ -460,15 +460,19 @@ static Instruction* getFirstNonDebug(BasicBlock* block) {
return inst; return inst;
} }
// Finds the first instruction in the basic block which is not a marker and no
// instruction after it in the block is either
Instruction* HCCVerifier::getFirstNonMarker(BasicBlock* block) { Instruction* HCCVerifier::getFirstNonMarker(BasicBlock* block) {
Instruction* result = block->getFirstNonPHIOrDbg(); // Traverse from the end, stopping when we encounter a marker
while (!result->isTerminator()) { Instruction* current = block->getTerminator();
CallInst* call = dyn_cast<CallInst>(result); Instruction* result = current;
if (!call) break; while (current) {
if (markerFunctions.find(call->getCalledFunction()) if (CallInst* call = dyn_cast<CallInst>(current)) {
!= markerFunctions.end()) { if (markerFunctions.find(call->getCalledFunction())
result = result->getNextNonDebugInstruction(); != markerFunctions.end()) break;
} }
result = current;
current = current->getPrevNonDebugInstruction();
} }
return result; return result;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment