aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index b36e078..c278176 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -6172,6 +6172,22 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD,
CodeGenFunction(*this).GenerateCode(GD, Fn, FI);
setNonAliasAttributes(GD, Fn);
+
+ bool ShouldAddOptNone = !CodeGenOpts.DisableO0ImplyOptNone &&
+ (CodeGenOpts.OptimizationLevel == 0) &&
+ !D->hasAttr<MinSizeAttr>();
+
+ if (D->hasAttr<OpenCLKernelAttr>()) {
+ if (GD.getKernelReferenceKind() == KernelReferenceKind::Stub &&
+ !D->hasAttr<NoInlineAttr>() &&
+ !Fn->hasFnAttribute(llvm::Attribute::NoInline) &&
+ !D->hasAttr<OptimizeNoneAttr>() &&
+ !Fn->hasFnAttribute(llvm::Attribute::OptimizeNone) &&
+ !ShouldAddOptNone) {
+ Fn->addFnAttr(llvm::Attribute::AlwaysInline);
+ }
+ }
+
SetLLVMFunctionAttributesForDefinition(D, Fn);
if (const ConstructorAttr *CA = D->getAttr<ConstructorAttr>())