aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CIR/CodeGen/CIRGenModule.cpp
diff options
context:
space:
mode:
authorSirui Mu <msrlancern@gmail.com>2025-07-02 23:29:43 +0800
committerGitHub <noreply@github.com>2025-07-02 23:29:43 +0800
commit1841b021c6bfda80cd0edd97cc8dff8e0f718993 (patch)
treef214a9c23a482fd5dc0ea83600b84614dfe1694c /clang/lib/CIR/CodeGen/CIRGenModule.cpp
parentce99db9d1b8ab609575893fc8026143d9b4765c9 (diff)
downloadllvm-1841b021c6bfda80cd0edd97cc8dff8e0f718993.zip
llvm-1841b021c6bfda80cd0edd97cc8dff8e0f718993.tar.gz
llvm-1841b021c6bfda80cd0edd97cc8dff8e0f718993.tar.bz2
[CIR] Add OptInfo attribute (#146261)
This patch adds the `#cir.opt_info` attribute which holds module-level optimization information.
Diffstat (limited to 'clang/lib/CIR/CodeGen/CIRGenModule.cpp')
-rw-r--r--clang/lib/CIR/CodeGen/CIRGenModule.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 7198b23..c1434ee 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -104,6 +104,12 @@ CIRGenModule::CIRGenModule(mlir::MLIRContext &mlirContext,
theModule->setAttr(cir::CIRDialect::getTripleAttrName(),
builder.getStringAttr(getTriple().str()));
+
+ if (cgo.OptimizationLevel > 0 || cgo.OptimizeSize > 0)
+ theModule->setAttr(cir::CIRDialect::getOptInfoAttrName(),
+ cir::OptInfoAttr::get(&mlirContext,
+ cgo.OptimizationLevel,
+ cgo.OptimizeSize));
}
CIRGenModule::~CIRGenModule() = default;