https://github.com/llvm-beanz updated https://github.com/llvm/llvm-project/pull/110546
>From c966c604e8e40ddae4e738d6048bb7f87cfeeb25 Mon Sep 17 00:00:00 2001 From: Chris Bieneman <chris.biene...@me.com> Date: Mon, 30 Sep 2024 13:05:09 -0500 Subject: [PATCH 1/2] [HLSL] Treat `main` as any other function HLSL doesn't distinguish `main` from any other function. It does treat entry points special, but they're not required to be called `main` so we have a different attribute annotation to mark them. At the moment this change really just changes the mangling of functions named `main` in the Itanium mangling. Fixes #110517 --- clang/lib/AST/Decl.cpp | 1 + .../test/CodeGenHLSL/builtins/wave_get_lane_index_do_while.hlsl | 2 +- clang/test/Options/enable_16bit_types_validation_spirv.hlsl | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index a14b1b33d35efc..84ef9f74582ef6 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -3302,6 +3302,7 @@ bool FunctionDecl::isImmediateFunction() const { bool FunctionDecl::isMain() const { return isNamed(this, "main") && !getLangOpts().Freestanding && + !getLangOpts().HLSL && (getDeclContext()->getRedeclContext()->isTranslationUnit() || isExternC()); } diff --git a/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_do_while.hlsl b/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_do_while.hlsl index 9481b0d60a2723..c223b9117e9277 100644 --- a/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_do_while.hlsl +++ b/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_do_while.hlsl @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ // RUN: spirv-pc-vulkan-library %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s -// CHECK: define spir_func void @main() [[A0:#[0-9]+]] { +// CHECK: define spir_func void @{{.*}}main{{.*}}() [[A0:#[0-9]+]] { void main() { // CHECK: entry: // CHECK: %[[CT_ENTRY:[0-9]+]] = call token @llvm.experimental.convergence.entry() diff --git a/clang/test/Options/enable_16bit_types_validation_spirv.hlsl b/clang/test/Options/enable_16bit_types_validation_spirv.hlsl index aeb7a8369f4034..3e6734011c39ad 100644 --- a/clang/test/Options/enable_16bit_types_validation_spirv.hlsl +++ b/clang/test/Options/enable_16bit_types_validation_spirv.hlsl @@ -4,7 +4,7 @@ // SPIRV: error: '-fnative-half-type' option requires target HLSL Version >= 2018, but HLSL Version is 'hlsl2016' // valid: "spirv-unknown-vulkan-library" -// valid: define spir_func void @main() #0 { +// valid: define spir_func void @{{.*}}main{{.*}}() #0 { [numthreads(1,1,1)] void main() >From d4c809d433798abee4f267e00de38df9dd9147bd Mon Sep 17 00:00:00 2001 From: Chris B <cbiene...@microsoft.com> Date: Mon, 30 Sep 2024 16:09:04 -0500 Subject: [PATCH 2/2] Update clang/test/Options/enable_16bit_types_validation_spirv.hlsl Co-authored-by: Farzon Lotfi <1802579+farz...@users.noreply.github.com> --- clang/test/Options/enable_16bit_types_validation_spirv.hlsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/Options/enable_16bit_types_validation_spirv.hlsl b/clang/test/Options/enable_16bit_types_validation_spirv.hlsl index 3e6734011c39ad..aad8836db1062b 100644 --- a/clang/test/Options/enable_16bit_types_validation_spirv.hlsl +++ b/clang/test/Options/enable_16bit_types_validation_spirv.hlsl @@ -4,7 +4,7 @@ // SPIRV: error: '-fnative-half-type' option requires target HLSL Version >= 2018, but HLSL Version is 'hlsl2016' // valid: "spirv-unknown-vulkan-library" -// valid: define spir_func void @{{.*}}main{{.*}}() #0 { +// valid: define spir_func void @{{.*main.*}}() #0 { [numthreads(1,1,1)] void main() _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits