[PATCH] D64610: [clang] allow -fthinlto-index= without -x ir

Bob Haarman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 15 13:53:45 PDT 2019


This revision was automatically updated to reflect the committed changes.
inglorion marked an inline comment as done.
Closed by commit rL366127: [clang] allow -fthinlto-index= without -x ir (authored by inglorion, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64610?vs=209948&id=209952#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64610/new/

https://reviews.llvm.org/D64610

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/thinlto_backend.c


Index: cfe/trunk/lib/Driver/Driver.cpp
===================================================================
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -2119,6 +2119,12 @@
               Diag(clang::diag::warn_drv_treating_input_as_cxx)
                   << getTypeName(OldTy) << getTypeName(Ty);
           }
+
+          // If running with -fthinlto-index=, extensions that normally identify
+          // native object files actually identify LLVM bitcode files.
+          if (Args.hasArgNoClaim(options::OPT_fthinlto_index_EQ) &&
+              Ty == types::TY_Object)
+            Ty = types::TY_LLVM_BC;
         }
 
         // -ObjC and -ObjC++ override the default language, but only for "source
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -3647,8 +3647,7 @@
 
   if (const Arg *A = Args.getLastArg(options::OPT_fthinlto_index_EQ)) {
     if (!types::isLLVMIR(Input.getType()))
-      D.Diag(diag::err_drv_argument_only_allowed_with) << A->getAsString(Args)
-                                                       << "-x ir";
+      D.Diag(diag::err_drv_arg_requires_bitcode_input) << A->getAsString(Args);
     Args.AddLastArg(CmdArgs, options::OPT_fthinlto_index_EQ);
   }
 
Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -159,6 +159,8 @@
   "cannot read configuration file '%0'">;
 def err_drv_nested_config_file: Error<
   "option '--config' is not allowed inside configuration file">;
+def err_drv_arg_requires_bitcode_input: Error<
+  "option '%0' requires input to be LLVM bitcode">;
 
 def err_target_unsupported_arch
   : Error<"the target architecture '%0' is not supported by the target '%1'">;
Index: cfe/trunk/test/Driver/thinlto_backend.c
===================================================================
--- cfe/trunk/test/Driver/thinlto_backend.c
+++ cfe/trunk/test/Driver/thinlto_backend.c
@@ -2,8 +2,14 @@
 // RUN: llvm-lto -thinlto -o %t %t.o
 
 // -fthinlto_index should be passed to cc1
-// RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc -### 2>&1 | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
+// RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc -### \
+// RUN:     2>&1 | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
 // CHECK-THINLTOBE-ACTION: -fthinlto-index=
+// CHECK-THINLTOBE-ACTION-SAME: {{"?-x"? "?ir"?}}
+
+// Check that this also works without -x ir.
+// RUN: %clang -O2 -o %t1.o %t.o -c -fthinlto-index=%t.thinlto.bc -### 2>&1 \
+// RUN:     | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
 
 // -save-temps should be passed to cc1
 // RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc -save-temps -### 2>&1 | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS -check-prefix=CHECK-SAVE-TEMPS-CWD
@@ -15,5 +21,6 @@
 // CHECK-SAVE-TEMPS-NOT: -emit-llvm-bc
 
 // Ensure clang driver gives the expected error for incorrect input type
-// RUN: not %clang -O2 -o %t1.o %s -c -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
-// CHECK-WARNING: error: invalid argument '-fthinlto-index={{.*}}' only allowed with '-x ir'
+// RUN: not %clang -O2 -o %t1.o %s -c -fthinlto-index=%t.thinlto.bc 2>&1 \
+// RUN:     | FileCheck %s -check-prefix=CHECK-WARNING
+// CHECK-WARNING: error: option '-fthinlto-index={{.*}}' requires input to be LLVM bitcode


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64610.209952.patch
Type: text/x-patch
Size: 3683 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190715/48fecfd8/attachment.bin>


More information about the llvm-commits mailing list