summaryrefslogtreecommitdiff
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.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index c63618d9dd12..09461e65e2dc 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -7885,6 +7885,13 @@ static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I, bool PtrValu
case Instruction::Call:
case Instruction::CallBr:
case Instruction::Invoke:
+ case Instruction::UDiv:
+ case Instruction::URem:
+ // Note: signed div/rem of INT_MIN / -1 is also immediate UB, not
+ // implemented to avoid code complexity as it is unclear how useful such
+ // logic is.
+ case Instruction::SDiv:
+ case Instruction::SRem:
return true;
}
});
@@ -7986,6 +7993,9 @@ static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I, bool PtrValu
}
}
}
+ // Div/Rem by zero is immediate UB
+ if (match(Use, m_BinOp(m_Value(), m_Specific(I))) && Use->isIntDivRem())
+ return true;
}
return false;
}