This is an archive of the discontinued LLVM Phabricator instance.

[flang] Lower integer constant code for STOP stmt
ClosedPublic

Authored by clementval on Feb 2 2022, 6:34 AM.

Details

Summary

This patch lower the integer constant code in the STOP statement.

The code is lowered to arith.constant.

This patch is part of the upstreaming effort from fir-dev branch.

Diff Detail

Event Timeline

clementval created this revision.Feb 2 2022, 6:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 2 2022, 6:34 AM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
clementval requested review of this revision.Feb 2 2022, 6:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 2 2022, 6:34 AM
kiranchandramohan accepted this revision.Feb 2 2022, 8:05 AM

LGTM.

flang/test/Lower/stop-statement.f90
27

Assuming the convert is removed by the canonicalize pass and that we don't have enough support for other types for the convert to be retained.

This revision is now accepted and ready to land.Feb 2 2022, 8:05 AM
clementval added inline comments.Feb 2 2022, 9:48 AM
flang/test/Lower/stop-statement.f90
27

Not sure I follow your comment here. The output of ./bin/bbc -emit-fir (without --canonicalize ) is the following:

func @_QPss() {
  %c42_i32 = arith.constant 42 : i32
  %false = arith.constant false
  %false_0 = arith.constant false
  %0 = fir.call @_FortranAStopStatement(%c42_i32, %false, %false_0) : (i32, i1, i1) -> none
  fir.unreachable
^bb1:  // no predecessors
  return
}

So there is no convert.. Do you have smth else?

flang/test/Lower/stop-statement.f90
27

Sorry, I completely missed the point that createConvert function checks whether the source and dest types are different and then only inserts the convert.

A test with a convert would be great. But if there is not enough infra that is OK.

flang/test/Lower/stop-statement.f90
27

I just saw from the standard that the Stop code value has to be an integer of the default kind. So you can skip my comment.

schweitz accepted this revision.Feb 2 2022, 12:10 PM
clementval marked 3 inline comments as done.Feb 3 2022, 2:07 AM
This revision was landed with ongoing or failed builds.Feb 3 2022, 2:31 AM
This revision was automatically updated to reflect the committed changes.