[lld] 259bb61 - [ELF] Fix multiple -mllvm after D70378

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 10:27:11 PDT 2020


Author: Fangrui Song
Date: 2020-09-29T10:26:58-07:00
New Revision: 259bb61c118bd7d15c3329ffb2daa9ceaea7302f

URL: https://github.com/llvm/llvm-project/commit/259bb61c118bd7d15c3329ffb2daa9ceaea7302f
DIFF: https://github.com/llvm/llvm-project/commit/259bb61c118bd7d15c3329ffb2daa9ceaea7302f.diff

LOG: [ELF] Fix multiple -mllvm after D70378

Fixes https://reviews.llvm.org/D70378#2299569 Multiple -mllvm is intended to be supported.

We don't have a proper test for `-plugin-opt=-`. This patch adds the test as well.

Differential Revision: https://reviews.llvm.org/D88461

Added: 
    lld/test/ELF/lto/mllvm.ll

Modified: 
    lld/ELF/Driver.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 8fee30c789ba..5e80385837ce 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -895,7 +895,6 @@ static void parseClangOption(StringRef opt, const Twine &msg) {
   raw_string_ostream os(err);
 
   const char *argv[] = {config->progName.data(), opt.data()};
-  cl::ResetAllOptionOccurrences();
   if (cl::ParseCommandLineOptions(2, argv, "", &os))
     return;
   os.flush();
@@ -1105,6 +1104,8 @@ static void readConfigs(opt::InputArgList &args) {
       error(errPrefix + toString(pat.takeError()));
   }
 
+  cl::ResetAllOptionOccurrences();
+
   // Parse LTO options.
   if (auto *arg = args.getLastArg(OPT_plugin_opt_mcpu_eq))
     parseClangOption(saver.save("-mcpu=" + StringRef(arg->getValue())),

diff  --git a/lld/test/ELF/lto/mllvm.ll b/lld/test/ELF/lto/mllvm.ll
new file mode 100644
index 000000000000..883a9c8d8dc7
--- /dev/null
+++ b/lld/test/ELF/lto/mllvm.ll
@@ -0,0 +1,24 @@
+; REQUIRES: x86
+; RUN: llvm-as %s -o %t.o
+; RUN: ld.lld %t.o -o %t -mllvm -mcpu=znver1 -mllvm -debug-pass=Structure -mllvm -print-after-all 2>&1 | FileCheck %s
+; RUN: llvm-objdump -d -j .text %t | FileCheck %s --check-prefix=DISASM
+
+;; We support -plugin-opt=- for LLVMgold.so compatibility. With a few exceptions,
+;; most -plugin-opt=- prefixed options are passed through to cl::ParseCommandLineOptions.
+; RUN: ld.lld %t.o -o %t -plugin-opt=-debug-pass=Structure -plugin-opt=-print-after-all 2>&1 | FileCheck %s
+
+; CHECK: Pass Arguments:
+; CHECK: # *** IR Dump
+
+; DISASM: nopw
+
+target triple = "x86_64-unknown-linux-gnu"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @_start() #0 {
+entry:
+  call void asm sideeffect ".p2align 4, 0x90", "~{dirflag},~{fpsr},~{flags}"()
+  ret void
+}
+
+attributes #0 = { "frame-pointer"="all" }


        


More information about the llvm-commits mailing list