[clang] [CIR] Source LoweringPrepare target facts from the module (PR #219078)

Konstantinos Parasyris via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 16 10:53:45 PDT 2026


================
@@ -298,6 +299,14 @@ struct LoweringPreparePass
 
   clang::ASTContext *astCtx;
 
+  /// Target/ABI facts sourced from the module's own attributes.
+  std::unique_ptr<cir::LowerModule> lowerModule;
+
+  const clang::TargetInfo &getTargetInfo() const {
+    assert(lowerModule && "LoweringPrepare requires a module with a triple");
----------------
koparasy wrote:

@bcardosolopes Made `cir-lowering-prepare` a module pass (per @andykaylor), so the ModuleOp operand is guaranteed.  The remaining  assert is kept at getTargetInfo()'s precondition. it can not be hit today, but I kept it in the accessor so any future caller is covered. I can also implement a lazy initializer:

```
const clang::TargetInfo &getTargetInfo() {
  if (!lowerModule)
    lowerModule = cir::createLowerModule(mlirModule);
  assert(lowerModule && "requires a module with a triple");
  return lowerModule->getTarget();
}
```

But I think this is not necessary now. 

Any comments?

https://github.com/llvm/llvm-project/pull/219078


More information about the cfe-commits mailing list