aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGCall.cpp
diff options
context:
space:
mode:
authorZequan Wu <zequanwu@google.com>2020-12-07 16:37:14 -0800
committerZequan Wu <zequanwu@google.com>2020-12-17 07:45:38 -0800
commitfb0f7288051eb2745bb9211306f53ff9aa6f73e2 (patch)
treeceb257f84ac3121524f07cc49434d0f614393b24 /clang/lib/CodeGen/CGCall.cpp
parentbd343d26814640b4934fdde8637ad5577d30c83c (diff)
downloadllvm-fb0f7288051eb2745bb9211306f53ff9aa6f73e2.zip
llvm-fb0f7288051eb2745bb9211306f53ff9aa6f73e2.tar.gz
llvm-fb0f7288051eb2745bb9211306f53ff9aa6f73e2.tar.bz2
[Clang] Make nomerge attribute a function attribute as well as a statement attribute.
Differential Revision: https://reviews.llvm.org/D92800
Diffstat (limited to 'clang/lib/CodeGen/CGCall.cpp')
-rw-r--r--clang/lib/CodeGen/CGCall.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 28a7d12..bfc7b8e 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1968,6 +1968,8 @@ void CodeGenModule::ConstructAttributeList(
FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
NBA = Fn->getAttr<NoBuiltinAttr>();
}
+ if (!AttrOnCallSite && TargetDecl->hasAttr<NoMergeAttr>())
+ FuncAttrs.addAttribute(llvm::Attribute::NoMerge);
}
// 'const', 'pure' and 'noalias' attributed functions are also nounwind.
@@ -4978,11 +4980,13 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
Attrs.addAttribute(getLLVMContext(), llvm::AttributeList::FunctionIndex,
llvm::Attribute::StrictFP);
- // Add call-site nomerge attribute if exists.
- if (InNoMergeAttributedStmt)
- Attrs =
- Attrs.addAttribute(getLLVMContext(), llvm::AttributeList::FunctionIndex,
- llvm::Attribute::NoMerge);
+ // Add nomerge attribute to the call-site if the callee function doesn't have
+ // the attribute.
+ if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl))
+ if (!FD->hasAttr<NoMergeAttr>() && InNoMergeAttributedStmt)
+ Attrs = Attrs.addAttribute(getLLVMContext(),
+ llvm::AttributeList::FunctionIndex,
+ llvm::Attribute::NoMerge);
// Apply some call-site-specific attributes.
// TODO: work this into building the attribute set.