[clang] [HLSL] set alwaysinline on HLSL functions (PR #106588)

Damyan Pepper via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 5 14:15:57 PDT 2024


================
@@ -1239,9 +1239,9 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
   if (getLangOpts().OpenMP && CurCodeDecl)
     CGM.getOpenMPRuntime().emitFunctionProlog(*this, CurCodeDecl);
 
-  if (FD && getLangOpts().HLSL) {
+  if (getLangOpts().HLSL) {
     // Handle emitting HLSL entry functions.
-    if (FD->hasAttr<HLSLShaderAttr>()) {
+    if (FD && FD->hasAttr<HLSLShaderAttr>()) {
       CGM.getHLSLRuntime().emitEntryFunction(FD, Fn);
     }
     CGM.getHLSLRuntime().setHLSLFunctionAttributes(FD, Fn);
----------------
damyanp wrote:

Maybe not for this change, but a bit of me is wondering if the two CGHLSLRuntime functions emitEntryFunction and setHLSLFunctionAttributes should be somewhat combined so that we end up with something like:

```c++
if (getLangOpts().HLSL)
    CGM.getHLSLRuntime().emitFunctionProlog(FD, Fn);
```

Similar to how this is encapsulated for OpenMP above.  That way we get more of the HLSL-specific stuff in CGHLSLRuntime.cpp.

https://github.com/llvm/llvm-project/pull/106588


More information about the cfe-commits mailing list