================
@@ -6174,6 +6174,19 @@ void 
CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD,
   CodeGenFunction(*this).GenerateCode(GD, Fn, FI);
 
   setNonAliasAttributes(GD, Fn);
+
+  bool ShouldAddOptNone = !CodeGenOpts.DisableO0ImplyOptNone &&
+                          (CodeGenOpts.OptimizationLevel == 0) &&
+                          !D->hasAttr<MinSizeAttr>();
----------------
lalaniket8 wrote:

I am following the logic for `ShouldAddOptNone` used later in 
`SetLLVMFunctionAttributesForDefinition(D, Fn);`  here 
https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CodeGenModule.cpp#L2552
 to decide if optnone and noinline attribute should be added. 

If we don't do the same check we end up adding alwaysinline to the stub in 
cases where `ShouldAddOptNone` would be true. This prevents adding of optnone 
and noinline later in 
https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CodeGenModule.cpp#L2552

https://github.com/llvm/llvm-project/pull/137769
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to