-
Notifications
You must be signed in to change notification settings - Fork 15k
Add metadata pointer regex substitution to MIR update script #163253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
bb613f7 to
bf7ed92
Compare
llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/amdgpu-metadata-pointer.ll
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder there should be more test impacted by this? The CI result would test us
I assume the CI will trigger if I un-draft the PR? I just didn't want github to start automatically adding the maintainers for review until you guys had a look at it in case I missed something silly |
ab72fe7 to
eedeabd
Compare
llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/amdgpu-metadata-pointer.ll
Show resolved
Hide resolved
llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/amdgpu-metadata-pointer.ll
Show resolved
Hide resolved
Signed-off-by: Domenic Nutile <domenic.nutile@gmail.com>
Signed-off-by: Domenic Nutile <domenic.nutile@gmail.com>
Signed-off-by: Domenic Nutile <domenic.nutile@gmail.com>
eedeabd to
3a84379
Compare
|
@llvm/pr-subscribers-backend-amdgpu Author: None (saxlungs) ChangesLLC prints metadata operands as pointers in MIR, meaning tests can fail due to stale values with future changes. This PR makes it so the MIR test update script will substitute these pointers in the output with regex that generically capture any pointer, avoiding stale value test failures. Full diff: https://github.com/llvm/llvm-project/pull/163253.diff 4 Files Affected:
diff --git a/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/amdgpu-metadata-pointer.ll b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/amdgpu-metadata-pointer.ll
new file mode 100644
index 0000000000000..3268f1bfdf30a
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/amdgpu-metadata-pointer.ll
@@ -0,0 +1,29 @@
+; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 6
+; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx900 -stop-after=irtranslator -o - %s | FileCheck %s
+
+define i32 @reloc_constant() {
+ ; CHECK-LABEL: name: reloc_constant
+ ; CHECK: bb.1 (%ir-block.0):
+ ; CHECK-NEXT: [[INT:%[0-9]+]]:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.reloc.constant), !0
+ ; CHECK-NEXT: [[INT1:%[0-9]+]]:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.reloc.constant), <0xc50ff1ce>
+ ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[INT]], [[INT1]]
+ ; CHECK-NEXT: $vgpr0 = COPY [[ADD]](s32)
+ ; CHECK-NEXT: SI_RETURN implicit $vgpr0
+ %val0 = call i32 @llvm.amdgcn.reloc.constant(metadata !0)
+ %val1 = call i32 @llvm.amdgcn.reloc.constant(metadata i32 4)
+ %res = add i32 %val0, %val1
+ ret i32 %res
+}
+
+define i32 @reloc_other_constant() {
+ %val0 = call i32 @llvm.amdgcn.reloc.constant(metadata !0)
+ %val1 = call i32 @llvm.amdgcn.reloc.constant(metadata i32 8)
+ %res = add i32 %val0, %val1
+ ret i32 %res
+}
+
+declare i32 @llvm.amdgcn.reloc.constant(metadata) #0
+
+attributes #0 = { nounwind readnone speculatable willreturn }
+
+!0 = !{!"arst"}
diff --git a/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/amdgpu-metadata-pointer.ll.expected b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/amdgpu-metadata-pointer.ll.expected
new file mode 100644
index 0000000000000..71bbe7cbb1d02
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/amdgpu-metadata-pointer.ll.expected
@@ -0,0 +1,36 @@
+; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 6
+; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx900 -stop-after=irtranslator -o - %s | FileCheck %s
+
+define i32 @reloc_constant() {
+ ; CHECK-LABEL: name: reloc_constant
+ ; CHECK: bb.1 (%ir-block.0):
+ ; CHECK-NEXT: [[INT:%[0-9]+]]:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.reloc.constant), !0
+ ; CHECK-NEXT: [[INT1:%[0-9]+]]:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.reloc.constant), <0x{{[0-9a-f]+}}>
+ ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[INT]], [[INT1]]
+ ; CHECK-NEXT: $vgpr0 = COPY [[ADD]](s32)
+ ; CHECK-NEXT: SI_RETURN implicit $vgpr0
+ %val0 = call i32 @llvm.amdgcn.reloc.constant(metadata !0)
+ %val1 = call i32 @llvm.amdgcn.reloc.constant(metadata i32 4)
+ %res = add i32 %val0, %val1
+ ret i32 %res
+}
+
+define i32 @reloc_other_constant() {
+ ; CHECK-LABEL: name: reloc_other_constant
+ ; CHECK: bb.1 (%ir-block.0):
+ ; CHECK-NEXT: [[INT:%[0-9]+]]:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.reloc.constant), !0
+ ; CHECK-NEXT: [[INT1:%[0-9]+]]:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.reloc.constant), <0x{{[0-9a-f]+}}>
+ ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[INT]], [[INT1]]
+ ; CHECK-NEXT: $vgpr0 = COPY [[ADD]](s32)
+ ; CHECK-NEXT: SI_RETURN implicit $vgpr0
+ %val0 = call i32 @llvm.amdgcn.reloc.constant(metadata !0)
+ %val1 = call i32 @llvm.amdgcn.reloc.constant(metadata i32 8)
+ %res = add i32 %val0, %val1
+ ret i32 %res
+}
+
+declare i32 @llvm.amdgcn.reloc.constant(metadata) #0
+
+attributes #0 = { nounwind readnone speculatable willreturn }
+
+!0 = !{!"arst"}
diff --git a/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/amdgpu-metadata-pointer.test b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/amdgpu-metadata-pointer.test
new file mode 100644
index 0000000000000..bcdbb6e384372
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/amdgpu-metadata-pointer.test
@@ -0,0 +1,7 @@
+# REQUIRES: amdgpu-registered-target
+## Check that update_mir_test_checks properly replaces metadata operand pointers
+## written out by LLC with a pointer-capturing regex, and also does not produce
+## new metadata operand pointers
+
+# RUN: cp -f %S/Inputs/amdgpu-metadata-pointer.ll %t.ll && %update_mir_test_checks %t.ll
+# RUN: diff -u %S/Inputs/amdgpu-metadata-pointer.ll.expected %t.ll
diff --git a/llvm/utils/update_mir_test_checks.py b/llvm/utils/update_mir_test_checks.py
index c4ee0523a6469..64fc4076b9371 100755
--- a/llvm/utils/update_mir_test_checks.py
+++ b/llvm/utils/update_mir_test_checks.py
@@ -65,6 +65,8 @@
flags=(re.M | re.S),
)
+MD_PTR_RE = re.compile(r"\<0x[a-f0-9]+\>", re.IGNORECASE)
+
class LLC:
def __init__(self, bin):
@@ -247,6 +249,14 @@ def update_test_file(args, test, autogenerated_note):
common.warn("No triple found: skipping file", test_file=test)
return
+ # Replace metadata pointer values inserted by LLC with generic regex
+ # capturing the pointer's format so that stale values don't break tests
+ no_pointer_output = ""
+ for line in raw_tool_output.splitlines():
+ line = MD_PTR_RE.sub("<0x{{[0-9a-f]+}}>", line)
+ no_pointer_output += line + "\n"
+ raw_tool_output = no_pointer_output
+
build_function_info_dictionary(
test,
raw_tool_output,
|
|
@llvm/pr-subscribers-testing-tools Author: None (saxlungs) ChangesLLC prints metadata operands as pointers in MIR, meaning tests can fail due to stale values with future changes. This PR makes it so the MIR test update script will substitute these pointers in the output with regex that generically capture any pointer, avoiding stale value test failures. Full diff: https://github.com/llvm/llvm-project/pull/163253.diff 4 Files Affected:
diff --git a/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/amdgpu-metadata-pointer.ll b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/amdgpu-metadata-pointer.ll
new file mode 100644
index 0000000000000..3268f1bfdf30a
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/amdgpu-metadata-pointer.ll
@@ -0,0 +1,29 @@
+; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 6
+; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx900 -stop-after=irtranslator -o - %s | FileCheck %s
+
+define i32 @reloc_constant() {
+ ; CHECK-LABEL: name: reloc_constant
+ ; CHECK: bb.1 (%ir-block.0):
+ ; CHECK-NEXT: [[INT:%[0-9]+]]:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.reloc.constant), !0
+ ; CHECK-NEXT: [[INT1:%[0-9]+]]:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.reloc.constant), <0xc50ff1ce>
+ ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[INT]], [[INT1]]
+ ; CHECK-NEXT: $vgpr0 = COPY [[ADD]](s32)
+ ; CHECK-NEXT: SI_RETURN implicit $vgpr0
+ %val0 = call i32 @llvm.amdgcn.reloc.constant(metadata !0)
+ %val1 = call i32 @llvm.amdgcn.reloc.constant(metadata i32 4)
+ %res = add i32 %val0, %val1
+ ret i32 %res
+}
+
+define i32 @reloc_other_constant() {
+ %val0 = call i32 @llvm.amdgcn.reloc.constant(metadata !0)
+ %val1 = call i32 @llvm.amdgcn.reloc.constant(metadata i32 8)
+ %res = add i32 %val0, %val1
+ ret i32 %res
+}
+
+declare i32 @llvm.amdgcn.reloc.constant(metadata) #0
+
+attributes #0 = { nounwind readnone speculatable willreturn }
+
+!0 = !{!"arst"}
diff --git a/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/amdgpu-metadata-pointer.ll.expected b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/amdgpu-metadata-pointer.ll.expected
new file mode 100644
index 0000000000000..71bbe7cbb1d02
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/Inputs/amdgpu-metadata-pointer.ll.expected
@@ -0,0 +1,36 @@
+; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 6
+; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx900 -stop-after=irtranslator -o - %s | FileCheck %s
+
+define i32 @reloc_constant() {
+ ; CHECK-LABEL: name: reloc_constant
+ ; CHECK: bb.1 (%ir-block.0):
+ ; CHECK-NEXT: [[INT:%[0-9]+]]:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.reloc.constant), !0
+ ; CHECK-NEXT: [[INT1:%[0-9]+]]:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.reloc.constant), <0x{{[0-9a-f]+}}>
+ ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[INT]], [[INT1]]
+ ; CHECK-NEXT: $vgpr0 = COPY [[ADD]](s32)
+ ; CHECK-NEXT: SI_RETURN implicit $vgpr0
+ %val0 = call i32 @llvm.amdgcn.reloc.constant(metadata !0)
+ %val1 = call i32 @llvm.amdgcn.reloc.constant(metadata i32 4)
+ %res = add i32 %val0, %val1
+ ret i32 %res
+}
+
+define i32 @reloc_other_constant() {
+ ; CHECK-LABEL: name: reloc_other_constant
+ ; CHECK: bb.1 (%ir-block.0):
+ ; CHECK-NEXT: [[INT:%[0-9]+]]:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.reloc.constant), !0
+ ; CHECK-NEXT: [[INT1:%[0-9]+]]:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.reloc.constant), <0x{{[0-9a-f]+}}>
+ ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[INT]], [[INT1]]
+ ; CHECK-NEXT: $vgpr0 = COPY [[ADD]](s32)
+ ; CHECK-NEXT: SI_RETURN implicit $vgpr0
+ %val0 = call i32 @llvm.amdgcn.reloc.constant(metadata !0)
+ %val1 = call i32 @llvm.amdgcn.reloc.constant(metadata i32 8)
+ %res = add i32 %val0, %val1
+ ret i32 %res
+}
+
+declare i32 @llvm.amdgcn.reloc.constant(metadata) #0
+
+attributes #0 = { nounwind readnone speculatable willreturn }
+
+!0 = !{!"arst"}
diff --git a/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/amdgpu-metadata-pointer.test b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/amdgpu-metadata-pointer.test
new file mode 100644
index 0000000000000..bcdbb6e384372
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_mir_test_checks/amdgpu-metadata-pointer.test
@@ -0,0 +1,7 @@
+# REQUIRES: amdgpu-registered-target
+## Check that update_mir_test_checks properly replaces metadata operand pointers
+## written out by LLC with a pointer-capturing regex, and also does not produce
+## new metadata operand pointers
+
+# RUN: cp -f %S/Inputs/amdgpu-metadata-pointer.ll %t.ll && %update_mir_test_checks %t.ll
+# RUN: diff -u %S/Inputs/amdgpu-metadata-pointer.ll.expected %t.ll
diff --git a/llvm/utils/update_mir_test_checks.py b/llvm/utils/update_mir_test_checks.py
index c4ee0523a6469..64fc4076b9371 100755
--- a/llvm/utils/update_mir_test_checks.py
+++ b/llvm/utils/update_mir_test_checks.py
@@ -65,6 +65,8 @@
flags=(re.M | re.S),
)
+MD_PTR_RE = re.compile(r"\<0x[a-f0-9]+\>", re.IGNORECASE)
+
class LLC:
def __init__(self, bin):
@@ -247,6 +249,14 @@ def update_test_file(args, test, autogenerated_note):
common.warn("No triple found: skipping file", test_file=test)
return
+ # Replace metadata pointer values inserted by LLC with generic regex
+ # capturing the pointer's format so that stale values don't break tests
+ no_pointer_output = ""
+ for line in raw_tool_output.splitlines():
+ line = MD_PTR_RE.sub("<0x{{[0-9a-f]+}}>", line)
+ no_pointer_output += line + "\n"
+ raw_tool_output = no_pointer_output
+
build_function_info_dictionary(
test,
raw_tool_output,
|
|
@davemgreen @MatzeB If either of you could give this a quick review that would be great |
I will add them as reviewers. I forgot you need commit access to do that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Please wait a bit for more comments from other reviewers since the update script could impacts the whole test repo
Can you work on fixing that rather than introducing a new script to workaround a bug |
|
LLC prints metadata operands as pointers in MIR, meaning tests can fail due to stale values with future changes. This PR makes it so the MIR test update script will substitute these pointers in the output with regex that generically capture any pointer, avoiding stale value test failures.