[flang-commits] [flang] [Flang] Extracting internal constants from scalar literals (PR #73829)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Tue Jun 18 07:46:01 PDT 2024


klausler wrote:

> > > Conforming or not, code that is reasonably portable today should also work with f18 with default options without source changes. This case is kind of on the edge.
> > 
> > 
> > This particular example works fine (as in prints 1 twice) with these changes - because the write to x gets optimized away, I think.
> > I'm not sure if there are more complex cases where it doesn't work quite that well - I have a hard time coming up with a case where this pass actually goes wrong. Your comments makes me wonder what we should do for that - the only plausible solution I can think of is to basically not do this unless we the compiler can "see" the source of the code being called - and it's precisely the case of the callee being in a different module that we're trying to make better here.
> > Any thoughts?
> 
> @klausler : Would it help if we only enable this on -O2 or something like that? Then it's not enabled without the user specifying a higher optimiseation level.

It seems weird to have an optimization level imply less portable semantics that are needed to work around a weakness in an optimization pass.  Would it not be better to improve LTO's handling of constant arguments passed by reference?

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


More information about the flang-commits mailing list