[all-commits] [llvm/llvm-project] 41ab14: [CIR] Fix assertion on Microsoft-ABI C++20 named m...

Konstantinos Parasyris via All-commits all-commits at lists.llvm.org
Wed Sep 23 09:15:33 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 41ab14be8d53df1df1e46d2a80c37463aeb02a31
      https://github.com/llvm/llvm-project/commit/41ab14be8d53df1df1e46d2a80c37463aeb02a31
  Author: Konstantinos Parasyris <koparasy at gmail.com>
  Date:   2026-09-23 (Wed, 23 Sep 2026)

  Changed paths:
    M clang/lib/CIR/CodeGen/CIRGenModule.cpp
    M clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp
    A clang/test/CIR/CodeGen/cxx20-module-initializer-ms-abi.cppm

  Log Message:
  -----------
  [CIR] Fix assertion on Microsoft-ABI C++20 named module initializer (#225565)

Compiling a C++20 named module interface unit for the Microsoft C++ ABI
asserts in `LoweringPrepare`, because the AST fallback for the
initializer name does an unguarded `cast<ItaniumMangleContext>`
([LoweringPrepare.cpp#L2006-L2013](https://github.com/llvm/llvm-project/blob/97458f644132d62bb938823394b716b684956f49/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp#L2006-L2013)).

That fallback is reachable because CIRGen only emits
`cir.cxx_module_init_fn_name` for the Itanium mangler
([CIRGenModule.cpp#L3985-L3996](https://github.com/llvm/llvm-project/blob/97458f644132d62bb938823394b716b684956f49/clang/lib/CIR/CodeGen/CIRGenModule.cpp#L3985-L3996)),
mirroring classic codegen's `CXX20ModuleInits`
([CodeGenModule.cpp#L596-L601](https://github.com/llvm/llvm-project/blob/97458f644132d62bb938823394b716b684956f49/clang/lib/CodeGen/CodeGenModule.cpp#L596-L601)).

This deletes the fallback so the attribute is the only channel: absent
means `_GLOBAL__sub_I_` with internal linkage, which is exactly what
classic codegen does for this ABI
([CodeGenModule.cpp#L1205-L1208](https://github.com/llvm/llvm-project/blob/97458f644132d62bb938823394b716b684956f49/clang/lib/CodeGen/CodeGenModule.cpp#L1205-L1208)).

The new test pins that lowering and fails with the same assertion
without the fix. It checks CIR rather than LLVM IR because Microsoft-ABI
CIR cannot reach LLVM IR yet (`EH ABI lowering is not yet implemented
for the Microsoft ABI`). This also drops the last `ASTContext` use in
`buildCXXGlobalInitFunc`.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list