summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2020-04-16 10:56:19 -0700
committerTom Stellard <tstellar@redhat.com>2020-05-07 13:47:01 -0700
commiteaae6dfc545000e335e6f89abb9c78818383d7ad (patch)
tree93528939f1ecbfc8d2cce5410f2db128e73e4082 /clang/lib/CodeGen
parent3ab301b4d9700d7ce3ebc22750166c49b45e3e98 (diff)
downloadbcm5719-llvm-eaae6dfc545000e335e6f89abb9c78818383d7ad.tar.gz
bcm5719-llvm-eaae6dfc545000e335e6f89abb9c78818383d7ad.zip
[CodeGen] fix inline builtin-related breakage from D78162
In cases where we have multiple decls of an inline builtin, we may need to go hunting for the one with a definition when setting function attributes. An additional test-case was provided on https://github.com/ClangBuiltLinux/linux/issues/979 (cherry picked from commit 94908088a831141cfbdd15fc5837dccf30cfeeb6)
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 73c41dc4cf3..a735bdd814e 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1848,9 +1848,15 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, llvm::Function *F,
F->setSection(SA->getName());
// 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);
+ if (FD->isInlineBuiltinDeclaration()) {
+ const FunctionDecl *FDBody;
+ bool HasBody = FD->hasBody(FDBody);
+ (void)HasBody;
+ assert(HasBody && "Inline builtin declarations should always have an "
+ "available body!");
+ if (shouldEmitFunction(FDBody))
+ F->addAttribute(llvm::AttributeList::FunctionIndex,
+ llvm::Attribute::NoBuiltin);
}
if (FD->isReplaceableGlobalAllocationFunction()) {
OpenPOWER on IntegriCloud