[clang] [HLSL] Appropriately set function attribute optnone (PR #125937)

Justin Bogner via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 10 13:38:16 PST 2025


================
@@ -345,6 +345,9 @@ void clang::CodeGen::CGHLSLRuntime::setHLSLEntryAttributes(
                 WaveSizeAttr->getPreferred());
     Fn->addFnAttr(WaveSizeKindStr, WaveSizeStr);
   }
+  if (CGM.getCodeGenOpts().OptimizationLevel == 0) {
+    Fn->addFnAttr(llvm::Attribute::OptimizeNone);
+  }
   Fn->addFnAttr(llvm::Attribute::NoInline);
----------------
bogner wrote:

Ok. I think a comment to the effect of "We need to manually set attributes here instead of relying on `SetLLVMFunctionAttributesForDefinition` to pick them up since these functions are injected by the compiler and won't go through the normal flow" (please reword as necessary to be accurate...) would be a good idea here.

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


More information about the cfe-commits mailing list