diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2018-01-30 18:18:59 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2018-01-30 18:18:59 +0000 |
commit | 3a730d8582d8e93c432c953dbf6940aa127ce8bc (patch) | |
tree | b3f80769693461464fe38e8a5ef603704d48a3cd | |
parent | cb6422dcc124f4f50262e14fa1a63cac7af72967 (diff) | |
download | bcm5719-llvm-3a730d8582d8e93c432c953dbf6940aa127ce8bc.tar.gz bcm5719-llvm-3a730d8582d8e93c432c953dbf6940aa127ce8bc.zip |
Pass CPU string to LTO pipeline.
Previously an empty CPU string was passed to the LTO engine which
resulted in a generic CPU for which certain features like NOPL were
disabled. This fixes that.
Patch by Pratik Bhatu!
llvm-svn: 323801
-rw-r--r-- | lld/Common/TargetOptionsCommandFlags.cpp | 2 | ||||
-rw-r--r-- | lld/ELF/LTO.cpp | 1 | ||||
-rw-r--r-- | lld/include/lld/Common/TargetOptionsCommandFlags.h | 1 | ||||
-rw-r--r-- | lld/test/ELF/lto/cpu-string.ll | 23 |
4 files changed, 27 insertions, 0 deletions
diff --git a/lld/Common/TargetOptionsCommandFlags.cpp b/lld/Common/TargetOptionsCommandFlags.cpp index e8e582f4c25..2d6819bba42 100644 --- a/lld/Common/TargetOptionsCommandFlags.cpp +++ b/lld/Common/TargetOptionsCommandFlags.cpp @@ -30,3 +30,5 @@ llvm::TargetOptions lld::InitTargetOptionsFromCodeGenFlags() { llvm::Optional<llvm::CodeModel::Model> lld::GetCodeModelFromCMModel() { return getCodeModel(); } + +std::string lld::GetCPUStr() { return ::getCPUStr(); } diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp index 03628fa70bb..3710bef345e 100644 --- a/lld/ELF/LTO.cpp +++ b/lld/ELF/LTO.cpp @@ -87,6 +87,7 @@ static std::unique_ptr<lto::LTO> createLTO() { Conf.DisableVerify = Config->DisableVerify; Conf.DiagHandler = diagnosticHandler; Conf.OptLevel = Config->LTOO; + Conf.CPU = GetCPUStr(); // Set up a custom pipeline if we've been asked to. Conf.OptPipeline = Config->LTONewPmPasses; diff --git a/lld/include/lld/Common/TargetOptionsCommandFlags.h b/lld/include/lld/Common/TargetOptionsCommandFlags.h index 9c4ff7cea3f..8443b184aa7 100644 --- a/lld/include/lld/Common/TargetOptionsCommandFlags.h +++ b/lld/include/lld/Common/TargetOptionsCommandFlags.h @@ -18,4 +18,5 @@ namespace lld { llvm::TargetOptions InitTargetOptionsFromCodeGenFlags(); llvm::Optional<llvm::CodeModel::Model> GetCodeModelFromCMModel(); +std::string GetCPUStr(); } diff --git a/lld/test/ELF/lto/cpu-string.ll b/lld/test/ELF/lto/cpu-string.ll new file mode 100644 index 00000000000..7ce34055a64 --- /dev/null +++ b/lld/test/ELF/lto/cpu-string.ll @@ -0,0 +1,23 @@ +; REQUIRES: x86 +; RUN: llvm-as %s -o %t.o + +; 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 + +; RUN: ld.lld -mllvm -mcpu=znver1 %t.o -o %m.so -shared +; RUN: llvm-objdump -d -section=".text" -no-leading-addr -no-show-raw-insn %m.so | FileCheck -check-prefix=ZNVER1 %s + +; CHECK: nop{{$}} + +; ZNVER1: nopw + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define void @foo() #0 { +entry: + call void asm sideeffect ".p2align 4, 0x90", "~{dirflag},~{fpsr},~{flags}"() + ret void +} + +attributes #0 = { "no-frame-pointer-elim"="true" } |