Skip to content

Commit c15d60b

Browse files
committed
Object: Remove ModuleSummaryIndexObjectFile class.
Differential Revision: https://reviews.llvm.org/D32195 llvm-svn: 301832
1 parent ba6c9cb commit c15d60b

File tree

13 files changed

+35
-261
lines changed

13 files changed

+35
-261
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include "llvm/LTO/LTOBackend.h"
3636
#include "llvm/MC/MCAsmInfo.h"
3737
#include "llvm/MC/SubtargetFeature.h"
38-
#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
3938
#include "llvm/Passes/PassBuilder.h"
4039
#include "llvm/Support/CommandLine.h"
4140
#include "llvm/Support/MemoryBuffer.h"

llvm/include/llvm/Bitcode/BitcodeReader.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ namespace llvm {
141141
Expected<std::unique_ptr<ModuleSummaryIndex>>
142142
getModuleSummaryIndex(MemoryBufferRef Buffer);
143143

144+
/// Parse the module summary index out of an IR file and return the module
145+
/// summary index object if found, or an empty summary if not. If Path refers
146+
/// to an empty file and the -ignore-empty-index-file cl::opt flag is passed
147+
/// this function will return nullptr.
148+
Expected<std::unique_ptr<ModuleSummaryIndex>>
149+
getModuleSummaryIndexForFile(StringRef Path);
150+
144151
/// isBitcodeWrapper - Return true if the given bytes are the magic bytes
145152
/// for an LLVM IR bitcode wrapper.
146153
///

llvm/include/llvm/Object/Binary.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class Binary {
4242
ID_MachOUniversalBinary,
4343
ID_COFFImportFile,
4444
ID_IR, // LLVM IR
45-
ID_ModuleSummaryIndex, // Module summary index
4645

4746
// Object and children.
4847
ID_StartObjects,
@@ -128,8 +127,6 @@ class Binary {
128127
return TypeID == ID_IR;
129128
}
130129

131-
bool isModuleSummaryIndex() const { return TypeID == ID_ModuleSummaryIndex; }
132-
133130
bool isLittleEndian() const {
134131
return !(TypeID == ID_ELF32B || TypeID == ID_ELF64B ||
135132
TypeID == ID_MachO32B || TypeID == ID_MachO64B);

llvm/include/llvm/Object/ModuleSummaryIndexObjectFile.h

Lines changed: 0 additions & 112 deletions
This file was deleted.

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ static cl::opt<bool> PrintSummaryGUIDs(
9393
cl::desc(
9494
"Print the global id for each value when reading the module summary"));
9595

96+
// FIXME: This flag should either be removed or moved to clang as a driver flag.
97+
static llvm::cl::opt<bool> IgnoreEmptyThinLTOIndexFile(
98+
"ignore-empty-index-file", llvm::cl::ZeroOrMore,
99+
llvm::cl::desc(
100+
"Ignore an empty index file and perform non-ThinLTO compilation"),
101+
llvm::cl::init(false));
102+
96103
namespace {
97104

98105
enum {
@@ -5609,3 +5616,14 @@ Expected<bool> llvm::hasGlobalValueSummary(MemoryBufferRef Buffer) {
56095616

56105617
return BM->hasSummary();
56115618
}
5619+
5620+
Expected<std::unique_ptr<ModuleSummaryIndex>>
5621+
llvm::getModuleSummaryIndexForFile(StringRef Path) {
5622+
ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr =
5623+
MemoryBuffer::getFileOrSTDIN(Path);
5624+
if (!FileOrErr)
5625+
return errorCodeToError(FileOrErr.getError());
5626+
if (IgnoreEmptyThinLTOIndexFile && !(*FileOrErr)->getBufferSize())
5627+
return nullptr;
5628+
return getModuleSummaryIndex(**FileOrErr);
5629+
}

llvm/lib/LTO/LTO.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "llvm/LTO/LTOBackend.h"
2626
#include "llvm/Linker/IRMover.h"
2727
#include "llvm/Object/IRObjectFile.h"
28-
#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
2928
#include "llvm/Support/Error.h"
3029
#include "llvm/Support/ManagedStatic.h"
3130
#include "llvm/Support/MemoryBuffer.h"

llvm/lib/LTO/ThinLTOCodeGenerator.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "llvm/Linker/Linker.h"
3434
#include "llvm/MC/SubtargetFeature.h"
3535
#include "llvm/Object/IRObjectFile.h"
36-
#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
3736
#include "llvm/Support/CachePruning.h"
3837
#include "llvm/Support/Debug.h"
3938
#include "llvm/Support/Error.h"
@@ -569,21 +568,19 @@ std::unique_ptr<ModuleSummaryIndex> ThinLTOCodeGenerator::linkCombinedIndex() {
569568
std::unique_ptr<ModuleSummaryIndex> CombinedIndex;
570569
uint64_t NextModuleId = 0;
571570
for (auto &ModuleBuffer : Modules) {
572-
Expected<std::unique_ptr<object::ModuleSummaryIndexObjectFile>> ObjOrErr =
573-
object::ModuleSummaryIndexObjectFile::create(
574-
ModuleBuffer.getMemBuffer());
575-
if (!ObjOrErr) {
571+
Expected<std::unique_ptr<ModuleSummaryIndex>> IndexOrErr =
572+
getModuleSummaryIndex(ModuleBuffer.getMemBuffer());
573+
if (!IndexOrErr) {
576574
// FIXME diagnose
577575
logAllUnhandledErrors(
578-
ObjOrErr.takeError(), errs(),
579-
"error: can't create ModuleSummaryIndexObjectFile for buffer: ");
576+
IndexOrErr.takeError(), errs(),
577+
"error: can't create module summary index for buffer: ");
580578
return nullptr;
581579
}
582-
auto Index = (*ObjOrErr)->takeIndex();
583580
if (CombinedIndex) {
584-
CombinedIndex->mergeFrom(std::move(Index), ++NextModuleId);
581+
CombinedIndex->mergeFrom(std::move(*IndexOrErr), ++NextModuleId);
585582
} else {
586-
CombinedIndex = std::move(Index);
583+
CombinedIndex = std::move(*IndexOrErr);
587584
}
588585
}
589586
return CombinedIndex;

llvm/lib/Object/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ add_llvm_library(LLVMObject
1111
IRSymtab.cpp
1212
MachOObjectFile.cpp
1313
MachOUniversal.cpp
14-
ModuleSummaryIndexObjectFile.cpp
1514
ModuleSymbolTable.cpp
1615
Object.cpp
1716
ObjectFile.cpp

llvm/lib/Object/ModuleSummaryIndexObjectFile.cpp

Lines changed: 0 additions & 129 deletions
This file was deleted.

llvm/lib/Transforms/IPO/FunctionImport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "llvm/ADT/Statistic.h"
1818
#include "llvm/ADT/StringSet.h"
1919
#include "llvm/ADT/Triple.h"
20+
#include "llvm/Bitcode/BitcodeReader.h"
2021
#include "llvm/IR/AutoUpgrade.h"
2122
#include "llvm/IR/DiagnosticPrinter.h"
2223
#include "llvm/IR/IntrinsicInst.h"
@@ -25,7 +26,6 @@
2526
#include "llvm/IRReader/IRReader.h"
2627
#include "llvm/Linker/Linker.h"
2728
#include "llvm/Object/IRObjectFile.h"
28-
#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
2929
#include "llvm/Support/CommandLine.h"
3030
#include "llvm/Support/Debug.h"
3131
#include "llvm/Support/SourceMgr.h"

llvm/test/tools/llvm-lto/error.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
; CHECK-LIST: llvm-lto: error loading file '{{.*}}/Inputs/empty.bc': The file was not recognized as a valid object file
66

77
; RUN: not llvm-lto --thinlto %S/Inputs/empty.bc 2>&1 | FileCheck %s --check-prefix=CHECK-THIN
8-
; CHECK-THIN: llvm-lto: error loading file '{{.*}}/Inputs/empty.bc': The file was not recognized as a valid object file
8+
; CHECK-THIN: llvm-lto: error loading file '{{.*}}/Inputs/empty.bc': Invalid bitcode signature

0 commit comments

Comments
 (0)