diff --git a/clang/test/utils/update_cc_test_checks/Inputs/annotations.c b/clang/test/utils/update_cc_test_checks/Inputs/annotations.c new file mode 100644 --- /dev/null +++ b/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; +} diff --git a/clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected b/clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected new file mode 100644 --- /dev/null +++ b/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; +} diff --git a/clang/test/utils/update_cc_test_checks/annotations.test b/clang/test/utils/update_cc_test_checks/annotations.test new file mode 100644 --- /dev/null +++ b/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 diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py --- a/llvm/utils/UpdateTestChecks/common.py +++ b/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 = [