Skip to content

Commit c202e5c

Browse files
hahnjotru
authored andcommitted
[CodeGen] Remove Constant arguments from linkage functions, NFCI.
This was unused since commit dd2362a last year. Differential Revision: https://reviews.llvm.org/D156891 (cherry picked from commit 2f3fe3e)
1 parent 731c93f commit c202e5c

File tree

9 files changed

+23
-28
lines changed

9 files changed

+23
-28
lines changed

clang/lib/CodeGen/CGCXXABI.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,7 @@ void CGCXXABI::setCXXDestructorDLLStorage(llvm::GlobalValue *GV,
312312
llvm::GlobalValue::LinkageTypes CGCXXABI::getCXXDestructorLinkage(
313313
GVALinkage Linkage, const CXXDestructorDecl *Dtor, CXXDtorType DT) const {
314314
// Delegate back to CGM by default.
315-
return CGM.getLLVMLinkageForDeclarator(Dtor, Linkage,
316-
/*IsConstantVariable=*/false);
315+
return CGM.getLLVMLinkageForDeclarator(Dtor, Linkage);
317316
}
318317

319318
bool CGCXXABI::NeedsVTTParameter(GlobalDecl GD) {

clang/lib/CodeGen/CGDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ void CodeGenFunction::EmitVarDecl(const VarDecl &D) {
202202
return;
203203

204204
llvm::GlobalValue::LinkageTypes Linkage =
205-
CGM.getLLVMLinkageVarDefinition(&D, /*IsConstant=*/false);
205+
CGM.getLLVMLinkageVarDefinition(&D);
206206

207207
// FIXME: We need to force the emission/use of a guard variable for
208208
// some variables even if we can constant-evaluate them because

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,8 +2692,7 @@ static LValue EmitGlobalNamedRegister(const VarDecl *VD, CodeGenModule &CGM) {
26922692
/// this context.
26932693
static bool canEmitSpuriousReferenceToVariable(CodeGenFunction &CGF,
26942694
const DeclRefExpr *E,
2695-
const VarDecl *VD,
2696-
bool IsConstant) {
2695+
const VarDecl *VD) {
26972696
// For a variable declared in an enclosing scope, do not emit a spurious
26982697
// reference even if we have a capture, as that will emit an unwarranted
26992698
// reference to our capture state, and will likely generate worse code than
@@ -2726,7 +2725,7 @@ static bool canEmitSpuriousReferenceToVariable(CodeGenFunction &CGF,
27262725
// We can emit a spurious reference only if the linkage implies that we'll
27272726
// be emitting a non-interposable symbol that will be retained until link
27282727
// time.
2729-
switch (CGF.CGM.getLLVMLinkageVarDefinition(VD, IsConstant)) {
2728+
switch (CGF.CGM.getLLVMLinkageVarDefinition(VD)) {
27302729
case llvm::GlobalValue::ExternalLinkage:
27312730
case llvm::GlobalValue::LinkOnceODRLinkage:
27322731
case llvm::GlobalValue::WeakODRLinkage:
@@ -2757,7 +2756,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
27572756
// constant value directly instead.
27582757
if (E->isNonOdrUse() == NOUR_Constant &&
27592758
(VD->getType()->isReferenceType() ||
2760-
!canEmitSpuriousReferenceToVariable(*this, E, VD, true))) {
2759+
!canEmitSpuriousReferenceToVariable(*this, E, VD))) {
27612760
VD->getAnyInitializer(VD);
27622761
llvm::Constant *Val = ConstantEmitter(*this).emitAbstract(
27632762
E->getLocation(), *VD->evaluateValue(), VD->getType());
@@ -2859,7 +2858,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
28592858
// some reason; most likely, because it's in an outer function.
28602859
} else if (VD->isStaticLocal()) {
28612860
llvm::Constant *var = CGM.getOrCreateStaticVarDecl(
2862-
*VD, CGM.getLLVMLinkageVarDefinition(VD, /*IsConstant=*/false));
2861+
*VD, CGM.getLLVMLinkageVarDefinition(VD));
28632862
addr = Address(
28642863
var, ConvertTypeForMem(VD->getType()), getContext().getDeclAlign(VD));
28652864

clang/lib/CodeGen/CGExprConstant.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1918,7 +1918,7 @@ ConstantLValueEmitter::tryEmitBase(const APValue::LValueBase &base) {
19181918

19191919
if (VD->isLocalVarDecl()) {
19201920
return CGM.getOrCreateStaticVarDecl(
1921-
*VD, CGM.getLLVMLinkageVarDefinition(VD, /*IsConstant=*/false));
1921+
*VD, CGM.getLLVMLinkageVarDefinition(VD));
19221922
}
19231923
}
19241924
}

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,7 +1667,7 @@ Address CGOpenMPRuntime::getAddrOfDeclareTargetVar(const VarDecl *VD) {
16671667
auto AddrOfGlobal = [&VD, this]() { return CGM.GetAddrOfGlobal(VD); };
16681668

16691669
auto LinkageForVariable = [&VD, this]() {
1670-
return CGM.getLLVMLinkageVarDefinition(VD, /*IsConstant=*/false);
1670+
return CGM.getLLVMLinkageVarDefinition(VD);
16711671
};
16721672

16731673
std::vector<llvm::GlobalVariable *> GeneratedRefs;
@@ -10170,7 +10170,7 @@ void CGOpenMPRuntime::registerTargetGlobalVariable(const VarDecl *VD,
1017010170

1017110171
auto AddrOfGlobal = [&VD, this]() { return CGM.GetAddrOfGlobal(VD); };
1017210172
auto LinkageForVariable = [&VD, this]() {
10173-
return CGM.getLLVMLinkageVarDefinition(VD, /*IsConstant=*/false);
10173+
return CGM.getLLVMLinkageVarDefinition(VD);
1017410174
};
1017510175

1017610176
std::vector<llvm::GlobalVariable *> GeneratedRefs;

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,7 +1974,7 @@ CodeGenModule::getFunctionLinkage(GlobalDecl GD) {
19741974
return llvm::GlobalValue::InternalLinkage;
19751975
}
19761976

1977-
return getLLVMLinkageForDeclarator(D, Linkage, /*IsConstantVariable=*/false);
1977+
return getLLVMLinkageForDeclarator(D, Linkage);
19781978
}
19791979

19801980
llvm::ConstantInt *CodeGenModule::CreateCrossDsoCfiTypeId(llvm::Metadata *MD) {
@@ -5228,8 +5228,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
52285228
AddGlobalAnnotations(D, GV);
52295229

52305230
// Set the llvm linkage type as appropriate.
5231-
llvm::GlobalValue::LinkageTypes Linkage =
5232-
getLLVMLinkageVarDefinition(D, GV->isConstant());
5231+
llvm::GlobalValue::LinkageTypes Linkage = getLLVMLinkageVarDefinition(D);
52335232

52345233
// CUDA B.2.1 "The __device__ qualifier declares a variable that resides on
52355234
// the device. [...]"
@@ -5422,8 +5421,9 @@ static bool isVarDeclStrongDefinition(const ASTContext &Context,
54225421
return false;
54235422
}
54245423

5425-
llvm::GlobalValue::LinkageTypes CodeGenModule::getLLVMLinkageForDeclarator(
5426-
const DeclaratorDecl *D, GVALinkage Linkage, bool IsConstantVariable) {
5424+
llvm::GlobalValue::LinkageTypes
5425+
CodeGenModule::getLLVMLinkageForDeclarator(const DeclaratorDecl *D,
5426+
GVALinkage Linkage) {
54275427
if (Linkage == GVA_Internal)
54285428
return llvm::Function::InternalLinkage;
54295429

@@ -5493,10 +5493,10 @@ llvm::GlobalValue::LinkageTypes CodeGenModule::getLLVMLinkageForDeclarator(
54935493
return llvm::GlobalVariable::ExternalLinkage;
54945494
}
54955495

5496-
llvm::GlobalValue::LinkageTypes CodeGenModule::getLLVMLinkageVarDefinition(
5497-
const VarDecl *VD, bool IsConstant) {
5496+
llvm::GlobalValue::LinkageTypes
5497+
CodeGenModule::getLLVMLinkageVarDefinition(const VarDecl *VD) {
54985498
GVALinkage Linkage = getContext().GetGVALinkageForVariable(VD);
5499-
return getLLVMLinkageForDeclarator(VD, Linkage, IsConstant);
5499+
return getLLVMLinkageForDeclarator(VD, Linkage);
55005500
}
55015501

55025502
/// Replace the uses of a function that was declared with a non-proto type.
@@ -5708,7 +5708,7 @@ void CodeGenModule::EmitAliasDefinition(GlobalDecl GD) {
57085708
Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(), DeclTy, LangAS::Default,
57095709
/*D=*/nullptr);
57105710
if (const auto *VD = dyn_cast<VarDecl>(GD.getDecl()))
5711-
LT = getLLVMLinkageVarDefinition(VD, D->getType().isConstQualified());
5711+
LT = getLLVMLinkageVarDefinition(VD);
57125712
else
57135713
LT = getFunctionLinkage(GD);
57145714
}
@@ -6339,8 +6339,7 @@ ConstantAddress CodeGenModule::GetAddrOfGlobalTemporary(
63396339
}
63406340

63416341
// Create a global variable for this lifetime-extended temporary.
6342-
llvm::GlobalValue::LinkageTypes Linkage =
6343-
getLLVMLinkageVarDefinition(VD, Constant);
6342+
llvm::GlobalValue::LinkageTypes Linkage = getLLVMLinkageVarDefinition(VD);
63446343
if (Linkage == llvm::GlobalVariable::ExternalLinkage) {
63456344
const VarDecl *InitVD;
63466345
if (VD->isStaticDataMember() && VD->getAnyInitializer(InitVD) &&

clang/lib/CodeGen/CodeGenModule.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,12 +1321,11 @@ class CodeGenModule : public CodeGenTypeCache {
13211321

13221322
/// Returns LLVM linkage for a declarator.
13231323
llvm::GlobalValue::LinkageTypes
1324-
getLLVMLinkageForDeclarator(const DeclaratorDecl *D, GVALinkage Linkage,
1325-
bool IsConstantVariable);
1324+
getLLVMLinkageForDeclarator(const DeclaratorDecl *D, GVALinkage Linkage);
13261325

13271326
/// Returns LLVM linkage for a declarator.
13281327
llvm::GlobalValue::LinkageTypes
1329-
getLLVMLinkageVarDefinition(const VarDecl *VD, bool IsConstant);
1328+
getLLVMLinkageVarDefinition(const VarDecl *VD);
13301329

13311330
/// Emit all the global annotations.
13321331
void EmitGlobalAnnotations();

clang/lib/CodeGen/ItaniumCXXABI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2839,7 +2839,7 @@ static bool isThreadWrapperReplaceable(const VarDecl *VD,
28392839
static llvm::GlobalValue::LinkageTypes
28402840
getThreadLocalWrapperLinkage(const VarDecl *VD, CodeGen::CodeGenModule &CGM) {
28412841
llvm::GlobalValue::LinkageTypes VarLinkage =
2842-
CGM.getLLVMLinkageVarDefinition(VD, /*IsConstant=*/false);
2842+
CGM.getLLVMLinkageVarDefinition(VD);
28432843

28442844
// For internal linkage variables, we don't need an external or weak wrapper.
28452845
if (llvm::GlobalValue::isLocalLinkage(VarLinkage))

clang/lib/CodeGen/MicrosoftCXXABI.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,8 +1379,7 @@ llvm::GlobalValue::LinkageTypes MicrosoftCXXABI::getCXXDestructorLinkage(
13791379
case Dtor_Base:
13801380
// The base destructor most closely tracks the user-declared constructor, so
13811381
// we delegate back to the normal declarator case.
1382-
return CGM.getLLVMLinkageForDeclarator(Dtor, Linkage,
1383-
/*IsConstantVariable=*/false);
1382+
return CGM.getLLVMLinkageForDeclarator(Dtor, Linkage);
13841383
case Dtor_Complete:
13851384
// The complete destructor is like an inline function, but it may be
13861385
// imported and therefore must be exported as well. This requires changing

0 commit comments

Comments
 (0)