[PATCH] D86695: [RFC] Call ParseLangArgs for all inputs

Harald van Dijk via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 27 04:09:10 PDT 2020


hvdijk created this revision.
Herald added subscribers: cfe-commits, atanasyan, arichardson, sdardis.
Herald added a project: clang.
hvdijk requested review of this revision.

clang/lib/CodeGen/BackendUtil.cpp contains multiple checks for attributes of LangOpts. The option processing that sets up LangOpts is mostly done by ParseLangArgs, which is skipped for LLVM IR files. Because of this, there are code generation differences when the -save-temps command line option is used: that command line option causes LLVM IR to be emitted to file and a new process to be spawned to process that file, which does not process options the same way.

An example of this is

  typedef float __attribute__((ext_vector_type(2))) float2;
  float2 foo (float2 a, float2 b, float2 c) {
    return a * b + c;
  }

This used to generate different code with clang --target=mips -mcpu=mips32r5 -mfp64 -mmsa -O3 -ffp-contract=fast depending on whether -save-temps was also present, because the -ffp-contract=fast option affects instruction selection but was ignored for LLVM IR input files.

While CompilerInvocation::CreateFromArgs contained special exceptions for a few options that were handled by ParseLangArgs that also need to be handled for LLVM IR, there are many more, and just allowing ParseLangArgs to be called seems like the simpler fix.

For InputKind::Precompiled, -std=* options were previously silently ignored and continue to be silently ignored, as it is reasonable for users to add them and in fact this is done in quite a number of tests in the test suite.

For Language::LLVM_IR, -std=* options were previously silently ignored and now result in an error, as it is not reasonable for users to add them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86695

Files:
  clang/lib/Frontend/CompilerInvocation.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86695.288263.patch
Type: text/x-patch
Size: 5686 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200827/8b194483/attachment.bin>


More information about the cfe-commits mailing list