[Mlir-commits] [flang] [mlir] [MLIR][LLVMIR] Use TargetFolder when creating globals (PR #126745)

Nikita Popov llvmlistbot at llvm.org
Tue Feb 11 11:36:51 PST 2025


nikic wrote:

> Is this correctness issue limited to globals, or could this also be an issue when translating the operations within function bodies?

If constant folding is not possible, IRBuilder will create instructions, which is fine for function bodies but not for globals. Using TargetFolder for function bodies still makes sense though, to avoid generating unnecessary instructions for cases that can be constant folded. I'll probably try doing that in a followup.

> Does the llvm builder always fold or does the constant folding happen once the expression is casted to a constant expression (the latter is only done for globals/aliases I believe)?

The IRBuilder always does constant folding on the fly (well, unless you disable it entirely using NoFolder).

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


More information about the Mlir-commits mailing list