llvm-project
9bda9bdf - [CIR] Allow multi-block ctor regions on GlobalOp (#193596)

Commit
7 days ago
[CIR] Allow multi-block ctor regions on GlobalOp (#193596) C++14 variable templates with non-constexpr constructors (e.g., `static const Foo<N> x{}` where `Foo()` is not constexpr) crash CIR codegen with: ``` 'cir.global' op region #0 ('ctorRegion') failed to verify constraint: region with at most 1 blocks ``` The problem is that `GlobalOp`'s `ctorRegion` is declared as `MaxSizedRegion<1>`, but when exceptions are enabled, `emitAggExpr` can create additional blocks in the ctor region for EH cleanup scaffolding (unreachable/trap terminators). These extra blocks are dead code — `LoweringPrepare` already discards them when it moves the ctor region into `__cxx_global_var_init`. This patch relaxes the constraint to `AnyRegion` and replaces the `llvm_unreachable("Multiple blocks NYI")` in the static-local guard path with an assert (that path will be reworked by #193576). Made with [Cursor](https://cursor.com)
Author
Parents
Loading