diff options
author | Florian Hahn <flo@fhahn.com> | 2022-09-04 22:22:36 +0100 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2022-09-04 22:26:18 +0100 |
commit | ba3d29f871e04c6cfc64ed84c478dd1846e6148d (patch) | |
tree | a07e8d248f184eb592c51675b9fd60def33df2a9 /llvm/lib/Transforms/Utils/LCSSA.cpp | |
parent | a10d42dd45f470babb993626e4a35d1fd0806388 (diff) | |
download | llvm-ba3d29f871e04c6cfc64ed84c478dd1846e6148d.zip llvm-ba3d29f871e04c6cfc64ed84c478dd1846e6148d.tar.gz llvm-ba3d29f871e04c6cfc64ed84c478dd1846e6148d.tar.bz2 |
[LCSSA] Update unreachable uses with poison.
Users of LCSSA may not expect non-phi uses when checking the uses
outside a loop, which may cause crashes. This is due to the fact that we
do not update uses in unreachable blocks.
To ensure all reachable uses outside the loop are phis, update uses in
unreachable blocks to use poison in dead code.
Fixes #57508.
Diffstat (limited to 'llvm/lib/Transforms/Utils/LCSSA.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LCSSA.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/LCSSA.cpp b/llvm/lib/Transforms/Utils/LCSSA.cpp index 76f2685..af79dc4 100644 --- a/llvm/lib/Transforms/Utils/LCSSA.cpp +++ b/llvm/lib/Transforms/Utils/LCSSA.cpp @@ -107,13 +107,15 @@ bool llvm::formLCSSAForInstructions(SmallVectorImpl<Instruction *> &Worklist, if (ExitBlocks.empty()) continue; - for (Use &U : I->uses()) { + for (Use &U : make_early_inc_range(I->uses())) { Instruction *User = cast<Instruction>(U.getUser()); BasicBlock *UserBB = User->getParent(); // Skip uses in unreachable blocks. - if (!DT.isReachableFromEntry(UserBB)) + if (!DT.isReachableFromEntry(UserBB)) { + U.set(PoisonValue::get(I->getType())); continue; + } // For practical purposes, we consider that the use in a PHI // occurs in the respective predecessor block. For more info, |