[clang] Reland "[HIP] Use original file path for CUID" (#108771) (PR #111885)

Artem Belevich via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 10 12:05:58 PDT 2024


================
@@ -1,13 +1,15 @@
 // Check CUID generated by hash.
 // The same CUID is generated for the same file with the same options.
 
+// RUN: cd %S
+
 // RUN: %clang -### -x hip --target=x86_64-unknown-linux-gnu --no-offload-new-driver \
 // RUN:   --offload-arch=gfx906 -c -nogpuinc -nogpulib -fuse-cuid=hash \
-// RUN:   %S/Inputs/hip_multiple_inputs/a.cu >%t.out 2>&1
----------------
Artem-B wrote:

That will likely break tests done outside of the source tree.

With the tests using `-cuid=[[CUID:[0-9a-f]+]]` the cuild matching itself would work fine.

What we need to do is verify that a host-only compilation produces the same hash value. Previously we've hardcoded that value, which is IIUIC, what broken things on mac.

One way to handle it is to run two clang commands in the same RUN statement, one for complete compilation, and one for the host only, and then verify that all cc1 compilations have the same CUID. We may also thrown in a device-only compilation for completeness sake.

e.g.
```
RUN: ( clang - ###; clang -### --cuda-host-only) | FileCheck
```

Not sure if process grouping would be portable, though. Another way to do it may be to just dump compiler output into a temp file, and then run filecheck on it.

```
RUN: clang -### > %t
RUN: clang -### --cuda-host-only >> %t
RUN: cat %t | FileCheck %s 
```


https://github.com/llvm/llvm-project/pull/111885


More information about the cfe-commits mailing list