[PATCH] D42956: [ELF] - Allow set CPU string with -plugin-opt=mcpu=<xxx>

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 6 08:41:52 PST 2018


LGTM

Thanks,
Rafael

George Rimar via Phabricator <reviews at reviews.llvm.org> writes:

> grimar created this revision.
> grimar added reviewers: ruiu, espindola.
> Herald added a subscriber: emaste.
>
> 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.
>
>
> https://reviews.llvm.org/D42956
>
> Files:
>   ELF/Driver.cpp
>   test/ELF/lto-plugin-ignore.s
>   test/ELF/lto/cpu-string.ll
>
>
> Index: test/ELF/lto-plugin-ignore.s
> ===================================================================
> --- test/ELF/lto-plugin-ignore.s
> +++ test/ELF/lto-plugin-ignore.s
> @@ -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
> Index: test/ELF/lto/cpu-string.ll
> ===================================================================
> --- test/ELF/lto/cpu-string.ll
> +++ test/ELF/lto/cpu-string.ll
> @@ -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"
>  
> Index: ELF/Driver.cpp
> ===================================================================
> --- ELF/Driver.cpp
> +++ ELF/Driver.cpp
> @@ -703,9 +703,10 @@
>        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.
>
>
> Index: test/ELF/lto-plugin-ignore.s
> ===================================================================
> --- test/ELF/lto-plugin-ignore.s
> +++ test/ELF/lto-plugin-ignore.s
> @@ -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
> Index: test/ELF/lto/cpu-string.ll
> ===================================================================
> --- test/ELF/lto/cpu-string.ll
> +++ test/ELF/lto/cpu-string.ll
> @@ -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"
>  
> Index: ELF/Driver.cpp
> ===================================================================
> --- ELF/Driver.cpp
> +++ ELF/Driver.cpp
> @@ -703,9 +703,10 @@
>        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.


More information about the llvm-commits mailing list