================ @@ -446,6 +449,13 @@ void CGHLSLRuntime::setHLSLFunctionAttributes(const FunctionDecl *FD, const StringRef ExportAttrKindStr = "hlsl.export"; Fn->addFnAttr(ExportAttrKindStr); } + llvm::Triple T(Fn->getParent()->getTargetTriple()); + if (T.getEnvironment() == llvm::Triple::EnvironmentType::Library) { + if (CGM.getCodeGenOpts().OptimizationLevel == 0) { + Fn->addFnAttr(llvm::Attribute::OptimizeNone); + Fn->addFnAttr(llvm::Attribute::NoInline); + } + } ---------------- bharadwajy wrote:
> Do we want to do this on all functions in a library or just entry points and > exported functions? In any case, it really would be preferable if > "SetLLVMFunctionAttributesForDefinition" did the right thing (whatever that > may be) rather than us needing to duplicate that logic here... OK. It would be sufficient to set the `optnone` attribute just for entry functions of both non-library shaders and library shaders since all shaders will have one or more (respectively) entry functions. The shader flag `DisableOptimizations` can be set based on the presence of this attribute on entry function(s). Deleted this change. The consequences and utility in the later passes of setting `optnone` attribute for exported library functions when optimizatons are disabled is not very clear to me, yet. I'd like to propose an change, if needed, be done in a follow on PR. https://github.com/llvm/llvm-project/pull/125937 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits