forked from OSchip/llvm-project
02fb5b771d
*SUMMARY* Currently, the frontend driver assumes that a target triple is either: * provided by the frontend itself (e.g. when lowering and generating code), * specified through the `-triple/-target` command line flags. If `-triple/-target` is not used, the frontend will simply use the host triple. This is going to be insufficient when e.g. consuming an LLVM IR file that has no triple specified (reading LLVM files is WIP, see D124667). We shouldn't require the triple to be specified via the command line in such situation. Instead, the frontend driver should contain a good default, e.g. the host triple. This patch updates Flang's `CompilerInvocation` to do just that, i.e. defines its default target triple. Similarly to Clang: * the default `CompilerInvocation` triple is set as the host triple, * the value specified with `-triple` takes precedence over the frontend driver default and the current module triple, * the frontend driver default takes precedence over the module triple. *TESTS* This change requires 2 unit tests to be updated. That's because relevant frontend actions are updated to assume that there's always a valid triple available in the current `CompilerInvocation`. This update is required because the unit tests bypass the regular `CompilerInvocation` set-up (in particular, they don't call `CompilerInvocation::CreateFromArgs`). I've also taken the liberty to disable the pre-precossor formatting in the affected unit tests as well (it is not required). No new tests are added. As `flang-new -fc1` does not support consuming LLVM IR files just yet, it is not possible to compile an LLVM IR file without a triple. More specifically, atm all LLVM IR files are generated and stored internally and the driver makes sure that these contain a valid target triple. This is about to change in D124667 (which adds support for reading LLVM IR/BC files) and that's where tests for exercising the default frontend driver triple will be added. *WHAT DOES CLANG DO?* For reference, the default target triple for Clang's `CompilerInvocation` is set through option marshalling infra [1] in Options.td. Please check the definition of the `-triple` flag: ``` def triple : Separate<["-"], "triple">, HelpText<"Specify target triple (e.g. i686-apple-darwin9)">, MarshallingInfoString<TargetOpts<"Triple">, "llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())">, AlwaysEmit, Normalizer<"normalizeTriple">; ``` Ideally, we should re-use the marshalling infra in Flang. [1] https://clang.llvm.org/docs/InternalsManual.html#option-marshalling-infrastructure Differential Revision: https://reviews.llvm.org/D124664 |
||
---|---|---|
.. | ||
Common | ||
Decimal | ||
Evaluate | ||
Frontend | ||
FrontendTool | ||
Lower | ||
Optimizer | ||
Parser | ||
Semantics | ||
CMakeLists.txt |