diff options
author | Yi Kong <yikong@google.com> | 2019-02-27 14:17:58 -0800 |
---|---|---|
committer | Yi Kong <yikong@google.com> | 2019-02-27 14:17:58 -0800 |
commit | 8a56a06ed4d2858cb4e442942f2620b3dec172c2 (patch) | |
tree | a277ed824e0b7eb20ca8ec7cfb2aba5d21aaf235 | |
parent | 08b26c8bfe46241b0ff60f0e25c0cb2e620b6adf (diff) | |
download | clang-8a56a06ed4d2858cb4e442942f2620b3dec172c2.tar.gz |
revert to previous base llvm-svn.349610
Change-Id: I225d988d276b86df0845f26abe5865f434b7505d
-rw-r--r-- | include/clang/Basic/CodeGenOptions.def | 2 | ||||
-rw-r--r-- | lib/CodeGen/BackendUtil.cpp | 45 | ||||
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 2 | ||||
-rw-r--r-- | lib/Driver/ToolChains/Arch/ARM.cpp | 2 | ||||
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 4 | ||||
-rw-r--r-- | test/CodeGen/emit-summary-index.c | 17 | ||||
-rw-r--r-- | test/CodeGen/lto-newpm-pipeline.c | 1 | ||||
-rw-r--r-- | test/Driver/arm-float-abi.c | 10 | ||||
-rw-r--r-- | test/Misc/thinlto.c | 4 |
9 files changed, 56 insertions, 31 deletions
diff --git a/include/clang/Basic/CodeGenOptions.def b/include/clang/Basic/CodeGenOptions.def index 2339bc1472..952aa588b6 100644 --- a/include/clang/Basic/CodeGenOptions.def +++ b/include/clang/Basic/CodeGenOptions.def @@ -112,7 +112,7 @@ CODEGENOPT(LessPreciseFPMAD , 1, 0) ///< Enable less precise MAD instructions t ///< be generated. CODEGENOPT(PrepareForLTO , 1, 0) ///< Set when -flto is enabled on the ///< compile step. -CODEGENOPT(EmitSummaryIndex, 1, 0) ///< Set when -flto=thin is enabled on the +CODEGENOPT(PrepareForThinLTO , 1, 0) ///< Set when -flto=thin is enabled on the ///< compile step. CODEGENOPT(LTOUnit, 1, 0) ///< Emit IR to support LTO unit features (CFI, whole ///< program vtable opt). diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index aa8aec73be..52fc08de9b 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/lib/CodeGen/BackendUtil.cpp @@ -542,7 +542,7 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM, PMBuilder.Inliner = createFunctionInliningPass( CodeGenOpts.OptimizationLevel, CodeGenOpts.OptimizeSize, (!CodeGenOpts.SampleProfileFile.empty() && - CodeGenOpts.EmitSummaryIndex)); + CodeGenOpts.PrepareForThinLTO)); } PMBuilder.OptLevel = CodeGenOpts.OptimizationLevel; @@ -552,7 +552,7 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM, PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops; PMBuilder.MergeFunctions = CodeGenOpts.MergeFunctions; - PMBuilder.PrepareForThinLTO = CodeGenOpts.EmitSummaryIndex; + PMBuilder.PrepareForThinLTO = CodeGenOpts.PrepareForThinLTO; PMBuilder.PrepareForLTO = CodeGenOpts.PrepareForLTO; PMBuilder.RerollLoops = CodeGenOpts.RerollLoops; @@ -806,7 +806,7 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action, break; case Backend_EmitBC: - if (CodeGenOpts.EmitSummaryIndex && !CodeGenOpts.DisableLLVMPasses) { + if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) { if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) { ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile); if (!ThinLinkOS) @@ -814,10 +814,21 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action, } PerModulePasses.add(createWriteThinLTOBitcodePass( *OS, ThinLinkOS ? &ThinLinkOS->os() : nullptr)); - } - else + } else { + // Emit a module summary by default for Regular LTO except for ld64 + // targets + bool EmitLTOSummary = + (CodeGenOpts.PrepareForLTO && + !CodeGenOpts.DisableLLVMPasses && + llvm::Triple(TheModule->getTargetTriple()).getVendor() != + llvm::Triple::Apple); + if (EmitLTOSummary && !TheModule->getModuleFlag("ThinLTO")) + TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0)); + PerModulePasses.add( - createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists)); + createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists, + EmitLTOSummary)); + } break; case Backend_EmitLL: @@ -969,7 +980,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager( ModulePassManager MPM(CodeGenOpts.DebugPassManager); if (!CodeGenOpts.DisableLLVMPasses) { - bool IsThinLTO = CodeGenOpts.EmitSummaryIndex; + bool IsThinLTO = CodeGenOpts.PrepareForThinLTO; bool IsLTO = CodeGenOpts.PrepareForLTO; if (CodeGenOpts.OptimizationLevel == 0) { @@ -984,8 +995,8 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager( if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds)) MPM.addPass(createModuleToFunctionPassAdaptor(BoundsCheckingPass())); - // Lastly, add a semantically necessary pass for ThinLTO. - if (IsThinLTO) + // Lastly, add a semantically necessary pass for LTO. + if (IsLTO || IsThinLTO) MPM.addPass(NameAnonGlobalPass()); } else { // Map our optimization levels into one of the distinct levels used to @@ -1011,6 +1022,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager( } else if (IsLTO) { MPM = PB.buildLTOPreLinkDefaultPipeline(Level, CodeGenOpts.DebugPassManager); + MPM.addPass(NameAnonGlobalPass()); } else { MPM = PB.buildPerModuleDefaultPipeline(Level, CodeGenOpts.DebugPassManager); @@ -1030,7 +1042,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager( break; case Backend_EmitBC: - if (CodeGenOpts.EmitSummaryIndex && !CodeGenOpts.DisableLLVMPasses) { + if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) { if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) { ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile); if (!ThinLinkOS) @@ -1039,9 +1051,18 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager( MPM.addPass(ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &ThinLinkOS->os() : nullptr)); } else { + // Emit a module summary by default for Regular LTO except for ld64 + // targets + bool EmitLTOSummary = + (CodeGenOpts.PrepareForLTO && + !CodeGenOpts.DisableLLVMPasses && + llvm::Triple(TheModule->getTargetTriple()).getVendor() != + llvm::Triple::Apple); + if (EmitLTOSummary && !TheModule->getModuleFlag("ThinLTO")) + TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0)); + MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists, - CodeGenOpts.EmitSummaryIndex, - CodeGenOpts.EmitSummaryIndex)); + EmitLTOSummary)); } break; diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index a4f0e218a3..f3a07a30eb 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -609,7 +609,7 @@ void CGDebugInfo::CreateCompileUnit() { // Create new compile unit. TheCU = DBuilder.createCompileUnit( LangTag, CUFile, CGOpts.EmitVersionIdentMetadata ? Producer : "", - LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex, + LO.Optimize || CGOpts.PrepareForLTO || CGOpts.PrepareForThinLTO, CGOpts.DwarfDebugFlags, RuntimeVers, (CGOpts.getSplitDwarfMode() != CodeGenOptions::NoFission) ? "" diff --git a/lib/Driver/ToolChains/Arch/ARM.cpp b/lib/Driver/ToolChains/Arch/ARM.cpp index 653971a4a0..f55efc1a22 100644 --- a/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/lib/Driver/ToolChains/Arch/ARM.cpp @@ -249,7 +249,7 @@ arm::FloatABI arm::getARMFloatABI(const ToolChain &TC, const ArgList &Args) { ABI = FloatABI::SoftFP; break; case llvm::Triple::Android: - ABI = (SubArch >= 7) ? FloatABI::SoftFP : FloatABI::Soft; + ABI = (SubArch == 7) ? FloatABI::SoftFP : FloatABI::Soft; break; default: // Assume "soft", but warn the user we are guessing. diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 8144a55917..220cad2738 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -897,11 +897,11 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, Opts.ProfileSampleAccurate = Args.hasArg(OPT_fprofile_sample_accurate); Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ); - Opts.EmitSummaryIndex = false; + Opts.PrepareForThinLTO = false; if (Arg *A = Args.getLastArg(OPT_flto_EQ)) { StringRef S = A->getValue(); if (S == "thin") - Opts.EmitSummaryIndex = true; + Opts.PrepareForThinLTO = true; else if (S != "full") Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << S; } diff --git a/test/CodeGen/emit-summary-index.c b/test/CodeGen/emit-summary-index.c new file mode 100644 index 0000000000..6126410206 --- /dev/null +++ b/test/CodeGen/emit-summary-index.c @@ -0,0 +1,17 @@ +// ; Check that the -flto=thin option emits a ThinLTO summary +// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-bcanalyzer -dump | FileCheck %s +// CHECK: <GLOBALVAL_SUMMARY_BLOCK +// +// ; Check that we do not emit a summary for regular LTO on Apple platforms +// RUN: %clang_cc1 -flto -triple x86_64-apple-darwin -emit-llvm-bc < %s | llvm-bcanalyzer -dump | FileCheck --check-prefix=LTO %s +// LTO-NOT: GLOBALVAL_SUMMARY_BLOCK +// +// ; Check that we emit a summary for regular LTO by default elsewhere +// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-bcanalyzer -dump | FileCheck --check-prefix=LTOINDEX %s +// LTOINDEX: <FULL_LTO_GLOBALVAL_SUMMARY_BLOCK +// +// ; Simulate -save-temps and check that it works (!"ThinLTO" module flag not added multiple times) +// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc -disable-llvm-passes < %s -o %t.bc +// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc -x ir < %t.bc | llvm-bcanalyzer -dump | FileCheck --check-prefix=LTOINDEX %s + +int main() {} diff --git a/test/CodeGen/lto-newpm-pipeline.c b/test/CodeGen/lto-newpm-pipeline.c index 10112da6d5..137c46c964 100644 --- a/test/CodeGen/lto-newpm-pipeline.c +++ b/test/CodeGen/lto-newpm-pipeline.c @@ -27,6 +27,7 @@ // CHECK-FULL-O0: Starting llvm::Module pass manager run. // CHECK-FULL-O0: Running pass: AlwaysInlinerPass +// CHECK-FULL-O0-NEXT: Running pass: NameAnonGlobalPass // CHECK-FULL-O0-NEXT: Running pass: BitcodeWriterPass // CHECK-FULL-O0: Finished llvm::Module pass manager run. diff --git a/test/Driver/arm-float-abi.c b/test/Driver/arm-float-abi.c index 9a76d1ee39..e5b42c9696 100644 --- a/test/Driver/arm-float-abi.c +++ b/test/Driver/arm-float-abi.c @@ -4,13 +4,3 @@ // ARMV7-ERROR: unsupported option '-mfloat-abi=hard' for target 'thumbv7' // NOERROR-NOT: unsupported option - -// RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \ -// RUN: | FileCheck --check-prefix=CHECK-ARM7-ANDROID %s -// CHECK-ARM7-ANDROID-NOT: "-target-feature" "+soft-float" -// CHECK-ARM7-ANDROID: "-target-feature" "+soft-float-abi" - -// RUN: %clang -target armv8-linux-androideabi21 %s -### -c 2>&1 \ -// RUN: | FileCheck --check-prefix=CHECK-ARM8-ANDROID %s -// CHECK-ARM8-ANDROID-NOT: "-target-feature" "+soft-float" -// CHECK-ARM8-ANDROID: "-target-feature" "+soft-float-abi" diff --git a/test/Misc/thinlto.c b/test/Misc/thinlto.c deleted file mode 100644 index ec0f03f5a2..0000000000 --- a/test/Misc/thinlto.c +++ /dev/null @@ -1,4 +0,0 @@ -// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-bcanalyzer -dump | FileCheck %s -// ; Check that the -flto=thin option emits a summary -// CHECK: <GLOBALVAL_SUMMARY_BLOCK -int main() {} |