aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CIR/CodeGen/CIRGenModule.cpp
diff options
context:
space:
mode:
authorMorris Hafner <mmha@users.noreply.github.com>2025-08-20 12:53:00 +0200
committerGitHub <noreply@github.com>2025-08-20 12:53:00 +0200
commit0989ff5de8daa5b5689f975141e720e0bc8afcad (patch)
tree95a568964f334fd3b3bf350668cf87a788120d33 /clang/lib/CIR/CodeGen/CIRGenModule.cpp
parent3b9664840bc59c1a5230d222f7eedb2668697ccc (diff)
downloadllvm-0989ff5de8daa5b5689f975141e720e0bc8afcad.zip
llvm-0989ff5de8daa5b5689f975141e720e0bc8afcad.tar.gz
llvm-0989ff5de8daa5b5689f975141e720e0bc8afcad.tar.bz2
[CIR] Add constant attribute to GlobalOp (#154359)
This patch adds the constant attribute to cir.global, the appropriate lowering to LLVM constant and updates the tests. --------- Co-authored-by: Andy Kaylor <akaylor@nvidia.com>
Diffstat (limited to 'clang/lib/CIR/CodeGen/CIRGenModule.cpp')
-rw-r--r--clang/lib/CIR/CodeGen/CIRGenModule.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index d529688..7c52adc 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -458,7 +458,7 @@ mlir::Operation *CIRGenModule::getGlobalValue(StringRef name) {
cir::GlobalOp CIRGenModule::createGlobalOp(CIRGenModule &cgm,
mlir::Location loc, StringRef name,
- mlir::Type t,
+ mlir::Type t, bool isConstant,
mlir::Operation *insertPoint) {
cir::GlobalOp g;
CIRGenBuilderTy &builder = cgm.getBuilder();
@@ -479,7 +479,7 @@ cir::GlobalOp CIRGenModule::createGlobalOp(CIRGenModule &cgm,
builder.setInsertionPointToStart(cgm.getModule().getBody());
}
- g = builder.create<cir::GlobalOp>(loc, name, t);
+ g = builder.create<cir::GlobalOp>(loc, name, t, isConstant);
if (!insertPoint)
cgm.lastGlobalOp = g;
@@ -581,7 +581,7 @@ CIRGenModule::getOrCreateCIRGlobal(StringRef mangledName, mlir::Type ty,
// mlir::SymbolTable::Visibility::Public is the default, no need to explicitly
// mark it as such.
cir::GlobalOp gv =
- CIRGenModule::createGlobalOp(*this, loc, mangledName, ty,
+ CIRGenModule::createGlobalOp(*this, loc, mangledName, ty, false,
/*insertPoint=*/entry.getOperation());
// This is the first use or definition of a mangled name. If there is a
@@ -1239,8 +1239,8 @@ generateStringLiteral(mlir::Location loc, mlir::TypedAttr c,
// Create a global variable for this string
// FIXME(cir): check for insertion point in module level.
- cir::GlobalOp gv =
- CIRGenModule::createGlobalOp(cgm, loc, globalName, c.getType());
+ cir::GlobalOp gv = CIRGenModule::createGlobalOp(
+ cgm, loc, globalName, c.getType(), !cgm.getLangOpts().WritableStrings);
// Set up extra information and add to the module
gv.setAlignmentAttr(cgm.getSize(alignment));