Skip to content

Commit 24b0807

Browse files
llvm-beanzfarzonl
authored andcommitted
[HLSL] Treat main as any other function (llvm#110546)
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 llvm#110517 --------- Co-authored-by: Farzon Lotfi <[email protected]>
1 parent 87f81bb commit 24b0807

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

clang/lib/AST/Decl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3302,6 +3302,7 @@ bool FunctionDecl::isImmediateFunction() const {
33023302

33033303
bool FunctionDecl::isMain() const {
33043304
return isNamed(this, "main") && !getLangOpts().Freestanding &&
3305+
!getLangOpts().HLSL &&
33053306
(getDeclContext()->getRedeclContext()->isTranslationUnit() ||
33063307
isExternC());
33073308
}

clang/test/CodeGenHLSL/builtins/wave_get_lane_index_do_while.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
22
// RUN: spirv-pc-vulkan-library %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
33

4-
// CHECK: define spir_func void @main() [[A0:#[0-9]+]] {
4+
// CHECK: define spir_func void @{{.*main.*}}() [[A0:#[0-9]+]] {
55
void main() {
66
// CHECK: entry:
77
// CHECK: %[[CT_ENTRY:[0-9]+]] = call token @llvm.experimental.convergence.entry()

clang/test/Options/enable_16bit_types_validation_spirv.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// SPIRV: error: '-fnative-half-type' option requires target HLSL Version >= 2018, but HLSL Version is 'hlsl2016'
55

66
// valid: "spirv-unknown-vulkan-library"
7-
// valid: define spir_func void @main() #0 {
7+
// valid: define spir_func void @{{.*main.*}}() #0 {
88

99
[numthreads(1,1,1)]
1010
void main()

0 commit comments

Comments
 (0)