This is an archive of the discontinued LLVM Phabricator instance.

[Flang] Restricting dynamic arrays stack to heap move
Needs ReviewPublic

Authored by d-smirnov on Jul 21 2023, 1:05 PM.

Details

Summary

This patch restricts moving dynamic arrays to heap to arrays with all dynamic dimensions only
(i.e fir.array<?x?xf64> but not fir.array<5x?xf64>).
The patch also enables -fdynamic-heap-array flag by default.

Context: An issue was observed in 503.bwaves_r, where a function having an alloca with a dynamic size was not being inlined in LLVM. Converting to heap-arrays enables inlining.

Diff Detail

Event Timeline

d-smirnov created this revision.Jul 21 2023, 1:05 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
d-smirnov requested review of this revision.Jul 21 2023, 1:05 PM
kiranchandramohan edited the summary of this revision. (Show Details)Jul 24 2023, 9:00 AM

Thank you for working on this.

Could you please provide more information about the LLVM behavior for the dynamically sized alloca? What sort of a heuristics prevents the inlining? Can you share optimization remarks (if there is any valuable info in there)?

flang/include/flang/Tools/CLOptions.inc
33

Please change the default value in a separate commit. I also think that such a change has to be accompanied with at least some performance data for the major benchmarks, e.g. a summary of regressions/improvements caused by this change would be useful.