Skip to content

Commit

Permalink
Object: Remove ModuleSummaryIndexObjectFile class.
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D32195

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301832 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
pcc committed May 1, 2017
1 parent 1b0acac commit 6a2cc4c
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 260 deletions.
7 changes: 7 additions & 0 deletions include/llvm/Bitcode/BitcodeReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ namespace llvm {
Expected<std::unique_ptr<ModuleSummaryIndex>>
getModuleSummaryIndex(MemoryBufferRef Buffer);

/// Parse the module summary index out of an IR file and return the module
/// summary index object if found, or an empty summary if not. If Path refers
/// to an empty file and the -ignore-empty-index-file cl::opt flag is passed
/// this function will return nullptr.
Expected<std::unique_ptr<ModuleSummaryIndex>>
getModuleSummaryIndexForFile(StringRef Path);

/// isBitcodeWrapper - Return true if the given bytes are the magic bytes
/// for an LLVM IR bitcode wrapper.
///
Expand Down
3 changes: 0 additions & 3 deletions include/llvm/Object/Binary.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class Binary {
ID_MachOUniversalBinary,
ID_COFFImportFile,
ID_IR, // LLVM IR
ID_ModuleSummaryIndex, // Module summary index

// Object and children.
ID_StartObjects,
Expand Down Expand Up @@ -128,8 +127,6 @@ class Binary {
return TypeID == ID_IR;
}

bool isModuleSummaryIndex() const { return TypeID == ID_ModuleSummaryIndex; }

bool isLittleEndian() const {
return !(TypeID == ID_ELF32B || TypeID == ID_ELF64B ||
TypeID == ID_MachO32B || TypeID == ID_MachO64B);
Expand Down
112 changes: 0 additions & 112 deletions include/llvm/Object/ModuleSummaryIndexObjectFile.h

This file was deleted.

18 changes: 18 additions & 0 deletions lib/Bitcode/Reader/BitcodeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ static cl::opt<bool> PrintSummaryGUIDs(
cl::desc(
"Print the global id for each value when reading the module summary"));

// FIXME: This flag should either be removed or moved to clang as a driver flag.
static llvm::cl::opt<bool> IgnoreEmptyThinLTOIndexFile(
"ignore-empty-index-file", llvm::cl::ZeroOrMore,
llvm::cl::desc(
"Ignore an empty index file and perform non-ThinLTO compilation"),
llvm::cl::init(false));

namespace {

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

return BM->hasSummary();
}

Expected<std::unique_ptr<ModuleSummaryIndex>>
llvm::getModuleSummaryIndexForFile(StringRef Path) {
ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr =
MemoryBuffer::getFileOrSTDIN(Path);
if (!FileOrErr)
return errorCodeToError(FileOrErr.getError());
if (IgnoreEmptyThinLTOIndexFile && !(*FileOrErr)->getBufferSize())
return nullptr;
return getModuleSummaryIndex(**FileOrErr);
}
1 change: 0 additions & 1 deletion lib/LTO/LTO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "llvm/LTO/LTOBackend.h"
#include "llvm/Linker/IRMover.h"
#include "llvm/Object/IRObjectFile.h"
#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
Expand Down
17 changes: 7 additions & 10 deletions lib/LTO/ThinLTOCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "llvm/Linker/Linker.h"
#include "llvm/MC/SubtargetFeature.h"
#include "llvm/Object/IRObjectFile.h"
#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
#include "llvm/Support/CachePruning.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Error.h"
Expand Down Expand Up @@ -569,21 +568,19 @@ std::unique_ptr<ModuleSummaryIndex> ThinLTOCodeGenerator::linkCombinedIndex() {
std::unique_ptr<ModuleSummaryIndex> CombinedIndex;
uint64_t NextModuleId = 0;
for (auto &ModuleBuffer : Modules) {
Expected<std::unique_ptr<object::ModuleSummaryIndexObjectFile>> ObjOrErr =
object::ModuleSummaryIndexObjectFile::create(
ModuleBuffer.getMemBuffer());
if (!ObjOrErr) {
Expected<std::unique_ptr<ModuleSummaryIndex>> IndexOrErr =
getModuleSummaryIndex(ModuleBuffer.getMemBuffer());
if (!IndexOrErr) {
// FIXME diagnose
logAllUnhandledErrors(
ObjOrErr.takeError(), errs(),
"error: can't create ModuleSummaryIndexObjectFile for buffer: ");
IndexOrErr.takeError(), errs(),
"error: can't create module summary index for buffer: ");
return nullptr;
}
auto Index = (*ObjOrErr)->takeIndex();
if (CombinedIndex) {
CombinedIndex->mergeFrom(std::move(Index), ++NextModuleId);
CombinedIndex->mergeFrom(std::move(*IndexOrErr), ++NextModuleId);
} else {
CombinedIndex = std::move(Index);
CombinedIndex = std::move(*IndexOrErr);
}
}
return CombinedIndex;
Expand Down
1 change: 0 additions & 1 deletion lib/Object/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ add_llvm_library(LLVMObject
IRSymtab.cpp
MachOObjectFile.cpp
MachOUniversal.cpp
ModuleSummaryIndexObjectFile.cpp
ModuleSymbolTable.cpp
Object.cpp
ObjectFile.cpp
Expand Down
129 changes: 0 additions & 129 deletions lib/Object/ModuleSummaryIndexObjectFile.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion lib/Transforms/IPO/FunctionImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/IR/AutoUpgrade.h"
#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/IR/IntrinsicInst.h"
Expand All @@ -25,7 +26,6 @@
#include "llvm/IRReader/IRReader.h"
#include "llvm/Linker/Linker.h"
#include "llvm/Object/IRObjectFile.h"
#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/SourceMgr.h"
Expand Down
2 changes: 1 addition & 1 deletion test/tools/llvm-lto/error.ll
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
; CHECK-LIST: llvm-lto: error loading file '{{.*}}/Inputs/empty.bc': The file was not recognized as a valid object file

; RUN: not llvm-lto --thinlto %S/Inputs/empty.bc 2>&1 | FileCheck %s --check-prefix=CHECK-THIN
; CHECK-THIN: llvm-lto: error loading file '{{.*}}/Inputs/empty.bc': The file was not recognized as a valid object file
; CHECK-THIN: llvm-lto: error loading file '{{.*}}/Inputs/empty.bc': Invalid bitcode signature
2 changes: 1 addition & 1 deletion tools/llvm-link/llvm-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//

#include "llvm/ADT/STLExtras.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/Bitcode/BitcodeWriter.h"
#include "llvm/IR/AutoUpgrade.h"
#include "llvm/IR/DiagnosticInfo.h"
Expand All @@ -23,7 +24,6 @@
#include "llvm/IR/Verifier.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/Linker/Linker.h"
#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ManagedStatic.h"
Expand Down
Loading

0 comments on commit 6a2cc4c

Please sign in to comment.