aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2025-05-28 16:03:24 +0100
committerGitHub <noreply@github.com>2025-05-28 16:03:24 +0100
commitfb923e98d13e80d0d1cf878ba5b10da4e81b5cd5 (patch)
tree488e36db09486eaace5be777b39792f9e5fa3410 /llvm/lib/Transforms/Utils/Local.cpp
parent61ec8fc283fcdf4d2a131bc1bf8102e84d8560c6 (diff)
downloadllvm-fb923e98d13e80d0d1cf878ba5b10da4e81b5cd5.zip
llvm-fb923e98d13e80d0d1cf878ba5b10da4e81b5cd5.tar.gz
llvm-fb923e98d13e80d0d1cf878ba5b10da4e81b5cd5.tar.bz2
[Local] Verify opcodes match for all insts passed to mergeFlags (NFC). (#141231)
The logic for tracking flags relies on all instructions having the same opcode. Add an assert to check, as suggested in https://github.com/llvm/llvm-project/pull/140406. PR: https://github.com/llvm/llvm-project/pull/141231
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 69dcd30..fe1391a 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -4364,6 +4364,13 @@ bool llvm::inferAttributesFromOthers(Function &F) {
}
void OverflowTracking::mergeFlags(Instruction &I) {
+#ifndef NDEBUG
+ if (Opcode)
+ assert(Opcode == I.getOpcode() &&
+ "can only use mergeFlags on instructions with matching opcodes");
+ else
+ Opcode = I.getOpcode();
+#endif
if (isa<OverflowingBinaryOperator>(&I)) {
HasNUW &= I.hasNoUnsignedWrap();
HasNSW &= I.hasNoSignedWrap();