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

S. Bharadwaj Yadavalli via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 11 07:34:06 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);
----------------
bharadwajy 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.

Comment added. Thanks!

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


More information about the cfe-commits mailing list