mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
Anticipate cpu_loop_exit removal
Fix of another bug showing up only with LLVM in debug mode: splitting a malformed basic block is not allowed, and we had a function call after a `ret` instruction.
This commit is contained in:
+10
-6
@@ -427,8 +427,13 @@ bool CpuLoopExitPass::runOnModule(llvm::Module& M) {
|
||||
|
||||
assert(CpuLoop != nullptr);
|
||||
|
||||
for (User *TheUser : CpuLoopExit->users()) {
|
||||
auto *Call = cast<CallInst>(TheUser);
|
||||
std::queue<User *> CpuLoopExitUsers;
|
||||
for (User *TheUser : CpuLoopExit->users())
|
||||
CpuLoopExitUsers.push(TheUser);
|
||||
|
||||
while (!CpuLoopExitUsers.empty()) {
|
||||
auto *Call = cast<CallInst>(CpuLoopExitUsers.front());
|
||||
CpuLoopExitUsers.pop();
|
||||
assert(Call->getCalledFunction() == CpuLoopExit);
|
||||
|
||||
// Call cpu_loop
|
||||
@@ -444,9 +449,11 @@ bool CpuLoopExitPass::runOnModule(llvm::Module& M) {
|
||||
auto *Unreach = cast<UnreachableInst>(&*++Call->getIterator());
|
||||
Unreach->eraseFromParent();
|
||||
|
||||
// Remove the call to cpu_loop_exit
|
||||
Function *Caller = Call->getParent()->getParent();
|
||||
|
||||
// Remove the call to cpu_loop_exit
|
||||
Call->eraseFromParent();
|
||||
|
||||
if (FixedCallers.find(Caller) == FixedCallers.end()) {
|
||||
FixedCallers.insert(Caller);
|
||||
|
||||
@@ -518,9 +525,6 @@ bool CpuLoopExitPass::runOnModule(llvm::Module& M) {
|
||||
}
|
||||
}
|
||||
|
||||
for (User *TheUser : CpuLoopExit->users())
|
||||
cast<Instruction>(TheUser)->eraseFromParent();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user