llvm.org GIT mirror llvm / b4067a0
Revert "ThinLTO: Verify bitcode before lauching the ThinLTOCodeGenerator." This reverts commit r303438 while deliberating buildbot breakage. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303467 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian Prantl 2 years ago
6 changed file(s) with 7 addition(s) and 102 deletion(s). Raw diff Collapse all Expand all
5252 : Index(Index), ModuleLoader(std::move(ModuleLoader)) {}
5353
5454 /// Import functions in Module \p M based on the supplied import list.
55 Expected importFunctions(
56 Module &M, const ImportMapTy &ImportList,
57 Optional> PostBitcodeLoading = None);
55 Expected
56 importFunctions(Module &M, const ImportMapTy &ImportList);
5857
5958 private:
6059 /// The summaries index used to trigger importing.
2424 #include "llvm/Bitcode/BitcodeWriterPass.h"
2525 #include "llvm/ExecutionEngine/ObjectMemoryBuffer.h"
2626 #include "llvm/IR/DiagnosticPrinter.h"
27 #include "llvm/IR/DebugInfo.h"
2827 #include "llvm/IR/LLVMContext.h"
2928 #include "llvm/IR/LegacyPassManager.h"
3029 #include "llvm/IR/Mangler.h"
31 #include "llvm/IR/Verifier.h"
3230 #include "llvm/IRReader/IRReader.h"
3331 #include "llvm/LTO/LTO.h"
3432 #include "llvm/Linker/Linker.h"
6361 extern cl::opt LTODiscardValueNames;
6462 extern cl::opt LTORemarksFilename;
6563 extern cl::opt LTOPassRemarksWithHotness;
66 extern cl::opt LTOStripInvalidDebugInfo;
6764 }
6865
6966 namespace {
144141 report_fatal_error("renameModuleForThinLTO failed");
145142 }
146143
147 namespace {
148 class ThinLTODiagnosticInfo : public DiagnosticInfo {
149 const Twine &Msg;
150 public:
151 ThinLTODiagnosticInfo(const Twine &DiagMsg,
152 DiagnosticSeverity Severity = DS_Error)
153 : DiagnosticInfo(DK_Linker, Severity), Msg(DiagMsg) {}
154 void print(DiagnosticPrinter &DP) const override { DP << Msg; }
155 };
156 }
157
158 /// Verify the module and strip broken debug info.
159 static void verifyLoadedModule(Module &TheModule) {
160 bool BrokenDebugInfo = false;
161 if (verifyModule(TheModule, &dbgs(),
162 LTOStripInvalidDebugInfo ? &BrokenDebugInfo : nullptr))
163 report_fatal_error("Broken module found, compilation aborted!");
164 if (BrokenDebugInfo) {
165 TheModule.getContext().diagnose(ThinLTODiagnosticInfo(
166 "Invalid debug info found, debug info will be stripped", DS_Warning));
167 StripDebugInfo(TheModule);
168 }
169 }
170
171144 static std::unique_ptr
172145 loadModuleFromBuffer(const MemoryBufferRef &Buffer, LLVMContext &Context,
173146 bool Lazy, bool IsImporting) {
185158 });
186159 report_fatal_error("Can't load module, abort.");
187160 }
188 if (!Lazy)
189 verifyLoadedModule(*ModuleOrErr.get());
190161 return std::move(ModuleOrErr.get());
191162 }
192163
200171 };
201172
202173 FunctionImporter Importer(Index, Loader);
203 Expected Result =
204 Importer.importFunctions(TheModule, ImportList, {verifyLoadedModule});
174 Expected Result = Importer.importFunctions(TheModule, ImportList);
205175 if (!Result) {
206176 handleAllErrors(Result.takeError(), [&](ErrorInfoBase &EIB) {
207177 SMDiagnostic Err = SMDiagnostic(TheModule.getModuleIdentifier(),
224194 PMB.OptLevel = OptLevel;
225195 PMB.LoopVectorize = true;
226196 PMB.SLPVectorize = true;
227 // Already did this in verifyLoadedModule().
228 PMB.VerifyInput = false;
197 PMB.VerifyInput = true;
229198 PMB.VerifyOutput = false;
230199
231200 legacy::PassManager PM;
645645 // index.
646646 //
647647 Expected FunctionImporter::importFunctions(
648 Module &DestModule, const FunctionImporter::ImportMapTy &ImportList,
649 Optional> PostBitcodeLoading) {
648 Module &DestModule, const FunctionImporter::ImportMapTy &ImportList) {
650649 DEBUG(dbgs() << "Starting import for Module "
651650 << DestModule.getModuleIdentifier() << "\n");
652651 unsigned ImportedCount = 0;
754753 // Upgrade debug info after we're done materializing all the globals and we
755754 // have loaded all the required metadata!
756755 UpgradeDebugInfo(*SrcModule);
757 if (PostBitcodeLoading)
758 (*PostBitcodeLoading)(*SrcModule);
759756
760757 // Link in the specified functions.
761758 if (renameModuleForThinLTO(*SrcModule, Index, &GlobalsToImport))
+0
-15
test/LTO/X86/Inputs/strip-debug-info-bar.ll less more
None target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
1 target triple = "x86_64-apple-macosx10.12"
2
3 define void @bar() !dbg !3 {
4 ret void
5 }
6
7 !llvm.module.flags = !{!0}
8 !llvm.dbg.cu = !{!1}
9
10 !0 = !{i32 2, !"Debug Info Version", i32 3}
11 !1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2)
12 !2 = !DIFile(filename: "broken", directory: "")
13 !3 = distinct !DISubprogram(line: 1000, isDefinition: true)
14
None ; RUN: llvm-as -disable-verify %s -o %t.bc
1 ; ---- Full LTO ---------------------------------------------
2 ; RUN: not llvm-lto -lto-strip-invalid-debug-info=false \
3 ; RUN: -o %t.o %t.bc 2>&1 | \
1 ; RUN: -o %t.o %S/Inputs/strip-debug-info.bc 2>&1 | \
42 ; RUN: FileCheck %s -allow-empty -check-prefix=CHECK-ERR
53 ; RUN: llvm-lto -lto-strip-invalid-debug-info=true \
64 ; RUN: -exported-symbol foo -exported-symbol _foo \
7 ; RUN: -o %t.o %t.bc 2>&1 | \
5 ; RUN: -o %t.o %S/Inputs/strip-debug-info.bc 2>&1 | \
86 ; RUN: FileCheck %s -allow-empty -check-prefix=CHECK-WARN
97 ; RUN: llvm-nm %t.o | FileCheck %s
10 ; ---- Thin LTO (codegen only) ------------------------------
11 ; RUN: not llvm-lto -thinlto -thinlto-action=codegen \
12 ; RUN: -lto-strip-invalid-debug-info=false \
13 ; RUN: %t.bc -disable-verify 2>&1 | \
14 ; RUN: FileCheck %s -allow-empty -check-prefix=CHECK-ERR
15 ; RUN: llvm-lto -thinlto -thinlto-action=codegen \
16 ; RUN: -lto-strip-invalid-debug-info=true \
17 ; RUN: %t.bc -disable-verify 2>&1 | \
18 ; RUN: FileCheck %s -allow-empty -check-prefix=CHECK-WARN
19 ; ---- Thin LTO (optimize, strip main file) -----------------
20 ; RUN: opt -disable-verify -module-summary %s -o %t.bc
21 ; RUN: opt -disable-verify -module-summary %S/Inputs/strip-debug-info-bar.ll \
22 ; RUN: -o %t2.bc
23 ; RUN: not llvm-lto -thinlto -thinlto-action=run \
24 ; RUN: -lto-strip-invalid-debug-info=false \
25 ; RUN: %t.bc -disable-verify 2>&1 | \
26 ; RUN: FileCheck %s -allow-empty -check-prefix=CHECK-ERR
27 ; RUN: llvm-lto -thinlto -thinlto-action=run \
28 ; RUN: -lto-strip-invalid-debug-info=true \
29 ; RUN: %t.bc -disable-verify 2>&1 | \
30 ; RUN: FileCheck %s -allow-empty -check-prefix=CHECK-WARN
31 ; ---- Thin LTO (optimize, strip imported file) -------------
32 ; RUN: opt -disable-verify -strip-debug -module-summary %t.bc -o %t-stripped.bc
33 ; RUN: llvm-lto -thinlto-action=thinlink -o %t.index.bc %t-stripped.bc %t2.bc
34 ; RUN: not llvm-lto -thinlto -thinlto-action=import \
35 ; RUN: -thinlto-index=%t.index.bc \
36 ; RUN: -lto-strip-invalid-debug-info=false \
37 ; RUN: -exported-symbol foo -exported-symbol _foo \
38 ; RUN: %t-stripped.bc -disable-verify 2>&1 | \
39 ; RUN: FileCheck %s -allow-empty -check-prefix=CHECK-ERR
40 ; RUN: llvm-lto -thinlto -thinlto-action=import \
41 ; RUN: -lto-strip-invalid-debug-info=true \
42 ; RUN: -thinlto-index=%t.index.bc \
43 ; RUN: -exported-symbol foo -exported-symbol _foo \
44 ; RUN: %t-stripped.bc -disable-verify 2>&1 | \
45 ; RUN: FileCheck %s -allow-empty -check-prefix=CHECK-WARN
468
479 ; CHECK-ERR: Broken module found, compilation aborted
4810 ; CHECK-WARN: Invalid debug info found, debug info will be stripped
49 ; CHECK-WARN-NOT: Broken module found
5011 ; CHECK: foo
51 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
52 target triple = "x86_64-apple-macosx10.12"
53
54 declare void @bar()
55
5612 define void @foo() {
57 call void @bar()
5813 ret void
5914 }
6015