This is an archive of the discontinued LLVM Phabricator instance.

[Flang} Fix issues in lowering loop variable of io implied do loop
AbandonedPublic

Authored by kiranchandramohan on Apr 21 2022, 4:20 AM.

Details

Summary

The existing codegen was for loop variables in io implied do loop
was not working correctly for pointer, allocatable variables. Rather
than finding the symbol address directly, use Evaluate Expression to
find the correct symbol and find the expression address from it. This
is similar to the handling for loop variables in fir.do_loop.

This is patch is part of upstreaming code from fir-dev branch of
https://github.com/flang-compiler/f18-llvm-project.

Diff Detail

Event Timeline

Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 21 2022, 4:20 AM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
kiranchandramohan requested review of this revision.Apr 21 2022, 4:20 AM

Can you check why the windows buildbot is failing?

@clementval I have no idea. I have not changed the result operation (fir.result). Not sure what is going wrong here and why it is different from linux. Posting the failure below in case @schweitz or @jeanPerier or you have any idea.

******************** TEST 'Flang :: Lower/io-implied-do-fixes.f90' FAILED ********************
Script:
--
: 'RUN: at line 1';   bbc -emit-fir C:\ws\w3\llvm-project\premerge-checks\flang\test\Lower\io-implied-do-fixes.f90 -o - | c:\ws\w3\llvm-project\premerge-checks\build\bin\filecheck.exe C:\ws\w3\llvm-project\premerge-checks\flang\test\Lower\io-implied-do-fixes.f90
--
Exit Code: 2
 
Command Output (stdout):
--
$ ":" "RUN: at line 1"
$ "bbc" "-emit-fir" "C:\ws\w3\llvm-project\premerge-checks\flang\test\Lower\io-implied-do-fixes.f90" "-o" "-"
# command stderr:
error: loc("C:\\ws\\w3\\llvm-project\\premerge-checks\\flang\\test\\Lower\\io-implied-do-fixes.f90":46:3): 'fir.result' op types mismatch between result op and its parent
FATAL: verification of lowering to FIR failed
error: command failed with exit status: 1
$ "c:\ws\w3\llvm-project\premerge-checks\build\bin\filecheck.exe" "C:\ws\w3\llvm-project\premerge-checks\flang\test\Lower\io-implied-do-fixes.f90"
# command stderr:
FileCheck error: '<stdin>' is empty.
FileCheck command line:  c:\ws\w3\llvm-project\premerge-checks\build\bin\filecheck.exe C:\ws\w3\llvm-project\premerge-checks\flang\test\Lower\io-implied-do-fixes.f90
 
error: command failed with exit status: 2

It doesn't look familiar to me, @kiranchandramohan .

I am not entirely surprised that IO contains something os-specific (that's what the failure would suggest). But it is hard to pin it down without the actual output, which is impossible without a Windows machine. I'd be OK with marking this particular test as unsupported on Windows and creating a GitHub ticket to track this. While it would be great to make it work on Windows, IMHO upstreaming is of much higher priority for us right now.

Btw, from the logs it seems that only ido3 is failing. Perhaps extract it to a separate file?

One last point, I find "io-implied-do-fixes.f90" to be a bit confusing. Without a bug report (or "before" vs "after" comments) it doesn't really feel like there are any "fixes" in this test file. It simply verifies the lowering of implied DO loops.

flang/test/Lower/io-implied-do-fixes.f90
1

Could add a RUN line with flang-new as well?

4

[nit] Why J_<name> everywhere?

7

What's CVT1?

9

I'm guessing that there's a call to print somewhere here?

12

Could subroutine names have a bit more descriptive name so that it's clear what's unique about each one of them? Alternatively, you could add a comment.

22

Would it be possible to replace %{{.*}} to %{{.*}} step %{{.*}} with some values from print *, (iptr,iptr=1,10)? Basically, something that would make it obvious that one corresponds to the other (might help to change indices in print).

kiranchandramohan abandoned this revision.Jul 26 2022, 4:24 AM

This went in as part of D120743, D128634. Created an issue for the failure on Windows https://github.com/llvm/llvm-project/issues/56723.