Skip to content

Commit b38cc9c

Browse files
committed
When loop extraction succeeds, make sure to map the function pointers over
to avoid dangling references. llvm-svn: 12470
1 parent 7e51a50 commit b38cc9c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

llvm/tools/bugpoint/Miscompilation.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,17 @@ static bool ExtractLoops(BugDriver &BD,
268268
exit(1);
269269
}
270270
delete ToOptimizeLoopExtracted;
271+
272+
// All of the Function*'s in the MiscompiledFunctions list are in the old
273+
// module. Make sure to update them to point to the corresponding functions
274+
// in the new module.
275+
for (unsigned i = 0, e = MiscompiledFunctions.size(); i != e; ++i) {
276+
Function *OldF = MiscompiledFunctions[i];
277+
Function *NewF =
278+
ToNotOptimize->getFunction(OldF->getName(), OldF->getFunctionType());
279+
MiscompiledFunctions[i] = NewF;
280+
}
281+
271282
BD.setNewProgram(ToNotOptimize);
272283
MadeChange = true;
273284
}

0 commit comments

Comments
 (0)