================
@@ -2474,7 +2474,9 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
     // If we don't have a declaration to control inlining, the function isn't
     // explicitly marked as alwaysinline for semantic reasons, and inlining is
     // disabled, mark the function as noinline.
+    // HLSL functions must be always inlined
     if (!F->hasFnAttribute(llvm::Attribute::AlwaysInline) &&
+        !getLangOpts().HLSL &&
----------------
pow2clk wrote:
I investigated this in some depth. The situation is that the autogenerated 
initialization and destruction functions get their attributes set through this 
call and others before their bodies are generated, which calls 
`setHLSLFunctionAttributes` while user functions generate their bodies and make 
the hlsl attributes call before this one. This seems error-prone to me, but the 
code has been around long enough that I'm not ready to go changing it even 
though some initial experiments showed no regressions. 

In the meantime, since so much inline attribute logic is in this function, I've 
concluded that the best solution is to add our inline logic here and not in 
`setHLSLFunctionAttributes` at all. That way it doesn't matter as much where in 
the IR function creation process it takes place and any consequences can be 
accounted for along with the existing logic. That's what my latest commit does. 

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