[lld] r324459 - [ELF] - Allow set CPU string with -plugin-opt=mcpu=<xxx>

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 7 00:50:36 PST 2018


Author: grimar
Date: Wed Feb  7 00:50:36 2018
New Revision: 324459

URL: http://llvm.org/viewvc/llvm-project?rev=324459&view=rev
Log:
[ELF] - Allow set CPU string with -plugin-opt=mcpu=<xxx>

Previously we ignored -plugin-opt=mcpu=<xxx>
and the only way to set CPU string was to pass
-mllvm -mcpu=<xxx>
Though clang may pass it with use of plugin options:
-plugin-opt=mcpu=x86-64
Since we are trying to be compatible in command line
with gold plugin, seems we should support it too.

Differential revision: https://reviews.llvm.org/D42956

Modified:
    lld/trunk/ELF/Driver.cpp
    lld/trunk/test/ELF/lto-plugin-ignore.s
    lld/trunk/test/ELF/lto/cpu-string.ll

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=324459&r1=324458&r2=324459&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Wed Feb  7 00:50:36 2018
@@ -703,9 +703,10 @@ void LinkerDriver::readConfigs(opt::Inpu
       Config->LTOPartitions = parseInt(S.substr(15), Arg);
     else if (S.startswith("jobs="))
       Config->ThinLTOJobs = parseInt(S.substr(5), Arg);
+    else if (S.startswith("mcpu="))
+      LTOOptions.push_back(Saver.save("-" + S).data());
     else if (!S.startswith("/") && !S.startswith("-fresolution=") &&
-             !S.startswith("-pass-through=") && !S.startswith("mcpu=") &&
-             !S.startswith("thinlto"))
+             !S.startswith("-pass-through=") && !S.startswith("thinlto"))
       LTOOptions.push_back(S.data());
   }
   // Parse and evaluate -mllvm options.

Modified: lld/trunk/test/ELF/lto-plugin-ignore.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto-plugin-ignore.s?rev=324459&r1=324458&r2=324459&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto-plugin-ignore.s (original)
+++ lld/trunk/test/ELF/lto-plugin-ignore.s Wed Feb  7 00:50:36 2018
@@ -3,8 +3,7 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
 # RUN: ld.lld %t -plugin-opt=/foo/bar -plugin-opt=-fresolution=zed \
 # RUN:   -plugin-opt=-pass-through=-lgcc -plugin-opt=-function-sections \
-# RUN:   -plugin-opt=-data-sections -plugin-opt=mcpu=x86-64 \
-# RUN:   -plugin-opt=thinlto -o /dev/null
+# RUN:   -plugin-opt=-data-sections -plugin-opt=thinlto -o /dev/null
 
 # RUN: not ld.lld %t -plugin-opt=-data-sectionxxx \
 # RUN:   -plugin-opt=-function-sectionxxx 2>&1 | FileCheck %s

Modified: lld/trunk/test/ELF/lto/cpu-string.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/cpu-string.ll?rev=324459&r1=324458&r2=324459&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/cpu-string.ll (original)
+++ lld/trunk/test/ELF/lto/cpu-string.ll Wed Feb  7 00:50:36 2018
@@ -3,14 +3,16 @@
 
 ; RUN: ld.lld %t.o -o %t.so -shared
 ; RUN: llvm-objdump -d -section=".text" -no-leading-addr -no-show-raw-insn %t.so | FileCheck %s
+; CHECK: nop{{$}}
 
 ; RUN: ld.lld -mllvm -mcpu=znver1 %t.o -o %t.znver1.so -shared
 ; RUN: llvm-objdump -d -section=".text" -no-leading-addr -no-show-raw-insn %t.znver1.so | FileCheck -check-prefix=ZNVER1 %s
-
-; CHECK: nop{{$}}
-
 ; ZNVER1: nopw
 
+; Check we are able to use -plugin-opt=mcpu=<CPU> to set CPU string.
+; RUN: ld.lld -plugin-opt=mcpu=znver1 %t.o -o %t.znver1.so -shared
+; RUN: llvm-objdump -d -section=".text" -no-leading-addr -no-show-raw-insn %t.znver1.so | FileCheck -check-prefix=ZNVER1 %s
+
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 




More information about the llvm-commits mailing list