[PATCH] D124753: [HLSL] Set main as default entry.

Xiang Li via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 2 00:25:59 PDT 2022


python3kgae created this revision.
python3kgae added reviewers: beanz, steven_wu, JonChesterfield, sscalpone, pow2clk, rnk, bogner, MaskRay, dexonsmith.
Herald added subscribers: Anastasia, StephenFan.
Herald added a project: All.
python3kgae requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When there's no -E option, use main as entry function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124753

Files:
  clang/lib/Driver/ToolChains/HLSL.cpp
  clang/test/CodeGenHLSL/entry_default.hlsl


Index: clang/test/CodeGenHLSL/entry_default.hlsl
===================================================================
--- /dev/null
+++ clang/test/CodeGenHLSL/entry_default.hlsl
@@ -0,0 +1,10 @@
+// RUN: %clang --driver-mode=dxc -Tcs_6_1  -Fo - %s | FileCheck %s
+
+// Make sure main is default entry.
+// Make sure not mangle entry.
+// CHECK:define void @main()
+// Make sure add function attribute.
+// CHECK:"dx.shader"="compute"
+[numthreads(1, 1, 1)] void main() {
+
+}
Index: clang/lib/Driver/ToolChains/HLSL.cpp
===================================================================
--- clang/lib/Driver/ToolChains/HLSL.cpp
+++ clang/lib/Driver/ToolChains/HLSL.cpp
@@ -179,5 +179,11 @@
                         Opts.getOption(options::OPT_dxil_validator_version),
                         DefaultValidatorVer);
   }
+  // If not set entry, default is main.
+  if (!DAL->hasArg(options::OPT_hlsl_entrypoint)) {
+    const StringRef DefaultEntry = "main";
+    DAL->AddSeparateArg(nullptr, Opts.getOption(options::OPT_hlsl_entrypoint),
+                        DefaultEntry);
+  }
   return DAL;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124753.426342.patch
Type: text/x-patch
Size: 1101 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220502/da9e7f8a/attachment.bin>


More information about the cfe-commits mailing list