File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
include/llvm/Transforms/Utils Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -565,6 +565,12 @@ struct OverflowTracking {
565565 bool HasNSW = true ;
566566 bool IsDisjoint = true ;
567567
568+ #ifndef NDEBUG
569+ // / Opcode of merged instructions. All instructions passed to mergeFlags must
570+ // / have the same opcode.
571+ std::optional<unsigned > Opcode;
572+ #endif
573+
568574 // Note: At the moment, users are responsible to manage AllKnownNonNegative
569575 // and AllKnownNonZero manually. AllKnownNonNegative can be true in a case
570576 // where one of the operands is negative, but one the operators is not NSW.
Original file line number Diff line number Diff line change @@ -4364,6 +4364,13 @@ bool llvm::inferAttributesFromOthers(Function &F) {
43644364}
43654365
43664366void OverflowTracking::mergeFlags (Instruction &I) {
4367+ #ifndef NDEBUG
4368+ if (Opcode)
4369+ assert (Opcode == I.getOpcode () &&
4370+ " can only use mergeFlags on instructions with matching opcodes" );
4371+ else
4372+ Opcode = I.getOpcode ();
4373+ #endif
43674374 if (isa<OverflowingBinaryOperator>(&I)) {
43684375 HasNUW &= I.hasNoUnsignedWrap ();
43694376 HasNSW &= I.hasNoSignedWrap ();
You can’t perform that action at this time.
0 commit comments