From 2dd17ff08165e6118e70f00e22b2c36d2d4e0a9a Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Wed, 15 Apr 2020 11:05:22 -0700 Subject: [CodeGen] only add nobuiltin to inline builtins if we'll emit them There are some inline builtin definitions that we can't emit (isTriviallyRecursive & callers go into why). Marking these nobuiltin is only useful if we actually emit the body, so don't mark these as such unless we _do_ plan on emitting that. This suboptimality was encountered in Linux (see some discussion on D71082, and https://github.com/ClangBuiltLinux/linux/issues/979). Differential Revision: https://reviews.llvm.org/D78162 --- clang/lib/CodeGen/CodeGenModule.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 39aa5c1c512f..73a3212bcd47 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1908,7 +1908,8 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, llvm::Function *F, else if (const auto *SA = FD->getAttr()) F->setSection(SA->getName()); - if (FD->isInlineBuiltinDeclaration()) { + // If we plan on emitting this inline builtin, we can't treat it as a builtin. + if (FD->isInlineBuiltinDeclaration() && shouldEmitFunction(FD)) { F->addAttribute(llvm::AttributeList::FunctionIndex, llvm::Attribute::NoBuiltin); } -- cgit v1.2.3