[clang] 19550e7 - [NFC][Clang] Remove redundant function definitions
Juan Manuel MARTINEZ CAAMAÑO via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 31 05:48:05 PDT 2023
Author: Juan Manuel MARTINEZ CAAMAÑO
Date: 2023-08-31T14:47:42+02:00
New Revision: 19550e79b50f0689404309a2c6091f0b53770e08
URL: https://github.com/llvm/llvm-project/commit/19550e79b50f0689404309a2c6091f0b53770e08
DIFF: https://github.com/llvm/llvm-project/commit/19550e79b50f0689404309a2c6091f0b53770e08.diff
LOG: [NFC][Clang] Remove redundant function definitions
There were 3 definitions of the mergeDefaultFunctionDefinitionAttributes
function: A private implementation, a version exposed in CodeGen, a
version exposed in CodeGenModule.
This patch removes the private and the CodeGenModule versions and keeps
a single definition in CodeGen.
Reviewed By: jhuber6
Differential Revision: https://reviews.llvm.org/D159256
Added:
Modified:
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGCall.h
clang/lib/CodeGen/CodeGenModule.h
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 01bbbd7371aad4..af05eec0ce19fc 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2002,10 +2002,7 @@ static void getTrivialDefaultFunctionAttributes(
}
}
-/// Adds attributes to \p F according to our \p CodeGenOpts and \p LangOpts, as
-/// though we had emitted it ourselves. We remove any attributes on F that
-/// conflict with the attributes we add here.
-static void mergeDefaultFunctionDefinitionAttributes(
+void CodeGen::mergeDefaultFunctionDefinitionAttributes(
llvm::Function &F, const CodeGenOptions &CodeGenOpts,
const LangOptions &LangOpts, const TargetOptions &TargetOpts,
bool WillInternalize) {
@@ -2065,15 +2062,6 @@ static void mergeDefaultFunctionDefinitionAttributes(
F.addFnAttrs(FuncAttrs);
}
-void clang::CodeGen::mergeDefaultFunctionDefinitionAttributes(
- llvm::Function &F, const CodeGenOptions CodeGenOpts,
- const LangOptions &LangOpts, const TargetOptions &TargetOpts,
- bool WillInternalize) {
-
- ::mergeDefaultFunctionDefinitionAttributes(F, CodeGenOpts, LangOpts,
- TargetOpts, WillInternalize);
-}
-
void CodeGenModule::getTrivialDefaultFunctionAttributes(
StringRef Name, bool HasOptnone, bool AttrOnCallSite,
llvm::AttrBuilder &FuncAttrs) {
@@ -2094,15 +2082,6 @@ void CodeGenModule::getDefaultFunctionAttributes(StringRef Name,
addMergableDefaultFunctionAttributes(CodeGenOpts, FuncAttrs);
}
-/// Apply default attributes to \p F, accounting for merge semantics of
-/// attributes that should not overwrite existing attributes.
-void CodeGenModule::mergeDefaultFunctionDefinitionAttributes(
- llvm::Function &F, bool WillInternalize) {
- ::mergeDefaultFunctionDefinitionAttributes(F, getCodeGenOpts(), getLangOpts(),
- getTarget().getTargetOpts(),
- WillInternalize);
-}
-
void CodeGenModule::addDefaultFunctionDefinitionAttributes(
llvm::AttrBuilder &attrs) {
getDefaultFunctionAttributes(/*function name*/ "", /*optnone*/ false,
diff --git a/clang/lib/CodeGen/CGCall.h b/clang/lib/CodeGen/CGCall.h
index 75c4dcc400caf0..cc0b1daf338e65 100644
--- a/clang/lib/CodeGen/CGCall.h
+++ b/clang/lib/CodeGen/CGCall.h
@@ -395,10 +395,25 @@ class ReturnValueSlot {
bool isExternallyDestructed() const { return IsExternallyDestructed; }
};
-/// Helper to add attributes to \p F according to the CodeGenOptions and
-/// LangOptions without requiring a CodeGenModule to be constructed.
+/// Adds attributes to \p F according to our \p CodeGenOpts and \p LangOpts, as
+/// though we had emitted it ourselves. We remove any attributes on F that
+/// conflict with the attributes we add here.
+///
+/// This is useful for adding attrs to bitcode modules that you want to link
+/// with but don't control, such as CUDA's libdevice. When linking with such
+/// a bitcode library, you might want to set e.g. its functions'
+/// "unsafe-fp-math" attribute to match the attr of the functions you're
+/// codegen'ing. Otherwise, LLVM will interpret the bitcode module's lack of
+/// unsafe-fp-math attrs as tantamount to unsafe-fp-math=false, and then LLVM
+/// will propagate unsafe-fp-math=false up to every transitive caller of a
+/// function in the bitcode library!
+///
+/// With the exception of fast-math attrs, this will only make the attributes
+/// on the function more conservative. But it's unsafe to call this on a
+/// function which relies on particular fast-math attributes for correctness.
+/// It's up to you to ensure that this is safe.
void mergeDefaultFunctionDefinitionAttributes(llvm::Function &F,
- const CodeGenOptions CodeGenOpts,
+ const CodeGenOptions &CodeGenOpts,
const LangOptions &LangOpts,
const TargetOptions &TargetOpts,
bool WillInternalize);
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index c8fc068bde7bba..2dcaaac4989624 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1259,26 +1259,6 @@ class CodeGenModule : public CodeGenTypeCache {
llvm::AttributeList &Attrs, unsigned &CallingConv,
bool AttrOnCallSite, bool IsThunk);
- /// Adds attributes to F according to our CodeGenOptions and LangOptions, as
- /// though we had emitted it ourselves. We remove any attributes on F that
- /// conflict with the attributes we add here.
- ///
- /// This is useful for adding attrs to bitcode modules that you want to link
- /// with but don't control, such as CUDA's libdevice. When linking with such
- /// a bitcode library, you might want to set e.g. its functions'
- /// "unsafe-fp-math" attribute to match the attr of the functions you're
- /// codegen'ing. Otherwise, LLVM will interpret the bitcode module's lack of
- /// unsafe-fp-math attrs as tantamount to unsafe-fp-math=false, and then LLVM
- /// will propagate unsafe-fp-math=false up to every transitive caller of a
- /// function in the bitcode library!
- ///
- /// With the exception of fast-math attrs, this will only make the attributes
- /// on the function more conservative. But it's unsafe to call this on a
- /// function which relies on particular fast-math attributes for correctness.
- /// It's up to you to ensure that this is safe.
- void mergeDefaultFunctionDefinitionAttributes(llvm::Function &F,
- bool WillInternalize);
-
/// Like the overload taking a `Function &`, but intended specifically
/// for frontends that want to build on Clang's target-configuration logic.
void addDefaultFunctionDefinitionAttributes(llvm::AttrBuilder &attrs);
More information about the cfe-commits
mailing list