Index: clang/lib/CodeGen/CGCall.cpp =================================================================== --- clang/lib/CodeGen/CGCall.cpp +++ clang/lib/CodeGen/CGCall.cpp @@ -2043,6 +2043,9 @@ if (TargetDecl->hasAttr()) FuncAttrs.addAttribute(llvm::Attribute::Convergent); + if (!AttrOnCallSite && TargetDecl->hasAttr()) + FuncAttrs.addAttribute(llvm::Attribute::NoInline); + if (const FunctionDecl *Fn = dyn_cast(TargetDecl)) { AddAttributesFromFunctionProtoType( getContext(), FuncAttrs, Fn->getType()->getAs()); Index: clang/lib/CodeGen/CGClass.cpp =================================================================== --- clang/lib/CodeGen/CGClass.cpp +++ clang/lib/CodeGen/CGClass.cpp @@ -1535,8 +1535,11 @@ } // -fapple-kext must inline any call to this dtor into // the caller's body. - if (getLangOpts().AppleKext) + if (getLangOpts().AppleKext) { + if (CurFn->hasFnAttribute(llvm::Attribute::NoInline)) + CurFn->removeFnAttr(llvm::Attribute::NoInline); CurFn->addFnAttr(llvm::Attribute::AlwaysInline); + } break; } Index: clang/test/CodeGen/noinline-attr-on-target.c =================================================================== --- /dev/null +++ clang/test/CodeGen/noinline-attr-on-target.c @@ -0,0 +1,13 @@ +// Make sure the `noinline` attribute has been attached to the `bar()`. + +// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s + +// CHECK: define dso_local void @foo() #[[#ATTR0:]] { +// CHECK: declare void @bar() #[[#ATTR1:]] +// CHECK: attributes #[[#ATTR0]] = { noinline +// CHECK: attributes #[[#ATTR1]] = { noinline + +extern void __attribute__((noinline)) bar(void); +void foo() { + bar(); +}