[PATCH] D153190: [UpdateTestChecks] Add update test check support for fpmath metadata

John McIver via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 16 20:26:42 PDT 2023


jmciver created this revision.
Herald added subscribers: luismarques, arichardson.
Herald added a project: All.
jmciver edited the summary of this revision.
jmciver added reviewers: jdoerfert, arichardson.
jmciver added a subscriber: nlopes.
jmciver added a reviewer: nhaehnle.
jmciver edited the summary of this revision.
jmciver published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Add support for fpmath metadata to update tools based on
UpdateTestChecks.common. A basic test has been added to update_test_checks
independent of existing tests, see basic-metadata.ll.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153190

Files:
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/basic-metadata.ll
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/basic-metadata.ll.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/basic-metadata.ll.globals.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/basic-metadata.test
  llvm/utils/UpdateTestChecks/common.py


Index: llvm/utils/UpdateTestChecks/common.py
===================================================================
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -976,6 +976,7 @@
     ),
     NamelessValue(r"DBG", "!", r"!dbg ", r"![0-9]+", None),
     NamelessValue(r"DIASSIGNID", "!", r"!DIAssignID ", r"![0-9]+", None),
+    NamelessValue(r"FPMATH", "!", r"!fpmath ", r"![0-9]+", None),
     NamelessValue(r"PROF", "!", r"!prof ", r"![0-9]+", None),
     NamelessValue(r"TBAA", "!", r"!tbaa ", r"![0-9]+", None),
     NamelessValue(r"TBAA_STRUCT", "!", r"!tbaa.struct ", r"![0-9]+", None),
Index: llvm/test/tools/UpdateTestChecks/update_test_checks/basic-metadata.test
===================================================================
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_test_checks/basic-metadata.test
@@ -0,0 +1,9 @@
+## Basic metadata test checking using update_test_checks.py
+# RUN: cp -f %S/Inputs/basic-metadata.ll %t.ll && %update_test_checks %t.ll
+# RUN: diff -u %t.ll %S/Inputs/basic-metadata.ll.expected
+## Check that running the script again does not change the result:
+# RUN: %update_test_checks %t.ll
+# RUN: diff -u %t.ll %S/Inputs/basic-metadata.ll.expected
+## Also try the --check-globals flag
+# RUN: %update_test_checks %t.ll --check-globals
+# RUN: diff -u %t.ll %S/Inputs/basic-metadata.ll.globals.expected
Index: llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/basic-metadata.ll.globals.expected
===================================================================
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/basic-metadata.ll.globals.expected
@@ -0,0 +1,19 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
+; Just run it through opt, no passes needed.
+; RUN: opt < %s -S | FileCheck %s
+
+define double @fpmathTest(double %a, double %b) {
+; CHECK-LABEL: @fpmathTest(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[RET:%.*]] = fmul double [[A:%.*]], [[B:%.*]], !fpmath [[FPMATH0:![0-9]+]]
+; CHECK-NEXT:    ret double [[RET]]
+;
+entry:
+  %ret = fmul double %a, %b, !fpmath !0
+  ret double %ret
+}
+
+!0 = !{float 3.0}
+;.
+; CHECK: [[FPMATH0]] = !{float 3.000000e+00}
+;.
Index: llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/basic-metadata.ll.expected
===================================================================
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/basic-metadata.ll.expected
@@ -0,0 +1,16 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; Just run it through opt, no passes needed.
+; RUN: opt < %s -S | FileCheck %s
+
+define double @fpmathTest(double %a, double %b) {
+; CHECK-LABEL: @fpmathTest(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[RET:%.*]] = fmul double [[A:%.*]], [[B:%.*]], !fpmath [[FPMATH0:![0-9]+]]
+; CHECK-NEXT:    ret double [[RET]]
+;
+entry:
+  %ret = fmul double %a, %b, !fpmath !0
+  ret double %ret
+}
+
+!0 = !{float 3.0}
Index: llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/basic-metadata.ll
===================================================================
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/basic-metadata.ll
@@ -0,0 +1,10 @@
+; Just run it through opt, no passes needed.
+; RUN: opt < %s -S | FileCheck %s
+
+define double @fpmathTest(double %a, double %b) {
+entry:
+  %ret = fmul double %a, %b, !fpmath !0
+  ret double %ret
+}
+
+!0 = !{float 3.0}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153190.532351.patch
Type: text/x-patch
Size: 3521 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230617/da82317d/attachment.bin>


More information about the llvm-commits mailing list