From 3ab301b4d9700d7ce3ebc22750166c49b45e3e98 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 (cherry picked from commit 2dd17ff08165e6118e70f00e22b2c36d2d4e0a9a) --- clang/lib/CodeGen/CodeGenModule.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'clang/lib') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index f8866ac4f7f..73c41dc4cf3 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1847,7 +1847,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