aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 3fa3c0f..8f717cb 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -7573,11 +7573,31 @@ static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I, bool PtrValu
return false;
if (C->isNullValue() || isa<UndefValue>(C)) {
- // Only look at the first use, avoid hurting compile time with long uselists
- auto *Use = cast<Instruction>(*I->user_begin());
+ // Only look at the first use we can handle, avoid hurting compile time with
+ // long uselists
+ auto FindUse = llvm::find_if(I->users(), [](auto *U) {
+ auto *Use = cast<Instruction>(U);
+ // Change this list when we want to add new instructions.
+ switch (Use->getOpcode()) {
+ default:
+ return false;
+ case Instruction::GetElementPtr:
+ case Instruction::Ret:
+ case Instruction::BitCast:
+ case Instruction::Load:
+ case Instruction::Store:
+ case Instruction::Call:
+ case Instruction::CallBr:
+ case Instruction::Invoke:
+ return true;
+ }
+ });
+ if (FindUse == I->user_end())
+ return false;
+ auto *Use = cast<Instruction>(*FindUse);
// Bail out if Use is not in the same BB as I or Use == I or Use comes
- // before I in the block. The latter two can be the case if Use is a PHI
- // node.
+ // before I in the block. The latter two can be the case if Use is a
+ // PHI node.
if (Use->getParent() != I->getParent() || Use == I || Use->comesBefore(I))
return false;