-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HLSL] Enable -fconvergent-functions by default #86571
Conversation
@llvm/pr-subscribers-hlsl @llvm/pr-subscribers-clang Author: aniplcc (aniplcc) ChangesFixes #86506 Full diff: https://github.com/llvm/llvm-project/pull/86571.diff 1 Files Affected:
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 7bd91d4791ecf0..30638a9999ca1d 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3516,7 +3516,8 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts,
GenerateArg(Consumer, OPT_fblocks);
if (Opts.ConvergentFunctions &&
- !(Opts.OpenCL || (Opts.CUDA && Opts.CUDAIsDevice) || Opts.SYCLIsDevice))
+ !(Opts.OpenCL || (Opts.CUDA && Opts.CUDAIsDevice) || Opts.SYCLIsDevice ||
+ Opts.HLSL))
GenerateArg(Consumer, OPT_fconvergent_functions);
if (Opts.NoBuiltin && !Opts.Freestanding)
@@ -3914,7 +3915,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.ConvergentFunctions = Args.hasArg(OPT_fconvergent_functions) ||
Opts.OpenCL || (Opts.CUDA && Opts.CUDAIsDevice) ||
- Opts.SYCLIsDevice;
+ Opts.SYCLIsDevice || Opts.HLSL;
Opts.NoBuiltin = Args.hasArg(OPT_fno_builtin) || Opts.Freestanding;
if (!Opts.NoBuiltin)
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
✅ With the latest revision this PR passed the Python code formatter. |
Requesting review, @llvm-beanz |
Hi @aniplcc, thank you for the PR. We do require test cases for bug fixes and new features (see the Developer Policy. Because this general feature is already tested for OpenCL, we can make a really simple test for this. Something like this should be fine: // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.4-library -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
void fn() {
};
// CHECK: define void @"?fn@@YAXXZ"() local_unnamed_addr #[[Attr:[0-9]+]]
// CHECK: attributes #[[Attr]] = { {{[^}]*}}convergent{{[^}]*}} } Put that into a file |
I was getting match errors with the RUN script. I went ahead and updated it with the checks in: // 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() {
}; Now it just checks the presence of Also for reference, the emitted llvmir from my forked clang build ; ModuleID = 'CodeGenHLSL/convergent-funtions.hlsl'
source_filename = "CodeGenHLSL/convergent-funtions.hlsl"
target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
target triple = "dxil-pc-shadermodel6.4-library"
; Function Attrs: convergent noinline nounwind optnone
define void @"?fn@@YAXXZ"() #0 {
entry:
ret void
}
attributes #0 = { convergent noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
...*some more lines* |
With this the
I'd prefer a more specific match where we actually verify that the 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. // 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{{[^}]*}} } |
Updated |
check fails with
|
Ah it's the spir-v check, apologies, forgot to check that |
@llvm-beanz and @aniplcc, this change seems to be causing a test failure of CodeGenHLSL/builtins/wave_get_lane_index_subcall.hlsl on several bots including:
Can you take a look and revert if you need time to investigate? |
Looking at it now. |
Fixes #86506