[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)
Henrik G Olsson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 14 07:34:09 PDT 2023
hnrklssn updated this revision to Diff 513589.
hnrklssn added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Add test case emitting !annotation from clang.
Make annotation matching a generic metadata fallback.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148216/new/
https://reviews.llvm.org/D148216
Files:
clang/test/utils/update_cc_test_checks/Inputs/annotations.c
clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected
clang/test/utils/update_cc_test_checks/annotations.test
llvm/utils/UpdateTestChecks/common.py
Index: llvm/utils/UpdateTestChecks/common.py
===================================================================
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -697,9 +697,10 @@
return self.global_ir_rhs_regexp is not None
# Return the IR prefix and check prefix we use for this kind or IR value,
- # e.g., (%, TMP) for locals.
+ # e.g., (%, TMP) for locals. If the IR prefix is a regex, return the prefix
+ # used in the IR output
def get_ir_prefix_from_ir_value_match(self, match):
- return self.ir_prefix, self.check_prefix
+ return re.search(self.ir_prefix, match[0])[0], self.check_prefix
# Return the IR regexp we use for this kind or IR value, e.g., [\w.-]+? for locals
def get_ir_regex_from_ir_value_re_match(self, match):
@@ -775,6 +776,7 @@
NamelessValue(r'META' , '!' , r'metadata ' , r'![0-9]+' , None ) ,
NamelessValue(r'META' , '!' , r'' , r'![0-9]+' , r'(?:distinct |)!.*' ) ,
NamelessValue(r'ACC_GRP' , '!' , r'!llvm.access.group ' , r'![0-9]+' , None ) ,
+ NamelessValue(r'META' , '!' , r'![a-z.]+ ' , r'![0-9]+' , None ) ,
]
asm_nameless_values = [
Index: clang/test/utils/update_cc_test_checks/annotations.test
===================================================================
--- /dev/null
+++ clang/test/utils/update_cc_test_checks/annotations.test
@@ -0,0 +1,4 @@
+## Test that !annotation metadata is matched correctly
+
+# RUN: cp %S/Inputs/annotations.c %t.c && %update_cc_test_checks %t.c
+# RUN: diff -u %S/Inputs/annotations.c.expected %t.c
Index: clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected
===================================================================
--- /dev/null
+++ clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected
@@ -0,0 +1,17 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks -ftrivial-auto-var-init=zero %s -emit-llvm -o - | FileCheck %s
+
+// CHECK-LABEL: @foo(
+// CHECK-NEXT: entry:
+// CHECK-NEXT: [[X:%.*]] = alloca i32, align 4
+// CHECK-NEXT: store i32 0, ptr [[X]], align 4, !annotation [[META2:![0-9]+]]
+// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[X]], align 4
+// CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP0]], 1
+// CHECK-NEXT: store i32 [[ADD]], ptr [[X]], align 4
+// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[X]], align 4
+// CHECK-NEXT: ret i32 [[TMP1]]
+//
+int foo() {
+ int x = x + 1;
+ return x;
+}
Index: clang/test/utils/update_cc_test_checks/Inputs/annotations.c
===================================================================
--- /dev/null
+++ clang/test/utils/update_cc_test_checks/Inputs/annotations.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks -ftrivial-auto-var-init=zero %s -emit-llvm -o - | FileCheck %s
+
+int foo() {
+ int x = x + 1;
+ return x;
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148216.513589.patch
Type: text/x-patch
Size: 3087 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230414/bb6303d7/attachment.bin>
More information about the llvm-commits
mailing list