[PATCH] D120568: [flang][driver] Add support for -S and implement -c/-emit-obj
Andrzej Warzynski via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 28 06:22:30 PST 2022
awarzynski marked 3 inline comments as done.
awarzynski added inline comments.
================
Comment at: flang/lib/Frontend/FrontendActions.cpp:43
using namespace Fortran::frontend;
+using namespace llvm;
----------------
schweitz wrote:
> You'll want to keep in mind that some class names are overloaded between llvm and Fortran::xyz namespaces and even between Fortran::uvw and Fortran::xyz namespaces.
Thanks, I will revert this.
================
Comment at: flang/lib/Frontend/FrontendActions.cpp:559
+ std::make_unique<llvm::TargetLibraryInfoImpl>(triple);
+ CodeGenPasses.add(new TargetLibraryInfoWrapperPass(*TLII));
+
----------------
schweitz wrote:
> Do you want to assert on this RAII of `TLII`?
Any particular suggestion? I don't see anything that I could `assert` here.
================
Comment at: flang/lib/Optimizer/Support/FIRContext.cpp:19
-static constexpr const char *tripleName = "fir.triple";
+static constexpr const char *tripleName = "llvm.target_triple";
----------------
schweitz wrote:
> Why is this being changed? This is a FIR specific attribute.
The driver assumes that when compiling a Fortran file, a valid triple will be present in the generated LLVM IR file. Currently, `fir.tiple` is just dropped and the generated LLVM IR module contains no triple. For `-emit-obj`/`-S` to work, we do need to make sure that a valid triple is actually there.
We could add logic to translate `fir.triple` to `llvm.target_triple` (in the FIR --> LLVM MLIR translation layer), but why bother if it's not used anywhere? Instead, Flang could use `llvm.target_triple` from the very beginning. This way, no extra functionality is needed (`llvm.target_triple` is preserved when translating from FIR to LLVM MLIR and then included in the generated LLVM IR module).
AFAIK, `fir-triple` is never used anywhere. In fact, it's already been removed from [[ https://github.com/flang-compiler/f18-llvm-project/blob/fir-dev/flang/lib/Optimizer/Support/FIRContext.cpp#L19 | fir-dev ]].
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120568/new/
https://reviews.llvm.org/D120568
More information about the cfe-commits
mailing list