[clang] [HLSL] Enable -fconvergent-functions by default (PR #86571)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 27 08:00:33 PDT 2024


llvm-beanz wrote:

> I was getting match errors with the RUN script. I went ahead and updated it with the checks in: `clang/test/CodeGen/convergent-functions.cpp` Hope that's correct/OK?
> 
> ```hlsl
> // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.4-library -emit-llvm -disable-llvm-passes -o - %s | FileCheck -check-prefixes=CHECK,CONVFUNC %s 
> 
> // CHECK: attributes
> // NOCONVFUNC-NOT: convergent
> // CONVFUNC-SAME: convergent
> // CHECK-SAME: }
> void fn() {
> };
> ```

With this the `NOCONVFUNC-NOT` line does nothing. Having multiple check prefixes here unnecessarily complicates the test. Since we're only running FileCheck once we really should only need the `CHECK` prefix.

> Now it just _checks_ the presence of `convergent` in attributes, as it does in `convergent-functions.cpp`. Note: I also left out the `#0` in the attributes to generalize it better. Is that okay?

I'd prefer a more specific match where we actually verify that the `convergent` attribute is applied to the function not just that the string `convergent` appears on the same line as the string `attributes`.

Something like this should work and insulates from the name mangling differences. I also added a run line to verify the SPIR-V targeting path which should be the same.

```hlsl
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.4-library -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple spirv-linux-vulkan-library -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s

void fn() {
};

// CHECK: define void {{.*}}fn{{.*}}()
// CHECK-SAME: #[[Attr:[0-9]+]]
// CHECK: attributes #[[Attr]] = { {{[^}]*}}convergent{{[^}]*}} }
```



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


More information about the cfe-commits mailing list