mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
ExitSSA: fix insertion of undefs
Before this commit we were replacing all uses of a PHI that were not used by other PHIs with llvm::UndefValue. That was wrong. The replacement is valid only if the use is used by a PHINode that is in the same group. This commit fixes the condition for such a replacement to take place.
This commit is contained in:
@@ -433,11 +433,11 @@ static void replacePHIEquivalenceClass(const SetVector<PHINode *> &PHIs,
|
||||
for (Use &U : llvm::make_early_inc_range(PHI->uses())) {
|
||||
revng_log(Log, "in User: " << dumpToString(U.getUser()));
|
||||
|
||||
Value *NewOperand = nullptr;
|
||||
if (isa<PHINode>(U.getUser()))
|
||||
Value *NewOperand = NewLoad;
|
||||
if (auto *PHIUser = dyn_cast<PHINode>(U.getUser());
|
||||
PHIUser and PHIs.contains(PHIUser)) {
|
||||
NewOperand = UndefValue::get(PHI->getType());
|
||||
else
|
||||
NewOperand = NewLoad;
|
||||
}
|
||||
revng_log(Log, "replaced with: " << dumpToString(NewOperand));
|
||||
U.set(NewOperand);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user