diff --git a/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/x86-dead-def.mir b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/x86-dead-def.mir new file mode 100644 index 00000000000000..b6695624da485a --- /dev/null +++ b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/x86-dead-def.mir @@ -0,0 +1,20 @@ +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py +# RUN: llc -mtriple=x86_64-linux-gnu -run-pass=none -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK + +--- | + + define void @test() { + unreachable + } + +... +--- +name: test +alignment: 16 +registers: + - { id: 0, class: gpr, preferred-register: '' } +body: | + bb.1: + dead %0(s32) = G_CONSTANT i32 0 + +... diff --git a/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/x86-dead-def.mir.expected b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/x86-dead-def.mir.expected new file mode 100644 index 00000000000000..f8b01e63a94acd --- /dev/null +++ b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/x86-dead-def.mir.expected @@ -0,0 +1,22 @@ +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py +# RUN: llc -mtriple=x86_64-linux-gnu -run-pass=none -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK + +--- | + + define void @test() { + unreachable + } + +... +--- +name: test +alignment: 16 +registers: + - { id: 0, class: gpr, preferred-register: '' } +body: | + bb.1: + ; CHECK-LABEL: name: test + ; CHECK: dead [[C:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 0 + dead %0(s32) = G_CONSTANT i32 0 + +... diff --git a/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/x86-dead-def.test b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/x86-dead-def.test new file mode 100644 index 00000000000000..3fb19a711fdb3b --- /dev/null +++ b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/x86-dead-def.test @@ -0,0 +1,5 @@ +# REQUIRES: x86-registered-target +## Check that update_mir_test_checks replaces vregs in dead definitions + +# RUN: cp -f %S/Inputs/x86-dead-def.mir %t.mir && %update_mir_test_checks %t.mir +# RUN: diff -u %S/Inputs/x86-dead-def.mir.expected %t.mir diff --git a/llvm/utils/update_mir_test_checks.py b/llvm/utils/update_mir_test_checks.py index 5fb811023922ae..4d275b6870d6cd 100755 --- a/llvm/utils/update_mir_test_checks.py +++ b/llvm/utils/update_mir_test_checks.py @@ -36,9 +36,11 @@ MI_FLAGS_STR= ( r'(frame-setup |frame-destroy |nnan |ninf |nsz |arcp |contract |afn ' r'|reassoc |nuw |nsw |exact |nofpexcept |nomerge )*') +VREG_DEF_FLAGS_STR = r'(?:dead )*' VREG_DEF_RE = re.compile( - r'^ *(?P{0}(?:, {0})*) = ' - r'{1}(?P[A-Zt][A-Za-z0-9_]+)'.format(VREG_RE.pattern, MI_FLAGS_STR)) + r'^ *(?P{2}{0}(?:, {2}{0})*) = ' + r'{1}(?P[A-Zt][A-Za-z0-9_]+)'.format( + VREG_RE.pattern, MI_FLAGS_STR, VREG_DEF_FLAGS_STR)) MIR_PREFIX_DATA_RE = re.compile(r'^ *(;|bb.[0-9].*: *$|[a-z]+:( |$)|$)') IR_FUNC_NAME_RE = re.compile(