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:
Pietro Fezzardi
2026-06-16 17:09:41 +02:00
parent c2ce667bd8
commit 422319f4d8
+4 -4
View File
@@ -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);
}