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

via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 27 07:54:12 PDT 2024


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

>From c22f63359b7391e9f69d74e5d4f4bdf6cf585c2c Mon Sep 17 00:00:00 2001
From: aniplcc <aniplccode at gmail.com>
Date: Tue, 26 Mar 2024 01:35:36 +0530
Subject: [PATCH 1/2] [HLSL] Enable -fconvergent-functions by default

---
 clang/lib/Frontend/CompilerInvocation.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

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)

>From e4fdf29d71803afa87939726292feb9e90f97e04 Mon Sep 17 00:00:00 2001
From: aniplcc <aniplccode at gmail.com>
Date: Wed, 27 Mar 2024 20:23:45 +0530
Subject: [PATCH 2/2] add CodeGenHLSL/convergent-functions.hlsl for testing new
 defaults

---
 clang/test/CodeGenHLSL/convergent-functions.hlsl | 8 ++++++++
 1 file changed, 8 insertions(+)
 create mode 100644 clang/test/CodeGenHLSL/convergent-functions.hlsl

diff --git a/clang/test/CodeGenHLSL/convergent-functions.hlsl b/clang/test/CodeGenHLSL/convergent-functions.hlsl
new file mode 100644
index 00000000000000..23746ec8703bbe
--- /dev/null
+++ b/clang/test/CodeGenHLSL/convergent-functions.hlsl
@@ -0,0 +1,8 @@
+// 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() {
+};



More information about the cfe-commits mailing list