Set MAttrs in LTO mode

Summary: Without this patch, MAttrs are not set.

Patch by Yin Ma

Reviewers: espindola, MaskRay, ruiu, pcc

Reviewed By: MaskRay, pcc

Subscribers: pcc, emaste, sbc100, inglorion, arichardson, aheejin, steven_wu, llvm-commits

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

llvm-svn: 345884
This commit is contained in:
Fangrui Song 2018-11-01 20:02:49 +00:00
parent 4af6025f09
commit ccfc8415c2
5 changed files with 6 additions and 0 deletions

View File

@ -60,6 +60,8 @@ static std::unique_ptr<lto::LTO> createLTO() {
C.DisableVerify = true;
C.DiagHandler = diagnosticHandler;
C.OptLevel = Config->LTOO;
C.MAttrs = GetMAttrs();
if (Config->SaveTemps)
checkError(C.addSaveTemps(std::string(Config->OutputFile) + ".",
/*UseInputModulePath*/ true));

View File

@ -32,3 +32,4 @@ llvm::Optional<llvm::CodeModel::Model> lld::GetCodeModelFromCMModel() {
}
std::string lld::GetCPUStr() { return ::getCPUStr(); }
std::vector<std::string> lld::GetMAttrs() { return ::MAttrs; }

View File

@ -88,6 +88,7 @@ static lto::Config createConfig() {
C.DiagHandler = diagnosticHandler;
C.OptLevel = Config->LTOO;
C.CPU = GetCPUStr();
C.MAttrs = GetMAttrs();
// Set up a custom pipeline if we've been asked to.
C.OptPipeline = Config->LTONewPmPasses;

View File

@ -19,4 +19,5 @@ namespace lld {
llvm::TargetOptions InitTargetOptionsFromCodeGenFlags();
llvm::Optional<llvm::CodeModel::Model> GetCodeModelFromCMModel();
std::string GetCPUStr();
std::vector<std::string> GetMAttrs();
}

View File

@ -55,6 +55,7 @@ static std::unique_ptr<lto::LTO> createLTO() {
C.DisableVerify = Config->DisableVerify;
C.DiagHandler = diagnosticHandler;
C.OptLevel = Config->LTOO;
C.MAttrs = GetMAttrs();
if (Config->SaveTemps)
checkError(C.addSaveTemps(Config->OutputFile.str() + ".",