[flang-commits] [flang] [flang] Use the target index width during FIR-to-LLVM lowering (PR #226424)

via flang-commits flang-commits at lists.llvm.org
Fri Sep 25 03:08:49 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-codegen

Author: Anutosh Bhat (anutosh491)

<details>
<summary>Changes</summary>

I'm interested in Flang cross-compilation to wasm32/wasm64 (as my [RFC](https://discourse.llvm.org/t/rfc-proposing-an-interactive-fortran-workflow-with-flang-using-jupyter-notebooks/89116) here says).

While working on it I noticed that FIR-to-LLVM lowering still hard-coded `i64` as its aggregate/index type, even when the target uses 32-bit indices.

This patch:

- uses the index width configured by `LowerToLLVMOptions`;
- materializes target conversions before emitting LLVM integer operations;

This is a general cross-compilation fix and does not contain any Wasm-specific logic. Tested with `fir-opt` for i386, x86-64 and other targets.

---
Full diff: https://github.com/llvm/llvm-project/pull/226424.diff


3 Files Affected:

- (modified) flang/lib/Optimizer/CodeGen/FIROpPatterns.cpp (+10-4) 
- (modified) flang/lib/Optimizer/CodeGen/TypeConverter.cpp (+7-3) 
- (modified) flang/test/Fir/convert-to-llvm-target.fir (+19) 


``````````diff
The server is unavailable at this time. Please wait a few minutes before you try again.
``````````

</details>


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


More information about the flang-commits mailing list