Skip to content

Commit 78ccaf1

Browse files
authored
[update_mir_test_checks] Add missing MIFlags (#150012)
If the update_mir_test_checks.py script is aware of MIFlags, it can produce meaningful identifiers in generated FileCheck lines. A few MIFlags that were introduced more recently have been missing from the script. Ideally, the MIFlags would be specified in a single place and automatically made known to the script to avoid this divergence, but for now adding a comment pointing to the script at the place where the MIFlags are printed seems like a reasonable trade-off. This PR only regenerates check lines for a single test as an example of the effect; other affected tests are not regenerated for now to avoid unnecessary test churn.
1 parent 07faafe commit 78ccaf1

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

llvm/lib/CodeGen/MIRPrinter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,9 @@ static void printMI(raw_ostream &OS, MFPrintState &State,
815815
if (MI.getFlag(MachineInstr::SameSign))
816816
OS << "samesign ";
817817

818+
// NOTE: Please add new MIFlags also to the MI_FLAGS_STR in
819+
// llvm/utils/update_mir_test_checks.py.
820+
818821
OS << TII->getName(MI.getOpcode());
819822

820823
LS = ListSeparator();

llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-gep-flags.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ define i32 @gep_nusw_nuw(ptr %ptr, i32 %idx) {
1717
; CHECK-NEXT: [[MUL1:%[0-9]+]]:_(s64) = G_MUL [[SEXT]], [[C]]
1818
; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[MUL1]](s64)
1919
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 4
20-
; CHECK-NEXT: %11:_(p0) = nuw nusw G_PTR_ADD [[PTR_ADD1]], [[C1]](s64)
21-
; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD %11(p0) :: (load (s32) from %ir.gep2)
20+
; CHECK-NEXT: [[PTR_ADD2:%[0-9]+]]:_(p0) = nuw nusw G_PTR_ADD [[PTR_ADD1]], [[C1]](s64)
21+
; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD2]](p0) :: (load (s32) from %ir.gep2)
2222
; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[LOAD]], [[LOAD1]]
2323
; CHECK-NEXT: $w0 = COPY [[ADD]](s32)
2424
; CHECK-NEXT: RET_ReallyLR implicit $w0
@@ -77,8 +77,8 @@ define i32 @gep_nusw(ptr %ptr, i32 %idx) {
7777
; CHECK-NEXT: [[MUL1:%[0-9]+]]:_(s64) = G_MUL [[SEXT]], [[C]]
7878
; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[MUL1]](s64)
7979
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 4
80-
; CHECK-NEXT: %11:_(p0) = nusw G_PTR_ADD [[PTR_ADD1]], [[C1]](s64)
81-
; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD %11(p0) :: (load (s32) from %ir.gep2)
80+
; CHECK-NEXT: [[PTR_ADD2:%[0-9]+]]:_(p0) = nusw G_PTR_ADD [[PTR_ADD1]], [[C1]](s64)
81+
; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD2]](p0) :: (load (s32) from %ir.gep2)
8282
; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[LOAD]], [[LOAD1]]
8383
; CHECK-NEXT: $w0 = COPY [[ADD]](s32)
8484
; CHECK-NEXT: RET_ReallyLR implicit $w0

llvm/utils/update_mir_test_checks.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,14 @@
3535
VREG_RE = re.compile(r"(%[0-9]+)(?:\.[a-z0-9_]+)?(?::[a-z0-9_]+)?(?:\([<>a-z0-9 ]+\))?")
3636
MI_FLAGS_STR = (
3737
r"(frame-setup |frame-destroy |nnan |ninf |nsz |arcp |contract |afn "
38-
r"|reassoc |nuw |nsw |exact |nofpexcept |nomerge |disjoint )*"
38+
r"|reassoc |nuw |nsw |exact |nofpexcept |nomerge |unpredictable "
39+
r"|noconvergent |nneg |disjoint |nusw |samesign )*"
3940
)
4041
VREG_DEF_FLAGS_STR = r"(?:dead |undef )*"
42+
43+
# Pattern to match the defined vregs and the opcode of an instruction that
44+
# defines vregs. Opcodes starting with a lower-case 't' are allowed to match
45+
# ARM's thumb instructions, like tADDi8 and t2ADDri.
4146
VREG_DEF_RE = re.compile(
4247
r"^ *(?P<vregs>{2}{0}(?:, {2}{0})*) = "
4348
r"{1}(?P<opcode>[A-Zt][A-Za-z0-9_]+)".format(

0 commit comments

Comments
 (0)