================
@@ -414,9 +414,20 @@ void CGHLSLRuntime::emitEntryFunction(const FunctionDecl 
*FD,
 
 void CGHLSLRuntime::setHLSLFunctionAttributes(const FunctionDecl *FD,
                                               llvm::Function *Fn) {
-  if (FD->isInExportDeclContext()) {
-    const StringRef ExportAttrKindStr = "hlsl.export";
-    Fn->addFnAttr(ExportAttrKindStr);
+  if (FD) { // "explicit" functions with declarations
+    if (FD->isInExportDeclContext()) {
+      const StringRef ExportAttrKindStr = "hlsl.export";
+      Fn->addFnAttr(ExportAttrKindStr);
+    }
+    // Respect noinline if the explicit functions use it
+    // otherwise default to alwaysinline
+    if (!Fn->hasFnAttribute(Attribute::NoInline))
+      Fn->addFnAttr(llvm::Attribute::AlwaysInline);
+  } else { // "implicit" autogenerated functions with no declaration
+    // Implicit functions might get marked as noinline by default
+    // but we override that for HLSL
+    Fn->removeFnAttr(Attribute::NoInline);
----------------
pow3clk wrote:

I was trying not to litter too many `if(getLangOpts().HLSL)` conditionals 
throughout the code. Something similar to this is done in [ 
a](https://github.com/llvm/llvm-project/blob/3ebd79751f2d5e1c54047409865c051daba0a21b/clang/lib/CodeGen/CGOpenMPRuntime.cpp#L3222-L3224)
 [few]( 
https://github.com/llvm/llvm-project/blob/3ebd79751f2d5e1c54047409865c051daba0a21b/clang/lib/CodeGen/CGOpenMPRuntime.cpp#L1100-L1102)
 
[places](https://github.com/llvm/llvm-project/blob/3ebd79751f2d5e1c54047409865c051daba0a21b/clang/lib/CodeGen/CGStmtOpenMP.cpp#L582-L583)
 for OpenMP. I don't feel strongly about it though. It's trivial to drop an _if 
HLSL_ conditional there.

https://github.com/llvm/llvm-project/pull/106588
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to