[PATCH] D42712: [utils] Add utils/update_cc_test_checks.py

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 2 02:52:40 PST 2018


arichardson requested changes to this revision.
arichardson added a comment.
This revision now requires changes to proceed.

If I have the following:

  // RUN: %clang_cc1 -emit-llvm -o - %s -O2 | FileCheck %s
  
  int test(int a, int b) {
    return a + b;
  }

After running update_cc1_checks.py I get the following test (which will not pass because of the broken label):

  // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
  // RUN: %clang_cc1 -emit-llvm -o - %s -O2 | FileCheck %s
  
  // CHECK-LABEL: tests:
  // CHECK:       entry:
  // CHECK-NEXT:    %add = add nsw i32 %b, %a
  // CHECK-NEXT:    ret i32 %add
  int tests(int a, int b) {
    return a + b;
  }

The label assertions doesn't work:

  /Users/alex/devel/llvm/tools/clang/test/CodeGen/avr/test.c:7:17: error: expected string not found in input
  // CHECK-LABEL: tests:
                  ^
  <stdin>:1:1: note: scanning from here
  ; ModuleID = '/Users/alex/devel/llvm/tools/clang/test/CodeGen/avr/test.c'
  ^
  <stdin>:7:13: note: possible intended match here
  define i32 @tests(i32 signext %a, i32 signext %b) local_unnamed_addr #0 {



================
Comment at: utils/update_cc_test_checks.py:50
+    output = subprocess.check_output([args.c_index_test,
+        '-test-print-mangle', f.name])
+    if sys.version_info[0] > 2:
----------------
 I noticed this does not work on MacOS because the mangled_name will be `_test` on OSX but the IR still uses `@test`, so the script does not add any IR checks



================
Comment at: utils/update_cc_test_checks.py:60
+    # Note -test-print-mangle does not print file names so if #include is used,
+    # the line number may come from an included file.
+    ret[int(line)-1] = (spell, mangled)
----------------
If I add the following lines here the script works on MacOS:
```
    if mangled == "_" + spell:
      # HACK for MacOS (where the mangled name includes an _ for C but the IR won't):
      mangled = spell
```


Repository:
  rL LLVM

https://reviews.llvm.org/D42712





More information about the llvm-commits mailing list