[CIR][NFCI] Remove 'isConstant' from getCIRLinkageForX#193100
Open
erichkeane wants to merge 1 commit intollvm:mainfrom
Open
[CIR][NFCI] Remove 'isConstant' from getCIRLinkageForX#193100erichkeane wants to merge 1 commit intollvm:mainfrom
erichkeane wants to merge 1 commit intollvm:mainfrom
Conversation
This variable has since disappeared from classic compiler, and we weren't using it anywhere anyway. This patch gets us back in sync with the classic codegen for these interfaces.
Member
|
@llvm/pr-subscribers-clangir @llvm/pr-subscribers-clang Author: Erich Keane (erichkeane) ChangesThis variable has since disappeared from classic compiler, and we weren't using it anywhere anyway. This patch gets us back in sync with the classic codegen for these interfaces. Full diff: https://github.com/llvm/llvm-project/pull/193100.diff 6 Files Affected:
diff --git a/clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp b/clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp
index e5e4f860faf38..83062c3906edf 100644
--- a/clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp
@@ -63,8 +63,7 @@ void CIRGenCXXABI::buildThisParam(CIRGenFunction &cgf,
cir::GlobalLinkageKind CIRGenCXXABI::getCXXDestructorLinkage(
GVALinkage linkage, const CXXDestructorDecl *dtor, CXXDtorType dt) const {
// Delegate back to cgm by default.
- return cgm.getCIRLinkageForDeclarator(dtor, linkage,
- /*isConstantVariable=*/false);
+ return cgm.getCIRLinkageForDeclarator(dtor, linkage);
}
mlir::Value CIRGenCXXABI::loadIncomingCXXThis(CIRGenFunction &cgf) {
diff --git a/clang/lib/CIR/CodeGen/CIRGenDecl.cpp b/clang/lib/CIR/CodeGen/CIRGenDecl.cpp
index 66f6f7f11e76f..fce81a458e937 100644
--- a/clang/lib/CIR/CodeGen/CIRGenDecl.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenDecl.cpp
@@ -371,8 +371,7 @@ void CIRGenFunction::emitVarDecl(const VarDecl &d) {
return;
}
- cir::GlobalLinkageKind linkage =
- cgm.getCIRLinkageVarDefinition(&d, /*IsConstant=*/false);
+ cir::GlobalLinkageKind linkage = cgm.getCIRLinkageVarDefinition(&d);
// FIXME: We need to force the emission/use of a guard variable for
// some variables even if we can constant-evaluate them because
diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
index 7fb34f2c53631..18810b6abf228 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
@@ -912,7 +912,7 @@ static bool canEmitSpuriousReferenceToVariable(CIRGenFunction &cgf,
// We can emit a spurious reference only if the linkage implies that we'll
// be emitting a non-interposable symbol that will be retained until link
// time.
- switch (cgf.cgm.getCIRLinkageVarDefinition(vd, /*IsConstant=*/false)) {
+ switch (cgf.cgm.getCIRLinkageVarDefinition(vd)) {
case cir::GlobalLinkageKind::ExternalLinkage:
case cir::GlobalLinkageKind::LinkOnceODRLinkage:
case cir::GlobalLinkageKind::WeakODRLinkage:
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
index 330e51c214dfc..a8b24fb686088 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
@@ -1404,8 +1404,7 @@ ConstantLValueEmitter::tryEmitBase(const APValue::LValueBase &base) {
return cgm.getAddrOfGlobalVarAttr(vd);
if (vd->isLocalVarDecl()) {
- cir::GlobalLinkageKind linkage =
- cgm.getCIRLinkageVarDefinition(vd, /*IsConstant=*/false);
+ cir::GlobalLinkageKind linkage = cgm.getCIRLinkageVarDefinition(vd);
return cgm.getBuilder().getGlobalViewAttr(
cgm.getOrCreateStaticVarDecl(*vd, linkage));
}
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 2f64fe45a694d..827a5d4a67ae0 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -1305,8 +1305,7 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *vd,
}
// Set CIR's linkage type as appropriate.
- cir::GlobalLinkageKind linkage =
- getCIRLinkageVarDefinition(vd, /*IsConstant=*/false);
+ cir::GlobalLinkageKind linkage = getCIRLinkageVarDefinition(vd);
// CUDA B.2.1 "The __device__ qualifier declares a variable that resides on
// the device. [...]"
@@ -1692,16 +1691,14 @@ static bool isVarDeclStrongDefinition(const ASTContext &astContext,
return false;
}
-cir::GlobalLinkageKind CIRGenModule::getCIRLinkageForDeclarator(
- const DeclaratorDecl *dd, GVALinkage linkage, bool isConstantVariable) {
+cir::GlobalLinkageKind
+CIRGenModule::getCIRLinkageForDeclarator(const DeclaratorDecl *dd,
+ GVALinkage linkage) {
if (linkage == GVA_Internal)
return cir::GlobalLinkageKind::InternalLinkage;
- if (dd->hasAttr<WeakAttr>()) {
- if (isConstantVariable)
- return cir::GlobalLinkageKind::WeakODRLinkage;
+ if (dd->hasAttr<WeakAttr>())
return cir::GlobalLinkageKind::WeakAnyLinkage;
- }
if (const auto *fd = dd->getAsFunction())
if (fd->isMultiVersion() && linkage == GVA_AvailableExternally)
@@ -1827,10 +1824,9 @@ void CIRGenModule::replaceUsesOfNonProtoTypeWithRealFunction(
}
cir::GlobalLinkageKind
-CIRGenModule::getCIRLinkageVarDefinition(const VarDecl *vd, bool isConstant) {
- assert(!isConstant && "constant variables NYI");
+CIRGenModule::getCIRLinkageVarDefinition(const VarDecl *vd) {
GVALinkage linkage = astContext.GetGVALinkageForVariable(vd);
- return getCIRLinkageForDeclarator(vd, linkage, isConstant);
+ return getCIRLinkageForDeclarator(vd, linkage);
}
cir::GlobalLinkageKind CIRGenModule::getFunctionLinkage(GlobalDecl gd) {
@@ -1841,7 +1837,7 @@ cir::GlobalLinkageKind CIRGenModule::getFunctionLinkage(GlobalDecl gd) {
if (const auto *dtor = dyn_cast<CXXDestructorDecl>(d))
return getCXXABI().getCXXDestructorLinkage(linkage, dtor, gd.getDtorType());
- return getCIRLinkageForDeclarator(d, linkage, /*isConstantVariable=*/false);
+ return getCIRLinkageForDeclarator(d, linkage);
}
static cir::GlobalOp
@@ -3460,8 +3456,7 @@ CIRGenModule::getAddrOfGlobalTemporary(const MaterializeTemporaryExpr *mte,
}
// Create a global variable for this lifetime-extended temporary.
- cir::GlobalLinkageKind linkage =
- getCIRLinkageVarDefinition(varDecl, /*isConstant=*/false);
+ cir::GlobalLinkageKind linkage = getCIRLinkageVarDefinition(varDecl);
if (linkage == cir::GlobalLinkageKind::ExternalLinkage) {
const VarDecl *initVD;
if (varDecl->isStaticDataMember() && varDecl->getAnyInitializer(initVD) &&
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.h b/clang/lib/CIR/CodeGen/CIRGenModule.h
index ba3f936106d31..1b999abd4caea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.h
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.h
@@ -756,8 +756,7 @@ class CIRGenModule : public CIRGenTypeCache {
cir::GlobalLinkageKind getFunctionLinkage(GlobalDecl gd);
static mlir::SymbolTable::Visibility getMLIRVisibility(cir::GlobalOp op);
cir::GlobalLinkageKind getCIRLinkageForDeclarator(const DeclaratorDecl *dd,
- GVALinkage linkage,
- bool isConstantVariable);
+ GVALinkage linkage);
void setFunctionLinkage(GlobalDecl gd, cir::FuncOp f) {
cir::GlobalLinkageKind l = getFunctionLinkage(gd);
f.setLinkageAttr(cir::GlobalLinkageKindAttr::get(&getMLIRContext(), l));
@@ -765,8 +764,7 @@ class CIRGenModule : public CIRGenTypeCache {
getMLIRVisibilityFromCIRLinkage(l));
}
- cir::GlobalLinkageKind getCIRLinkageVarDefinition(const VarDecl *vd,
- bool isConstant);
+ cir::GlobalLinkageKind getCIRLinkageVarDefinition(const VarDecl *vd);
void addReplacement(llvm::StringRef name, mlir::Operation *op);
|
bcardosolopes
approved these changes
Apr 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This variable has since disappeared from classic compiler, and we weren't using it anywhere anyway. This patch gets us back in sync with the classic codegen for these interfaces.