diff options
author | Zequan Wu <zequanwu@google.com> | 2021-01-12 11:22:31 -0800 |
---|---|---|
committer | Zequan Wu <zequanwu@google.com> | 2021-01-12 12:10:46 -0800 |
commit | e53bbd99516fc7b612df1ae08d48288d0b8784ea (patch) | |
tree | 5e6fdd7e98164db1d4dacb428eb60d8fd18d2c91 /clang/lib/CodeGen/CGCall.cpp | |
parent | 6cd44b204c6c6f2e915270af6792f247c4c23abc (diff) | |
download | llvm-e53bbd99516fc7b612df1ae08d48288d0b8784ea.zip llvm-e53bbd99516fc7b612df1ae08d48288d0b8784ea.tar.gz llvm-e53bbd99516fc7b612df1ae08d48288d0b8784ea.tar.bz2 |
[IR] move nomerge attribute from function declaration/definition to callsites
Move nomerge attribute from function declaration/definition to callsites to
allow virtual function calls attach the attribute.
Differential Revision: https://reviews.llvm.org/D94537
Diffstat (limited to 'clang/lib/CodeGen/CGCall.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 2cc7203..4280137 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1985,7 +1985,9 @@ void CodeGenModule::ConstructAttributeList( FuncAttrs.addAttribute(llvm::Attribute::NoReturn); NBA = Fn->getAttr<NoBuiltinAttr>(); } - if (!AttrOnCallSite && TargetDecl->hasAttr<NoMergeAttr>()) + // Only place nomerge attribute on call sites, never functions. This + // allows it to work on indirect virtual function calls. + if (AttrOnCallSite && TargetDecl->hasAttr<NoMergeAttr>()) FuncAttrs.addAttribute(llvm::Attribute::NoMerge); } @@ -5018,13 +5020,11 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, Attrs.addAttribute(getLLVMContext(), llvm::AttributeList::FunctionIndex, llvm::Attribute::StrictFP); - // 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); + // Add call-site nomerge attribute if exists. + if (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. |