[llvm] [ConstantFold] Remove recursion from ConstantFoldInsertValueInstruction (PR #88541)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 12 18:22:23 PDT 2024


nikic wrote:

It sounds like flang is constructing a big aggregate by repeatedly performing insertvalue operations to initialize each individual part of it. If that's the case, there's just fundamentally no way to salvage this on the LLVM side no matter how you turn it: Each time you call insertvalue, a whole new aggregate has to be constructed from scratch. Constants are immutable, so you can't do an incremental update on them.

Instead, you should be directly constructing the whole constant aggregate in one go, or if that is not possible, use a global ctor and initialize it with memory operations. (LLVM can turn that back into a constant aggregate efficiently.)

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


More information about the llvm-commits mailing list