summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2020-04-15 11:05:22 -0700
committerGeorge Burgess IV <george.burgess.iv@gmail.com>2020-04-15 11:05:22 -0700
commit2dd17ff08165e6118e70f00e22b2c36d2d4e0a9a (patch)
treefd92b5152b981d7283bed722544f1787e8ec1c5f /clang/lib/CodeGen/CodeGenModule.cpp
parentf42baaab4f86d5259717bd26f713c002fd225669 (diff)
[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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp3
1 files changed, 2 insertions, 1 deletions
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<SectionAttr>())
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);
}