diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6810,5 +6810,5 @@ def hlsl_entrypoint : Option<["--", "/", "-"], "E", KIND_JOINED_OR_SEPARATE>, Group, Flags<[DXCOption, CC1Option, NoXarchOption]>, - MarshallingInfoString>, + MarshallingInfoString, "\"main\"">, HelpText<"Entry point name">; diff --git a/clang/test/CodeGenHLSL/entry_default.hlsl b/clang/test/CodeGenHLSL/entry_default.hlsl new file mode 100644 --- /dev/null +++ b/clang/test/CodeGenHLSL/entry_default.hlsl @@ -0,0 +1,29 @@ +// RUN: %clang --driver-mode=dxc -Tcs_6_1 -fcgl -Fo - %s | FileCheck %s +// RUN: %clang --driver-mode=dxc -Efoo -Tcs_6_1 -fcgl -Fo - %s | FileCheck %s --check-prefix=NOTMAIN + +// Make sure main is default entry. +// Make sure not mangle entry. +// CHECK: define void @main() [[MAIN_ATTR:#[0-9]]] +// CHECK: define void @_Z3foov() [[FOO_ATTR:#[0-9]]] +// Make sure only main has dx.shader attribute. +// CHECK: [[MAIN_ATTR]] +// CHECK-SAME: "dx.shader"="compute" +// CHECK-SAME: } +// CHECK: [[FOO_ATTR]] +// CHECK-NOT: "dx.shader"="compute" +// CHECK-SAME: } +[numthreads(1, 1, 1)] void main() { + +} + +// NOTMAIN: define void @main() [[MAIN_ATTR:#[0-9]]] +// NOTMAIN: define void @foo() [[FOO_ATTR:#[0-9]]] +// Make sure only foo has dx.shader attribute. +// NOTMAIN: [[MAIN_ATTR]] +// NOTMAIN-NOT:"dx.shader"="compute" +// NOTMAIN-SAME:} +// NOTMAIN: [[FOO_ATTR]] +// NOTMAIN-SAME: "dx.shader"="compute" +[numthreads(1, 1, 1)] void foo() { + +}