mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-15 21:24:00 +00:00
Revert "Convert a few std::strings to StringRef."
This reverts commit r212342. We can get a StringRef into the current Record, but not one in the bitcode itself since the string is compressed in it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212356 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -14,7 +14,6 @@
|
|||||||
#ifndef LLVM_BITCODE_READERWRITER_H
|
#ifndef LLVM_BITCODE_READERWRITER_H
|
||||||
#define LLVM_BITCODE_READERWRITER_H
|
#define LLVM_BITCODE_READERWRITER_H
|
||||||
|
|
||||||
#include "llvm/ADT/StringRef.h"
|
|
||||||
#include "llvm/Support/ErrorOr.h"
|
#include "llvm/Support/ErrorOr.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -45,7 +44,8 @@ namespace llvm {
|
|||||||
/// Read the header of the specified bitcode buffer and extract just the
|
/// Read the header of the specified bitcode buffer and extract just the
|
||||||
/// triple information. If successful, this returns a string and *does not*
|
/// triple information. If successful, this returns a string and *does not*
|
||||||
/// take ownership of 'buffer'. On error, this returns "".
|
/// take ownership of 'buffer'. On error, this returns "".
|
||||||
StringRef getBitcodeTargetTriple(MemoryBuffer *Buffer, LLVMContext &Context);
|
std::string getBitcodeTargetTriple(MemoryBuffer *Buffer,
|
||||||
|
LLVMContext &Context);
|
||||||
|
|
||||||
/// Read the specified bitcode file, returning the module.
|
/// Read the specified bitcode file, returning the module.
|
||||||
/// This method *never* takes ownership of Buffer.
|
/// This method *never* takes ownership of Buffer.
|
||||||
|
@ -71,15 +71,6 @@ static bool ConvertToString(ArrayRef<uint64_t> Record, unsigned Idx,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<StringRef> BitcodeReader::convertToStringRef(ArrayRef<uint64_t> Record,
|
|
||||||
unsigned Idx) {
|
|
||||||
if (Idx > Record.size())
|
|
||||||
return Error(InvalidRecord);
|
|
||||||
|
|
||||||
return StringRef((char*)&Record[Idx], Record.size() - Idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static GlobalValue::LinkageTypes GetDecodedLinkage(unsigned Val) {
|
static GlobalValue::LinkageTypes GetDecodedLinkage(unsigned Val) {
|
||||||
switch (Val) {
|
switch (Val) {
|
||||||
default: // Map unknown/new linkages to external
|
default: // Map unknown/new linkages to external
|
||||||
@ -2125,13 +2116,13 @@ std::error_code BitcodeReader::ParseBitcodeInto(Module *M) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<StringRef> BitcodeReader::parseModuleTriple() {
|
ErrorOr<std::string> BitcodeReader::parseModuleTriple() {
|
||||||
if (Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID))
|
if (Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID))
|
||||||
return Error(InvalidRecord);
|
return Error(InvalidRecord);
|
||||||
|
|
||||||
SmallVector<uint64_t, 64> Record;
|
SmallVector<uint64_t, 64> Record;
|
||||||
|
|
||||||
StringRef Triple;
|
std::string Triple;
|
||||||
// Read all the records for this module.
|
// Read all the records for this module.
|
||||||
while (1) {
|
while (1) {
|
||||||
BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
|
BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
|
||||||
@ -2151,10 +2142,10 @@ ErrorOr<StringRef> BitcodeReader::parseModuleTriple() {
|
|||||||
switch (Stream.readRecord(Entry.ID, Record)) {
|
switch (Stream.readRecord(Entry.ID, Record)) {
|
||||||
default: break; // Default behavior, ignore unknown content.
|
default: break; // Default behavior, ignore unknown content.
|
||||||
case bitc::MODULE_CODE_TRIPLE: { // TRIPLE: [strchr x N]
|
case bitc::MODULE_CODE_TRIPLE: { // TRIPLE: [strchr x N]
|
||||||
ErrorOr<StringRef> S = convertToStringRef(Record, 0);
|
std::string S;
|
||||||
if (std::error_code EC = S.getError())
|
if (ConvertToString(Record, 0, S))
|
||||||
return EC;
|
return Error(InvalidRecord);
|
||||||
Triple = S.get();
|
Triple = S;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2163,7 +2154,7 @@ ErrorOr<StringRef> BitcodeReader::parseModuleTriple() {
|
|||||||
return Triple;
|
return Triple;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<StringRef> BitcodeReader::parseTriple() {
|
ErrorOr<std::string> BitcodeReader::parseTriple() {
|
||||||
if (std::error_code EC = InitStream())
|
if (std::error_code EC = InitStream())
|
||||||
return EC;
|
return EC;
|
||||||
|
|
||||||
@ -3478,10 +3469,10 @@ ErrorOr<Module *> llvm::parseBitcodeFile(MemoryBuffer *Buffer,
|
|||||||
return M;
|
return M;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef llvm::getBitcodeTargetTriple(MemoryBuffer *Buffer,
|
std::string llvm::getBitcodeTargetTriple(MemoryBuffer *Buffer,
|
||||||
LLVMContext &Context) {
|
LLVMContext &Context) {
|
||||||
BitcodeReader *R = new BitcodeReader(Buffer, Context);
|
BitcodeReader *R = new BitcodeReader(Buffer, Context);
|
||||||
ErrorOr<StringRef> Triple = R->parseTriple();
|
ErrorOr<std::string> Triple = R->parseTriple();
|
||||||
R->releaseBuffer();
|
R->releaseBuffer();
|
||||||
delete R;
|
delete R;
|
||||||
if (Triple.getError())
|
if (Triple.getError())
|
||||||
|
@ -196,9 +196,6 @@ class BitcodeReader : public GVMaterializer {
|
|||||||
|
|
||||||
static const std::error_category &BitcodeErrorCategory();
|
static const std::error_category &BitcodeErrorCategory();
|
||||||
|
|
||||||
static ErrorOr<StringRef> convertToStringRef(ArrayRef<uint64_t> Record,
|
|
||||||
unsigned Idx);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum ErrorType {
|
enum ErrorType {
|
||||||
BitcodeStreamInvalidSize,
|
BitcodeStreamInvalidSize,
|
||||||
@ -223,7 +220,7 @@ public:
|
|||||||
InvalidValue // Invalid version, inst number, attr number, etc
|
InvalidValue // Invalid version, inst number, attr number, etc
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::error_code Error(ErrorType E) {
|
std::error_code Error(ErrorType E) {
|
||||||
return std::error_code(E, BitcodeErrorCategory());
|
return std::error_code(E, BitcodeErrorCategory());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,7 +252,7 @@ public:
|
|||||||
|
|
||||||
/// @brief Cheap mechanism to just extract module triple
|
/// @brief Cheap mechanism to just extract module triple
|
||||||
/// @returns true if an error occurred.
|
/// @returns true if an error occurred.
|
||||||
ErrorOr<StringRef> parseTriple();
|
ErrorOr<std::string> parseTriple();
|
||||||
|
|
||||||
static uint64_t decodeSignRotatedValue(uint64_t V);
|
static uint64_t decodeSignRotatedValue(uint64_t V);
|
||||||
|
|
||||||
@ -357,7 +354,7 @@ private:
|
|||||||
std::error_code ResolveGlobalAndAliasInits();
|
std::error_code ResolveGlobalAndAliasInits();
|
||||||
std::error_code ParseMetadata();
|
std::error_code ParseMetadata();
|
||||||
std::error_code ParseMetadataAttachment();
|
std::error_code ParseMetadataAttachment();
|
||||||
ErrorOr<StringRef> parseModuleTriple();
|
ErrorOr<std::string> parseModuleTriple();
|
||||||
std::error_code ParseUseLists();
|
std::error_code ParseUseLists();
|
||||||
std::error_code InitStream();
|
std::error_code InitStream();
|
||||||
std::error_code InitStreamFromBuffer();
|
std::error_code InitStreamFromBuffer();
|
||||||
|
@ -63,8 +63,8 @@ bool LTOModule::isBitcodeFile(const char *path) {
|
|||||||
|
|
||||||
bool LTOModule::isBitcodeForTarget(MemoryBuffer *buffer,
|
bool LTOModule::isBitcodeForTarget(MemoryBuffer *buffer,
|
||||||
StringRef triplePrefix) {
|
StringRef triplePrefix) {
|
||||||
StringRef Triple = getBitcodeTargetTriple(buffer, getGlobalContext());
|
std::string Triple = getBitcodeTargetTriple(buffer, getGlobalContext());
|
||||||
return Triple.startswith(triplePrefix);
|
return StringRef(Triple).startswith(triplePrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
LTOModule *LTOModule::createFromFile(const char *path, TargetOptions options,
|
LTOModule *LTOModule::createFromFile(const char *path, TargetOptions options,
|
||||||
|
Reference in New Issue
Block a user