This is an archive of the discontinued LLVM Phabricator instance.

[flang][driver] Add support for consuming LLVM IR/BC files
ClosedPublic

Authored by awarzynski on Apr 29 2022, 3:50 AM.

Details

Summary

This change is mostly about making sure that Flang's driver recognises
LLVM IR and BC as supported as supported file formats. To this end,
isFortran is extended and renamed as isSupportedByFlang (the latter
better reflects the new functionality).

Some new tests are added to verify that the target triple is overridden
by the frontend driver's default or the value specified with -triple.
Strictly speaking, this is not a functionality that's added here.
However, this patch enables us to write such tests and hence I'm
including them here.

Depends on D124664
Depends on D124665

Diff Detail

Event Timeline

awarzynski created this revision.Apr 29 2022, 3:50 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
Herald added a subscriber: mgorny. · View Herald Transcript
awarzynski requested review of this revision.Apr 29 2022, 3:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 29 2022, 3:50 AM
rovka accepted this revision.May 2 2022, 1:05 AM

A few nits, but otherwise LGTM.

flang/lib/Frontend/FrontendActions.cpp
86

Nit: Should we assert that the language is Language::Fortran at this point?

flang/test/Driver/emit-asm-from-llvm-bc.ll
2
3
9

Have you tried %basename_t.bc instead? You might be able to skip all the rms then...

flang/test/Driver/emit-asm-from-llvm.ll
1
2
3
flang/test/Driver/override-triple.ll
20
This revision is now accepted and ready to land.May 2 2022, 1:05 AM
awarzynski marked 8 inline comments as done.May 3 2022, 6:18 AM

Thanks for the review @rovka!

flang/lib/Frontend/FrontendActions.cpp
86

No harm in doing so 👍 !

flang/test/Driver/emit-asm-from-llvm-bc.ll
9

IIUC, the only difference between %t.bcand %basename_t.bc is that former contains a directory name and the file extension and latter does not. In either case, LIT won't delete it :(

I like %t a bit more as this way we make sure that the output lands in the right temporary directory.

awarzynski updated this revision to Diff 426678.May 3 2022, 6:24 AM
awarzynski marked 2 inline comments as done.

Add an assert, make some editorial changes in comments

awarzynski updated this revision to Diff 427032.May 4 2022, 8:59 AM

Rebase on top of main

This revision was landed with ongoing or failed builds.May 5 2022, 8:12 AM
This revision was automatically updated to reflect the committed changes.