[llvm] r368156 - Remove support for 32-bit offsets in utility classes (5/5)
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 7 04:44:47 PDT 2019
Author: ikudrin
Date: Wed Aug 7 04:44:47 2019
New Revision: 368156
URL: http://llvm.org/viewvc/llvm-project?rev=368156&view=rev
Log:
Remove support for 32-bit offsets in utility classes (5/5)
Differential Revision: https://reviews.llvm.org/D65641
Modified:
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
llvm/trunk/include/llvm/Support/DataExtractor.h
llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp
llvm/trunk/lib/Support/DataExtractor.cpp
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
llvm/trunk/unittests/Support/DataExtractorTest.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h?rev=368156&r1=368155&r2=368156&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h Wed Aug 7 04:44:47 2019
@@ -453,10 +453,6 @@ public:
Expected<Entry> getEntry(uint64_t *Offset) const;
- // A temporarily method to preserve compatibility with existing code.
- // Will be removed when the migration to 64-bit offsets is finished.
- Expected<Entry> getEntry(uint32_t *Offset) const;
-
/// Look up all entries in this Name Index matching \c Key.
iterator_range<ValueIterator> equal_range(StringRef Key) const;
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h?rev=368156&r1=368155&r2=368156&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h Wed Aug 7 04:44:47 2019
@@ -147,28 +147,6 @@ public:
uint64_t *OffsetPtr,
const dwarf::FormParams FormParams);
- // The following methods are temporarily kept in order to preserve
- // compatibility with existing code and migrate to 64-bit offsets smoothly.
- // They will be removed when the migration is finished.
- // Please do not use them in new code.
- static DWARFFormValue createFromUnit(dwarf::Form F, const DWARFUnit *Unit,
- uint32_t *OffsetPtr);
- bool extractValue(const DWARFDataExtractor &Data, uint32_t *OffsetPtr,
- dwarf::FormParams FormParams,
- const DWARFContext *Context = nullptr,
- const DWARFUnit *Unit = nullptr);
- bool extractValue(const DWARFDataExtractor &Data, uint32_t *OffsetPtr,
- dwarf::FormParams FormParams, const DWARFUnit *U) {
- return extractValue(Data, OffsetPtr, FormParams, nullptr, U);
- }
- bool skipValue(DataExtractor DebugInfoData, uint32_t *OffsetPtr,
- const dwarf::FormParams Params) const {
- return DWARFFormValue::skipValue(Form, DebugInfoData, OffsetPtr, Params);
- }
- static bool skipValue(dwarf::Form Form, DataExtractor DebugInfoData,
- uint32_t *OffsetPtr,
- const dwarf::FormParams FormParams);
-
private:
void dumpString(raw_ostream &OS) const;
};
Modified: llvm/trunk/include/llvm/Support/DataExtractor.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DataExtractor.h?rev=368156&r1=368155&r2=368156&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/DataExtractor.h (original)
+++ llvm/trunk/include/llvm/Support/DataExtractor.h Wed Aug 7 04:44:47 2019
@@ -420,29 +420,6 @@ public:
bool isValidOffsetForAddress(uint64_t offset) const {
return isValidOffsetForDataOfSize(offset, AddressSize);
}
-
- // The following methods are temporarily kept in order to preserve
- // compatibility with existing code and migrate to 64-bit offsets smoothly.
- // They will be removed when the migration is finished.
- // Please do not use them in new code.
- const char *getCStr(uint32_t *offset_ptr) const;
- StringRef getCStrRef(uint32_t *offset_ptr) const;
- uint64_t getUnsigned(uint32_t *offset_ptr, uint32_t byte_size) const;
- int64_t getSigned(uint32_t *offset_ptr, uint32_t size) const;
- uint64_t getAddress(uint32_t *offset_ptr) const {
- return getUnsigned(offset_ptr, AddressSize);
- }
- uint8_t getU8(uint32_t *offset_ptr) const;
- uint8_t *getU8(uint32_t *offset_ptr, uint8_t *dst, uint32_t count) const;
- uint16_t getU16(uint32_t *offset_ptr) const;
- uint16_t *getU16(uint32_t *offset_ptr, uint16_t *dst, uint32_t count) const;
- uint32_t getU24(uint32_t *offset_ptr) const;
- uint32_t getU32(uint32_t *offset_ptr) const;
- uint32_t *getU32(uint32_t *offset_ptr, uint32_t *dst, uint32_t count) const;
- uint64_t getU64(uint32_t *offset_ptr) const;
- uint64_t *getU64(uint32_t *offset_ptr, uint64_t *dst, uint32_t count) const;
- int64_t getSLEB128(uint32_t *offset_ptr) const;
- uint64_t getULEB128(uint32_t *offset_ptr) const;
};
} // namespace llvm
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp?rev=368156&r1=368155&r2=368156&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp Wed Aug 7 04:44:47 2019
@@ -622,16 +622,6 @@ DWARFDebugNames::NameIndex::getEntry(uin
return std::move(E);
}
-// A temporarily method to preserve compatibility with existing code.
-// Will be removed when the migration to 64-bit offsets is finished.
-Expected<DWARFDebugNames::Entry>
-DWARFDebugNames::NameIndex::getEntry(uint32_t *Offset) const {
- uint64_t Offset64 = *Offset;
- auto Result = getEntry(&Offset64);
- *Offset = Offset64;
- return Result;
-}
-
DWARFDebugNames::NameTableEntry
DWARFDebugNames::NameIndex::getNameTableEntry(uint32_t Index) const {
assert(0 < Index && Index <= Hdr.NameCount);
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp?rev=368156&r1=368155&r2=368156&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp Wed Aug 7 04:44:47 2019
@@ -718,40 +718,3 @@ Optional<uint64_t> DWARFFormValue::getAs
return None;
return Value.uval;
}
-
-// The following is temporary code aimed to preserve compatibility with
-// existing code which uses 32-bit offsets.
-// It will be removed when migration to 64-bit offsets is finished.
-
-namespace {
-
-class WrapOffset {
- uint64_t Offset64;
- uint32_t *Offset32;
-
-public:
- WrapOffset(uint32_t *Offset)
- : Offset64(*Offset), Offset32(Offset) {}
- ~WrapOffset() { *Offset32 = Offset64; }
- operator uint64_t *() { return &Offset64; }
-};
-
-}
-
-DWARFFormValue DWARFFormValue::createFromUnit(dwarf::Form F, const DWARFUnit *U,
- uint32_t *OffsetPtr) {
- return createFromUnit(F, U, WrapOffset(OffsetPtr));
-}
-
-bool DWARFFormValue::skipValue(dwarf::Form Form, DataExtractor DebugInfoData,
- uint32_t *OffsetPtr,
- const dwarf::FormParams Params) {
- return skipValue(Form, DebugInfoData, WrapOffset(OffsetPtr), Params);
-}
-
-bool DWARFFormValue::extractValue(const DWARFDataExtractor &Data,
- uint32_t *OffsetPtr, dwarf::FormParams FP,
- const DWARFContext *Ctx,
- const DWARFUnit *CU) {
- return extractValue(Data, WrapOffset(OffsetPtr), FP, Ctx, CU);
-}
Modified: llvm/trunk/lib/Support/DataExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/DataExtractor.cpp?rev=368156&r1=368155&r2=368156&view=diff
==============================================================================
--- llvm/trunk/lib/Support/DataExtractor.cpp (original)
+++ llvm/trunk/lib/Support/DataExtractor.cpp Wed Aug 7 04:44:47 2019
@@ -171,88 +171,3 @@ int64_t DataExtractor::getSLEB128(uint64
*offset_ptr += bytes_read;
return result;
}
-
-// The following is temporary code aimed to preserve compatibility with
-// existing code which uses 32-bit offsets.
-// It will be removed when migration to 64-bit offsets is finished.
-
-namespace {
-
-class WrapOffset {
- uint64_t offset64;
- uint32_t *offset32_ptr;
-
-public:
- WrapOffset(uint32_t *offset_ptr)
- : offset64(*offset_ptr), offset32_ptr(offset_ptr) {}
- ~WrapOffset() { *offset32_ptr = offset64; }
- operator uint64_t *() { return &offset64; }
-};
-
-}
-
-uint8_t DataExtractor::getU8(uint32_t *offset_ptr) const {
- return getU8(WrapOffset(offset_ptr));
-}
-
-uint8_t *
-DataExtractor::getU8(uint32_t *offset_ptr, uint8_t *dst, uint32_t count) const {
- return getU8(WrapOffset(offset_ptr), dst, count);
-}
-
-uint16_t DataExtractor::getU16(uint32_t *offset_ptr) const {
- return getU16(WrapOffset(offset_ptr));
-}
-
-uint16_t *DataExtractor::getU16(uint32_t *offset_ptr, uint16_t *dst,
- uint32_t count) const {
- return getU16(WrapOffset(offset_ptr), dst, count);
-}
-
-uint32_t DataExtractor::getU24(uint32_t *offset_ptr) const {
- return getU24(WrapOffset(offset_ptr));
-}
-
-uint32_t DataExtractor::getU32(uint32_t *offset_ptr) const {
- return getU32(WrapOffset(offset_ptr));
-}
-
-uint32_t *DataExtractor::getU32(uint32_t *offset_ptr, uint32_t *dst,
- uint32_t count) const {
- return getU32(WrapOffset(offset_ptr), dst, count);
-}
-
-uint64_t DataExtractor::getU64(uint32_t *offset_ptr) const {
- return getU64(WrapOffset(offset_ptr));
-}
-
-uint64_t *DataExtractor::getU64(uint32_t *offset_ptr, uint64_t *dst,
- uint32_t count) const {
- return getU64(WrapOffset(offset_ptr), dst, count);
-}
-
-uint64_t
-DataExtractor::getUnsigned(uint32_t *offset_ptr, uint32_t byte_size) const {
- return getUnsigned(WrapOffset(offset_ptr), byte_size);
-}
-
-int64_t
-DataExtractor::getSigned(uint32_t *offset_ptr, uint32_t byte_size) const {
- return getSigned(WrapOffset(offset_ptr), byte_size);
-}
-
-const char *DataExtractor::getCStr(uint32_t *offset_ptr) const {
- return getCStr(WrapOffset(offset_ptr));
-}
-
-StringRef DataExtractor::getCStrRef(uint32_t *offset_ptr) const {
- return getCStrRef(WrapOffset(offset_ptr));
-}
-
-uint64_t DataExtractor::getULEB128(uint32_t *offset_ptr) const {
- return getULEB128(WrapOffset(offset_ptr));
-}
-
-int64_t DataExtractor::getSLEB128(uint32_t *offset_ptr) const {
- return getSLEB128(WrapOffset(offset_ptr));
-}
Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=368156&r1=368155&r2=368156&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Wed Aug 7 04:44:47 2019
@@ -4383,15 +4383,6 @@ void GNUStyle<ELFT>::printELFLinkerOptio
OS << "printELFLinkerOptions not implemented!\n";
}
-// FIXME: As soon as the DataExtractor interface handles uint64_t *, this
-// should be eliminated. See upstream review https://reviews.llvm.org/D64006.
-inline uint32_t *AdjustPtr(uint64_t *Offset) {
- uint32_t *Ptr = reinterpret_cast<uint32_t *>(Offset);
- if (sys::IsBigEndianHost)
- Ptr++;
- return Ptr;
-}
-
template <class ELFT>
void DumpStyle<ELFT>::printFunctionStackSize(
const ELFObjectFile<ELFT> *Obj, uint64_t SymValue, SectionRef FunctionSec,
@@ -4431,7 +4422,7 @@ void DumpStyle<ELFT>::printFunctionStack
// Extract the size. The expectation is that Offset is pointing to the right
// place, i.e. past the function address.
uint64_t PrevOffset = *Offset;
- uint64_t StackSize = Data.getULEB128(AdjustPtr(Offset));
+ uint64_t StackSize = Data.getULEB128(Offset);
// getULEB128() does not advance Offset if it is not able to extract a valid
// integer.
if (*Offset == PrevOffset)
@@ -4504,7 +4495,7 @@ void DumpStyle<ELFT>::printStackSize(con
"while trying to extract a stack size entry",
StackSizeSectionName.data()));
- uint64_t Addend = Data.getAddress(AdjustPtr(&Offset));
+ uint64_t Addend = Data.getAddress(&Offset);
uint64_t SymValue = Resolver(Reloc, RelocSymValue, Addend);
this->printFunctionStackSize(Obj, SymValue, FunctionSec, StackSizeSectionName,
Data, &Offset);
@@ -4553,7 +4544,7 @@ void DumpStyle<ELFT>::printNonRelocatabl
"section %s ended while trying to extract a stack size entry",
SectionName.data()));
}
- uint64_t SymValue = Data.getAddress(AdjustPtr(&Offset));
+ uint64_t SymValue = Data.getAddress(&Offset);
printFunctionStackSize(Obj, SymValue,
toSectionRef<ELFT>(Obj, FunctionELFSec),
SectionName, Data, &Offset);
Modified: llvm/trunk/unittests/Support/DataExtractorTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/DataExtractorTest.cpp?rev=368156&r1=368155&r2=368156&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/DataExtractorTest.cpp (original)
+++ llvm/trunk/unittests/Support/DataExtractorTest.cpp Wed Aug 7 04:44:47 2019
@@ -12,27 +12,19 @@ using namespace llvm;
namespace {
-// Test fixture
-template <typename T>
-class DataExtractorTest : public ::testing::Test { };
-
-// Test DataExtractor with both types which can be used for offsets.
-typedef ::testing::Types</*uint32_t, */uint64_t> TestTypes;
-TYPED_TEST_CASE(DataExtractorTest, TestTypes);
-
const char numberData[] = "\x80\x90\xFF\xFF\x80\x00\x00\x00";
const char stringData[] = "hellohello\0hello";
const char leb128data[] = "\xA6\x49";
const char bigleb128data[] = "\xAA\xA9\xFF\xAA\xFF\xAA\xFF\x4A";
-TYPED_TEST(DataExtractorTest, OffsetOverflow) {
+TEST(DataExtractorTest, OffsetOverflow) {
DataExtractor DE(StringRef(numberData, sizeof(numberData)-1), false, 8);
EXPECT_FALSE(DE.isValidOffsetForDataOfSize(-2U, 5));
}
-TYPED_TEST(DataExtractorTest, UnsignedNumbers) {
+TEST(DataExtractorTest, UnsignedNumbers) {
DataExtractor DE(StringRef(numberData, sizeof(numberData)-1), false, 8);
- TypeParam offset = 0;
+ uint64_t offset = 0;
EXPECT_EQ(0x80U, DE.getU8(&offset));
EXPECT_EQ(1U, offset);
@@ -78,9 +70,9 @@ TYPED_TEST(DataExtractorTest, UnsignedNu
EXPECT_EQ(8U, offset);
}
-TYPED_TEST(DataExtractorTest, SignedNumbers) {
+TEST(DataExtractorTest, SignedNumbers) {
DataExtractor DE(StringRef(numberData, sizeof(numberData)-1), false, 8);
- TypeParam offset = 0;
+ uint64_t offset = 0;
EXPECT_EQ(-128, DE.getSigned(&offset, 1));
EXPECT_EQ(1U, offset);
@@ -95,9 +87,9 @@ TYPED_TEST(DataExtractorTest, SignedNumb
EXPECT_EQ(8U, offset);
}
-TYPED_TEST(DataExtractorTest, Strings) {
+TEST(DataExtractorTest, Strings) {
DataExtractor DE(StringRef(stringData, sizeof(stringData)-1), false, 8);
- TypeParam offset = 0;
+ uint64_t offset = 0;
EXPECT_EQ(stringData, DE.getCStr(&offset));
EXPECT_EQ(11U, offset);
@@ -105,9 +97,9 @@ TYPED_TEST(DataExtractorTest, Strings) {
EXPECT_EQ(11U, offset);
}
-TYPED_TEST(DataExtractorTest, LEB128) {
+TEST(DataExtractorTest, LEB128) {
DataExtractor DE(StringRef(leb128data, sizeof(leb128data)-1), false, 8);
- TypeParam offset = 0;
+ uint64_t offset = 0;
EXPECT_EQ(9382ULL, DE.getULEB128(&offset));
EXPECT_EQ(2U, offset);
@@ -124,9 +116,9 @@ TYPED_TEST(DataExtractorTest, LEB128) {
EXPECT_EQ(8U, offset);
}
-TYPED_TEST(DataExtractorTest, LEB128_error) {
+TEST(DataExtractorTest, LEB128_error) {
DataExtractor DE(StringRef("\x81"), false, 8);
- TypeParam Offset = 0;
+ uint64_t Offset = 0;
EXPECT_EQ(0U, DE.getULEB128(&Offset));
EXPECT_EQ(0U, Offset);
More information about the llvm-commits
mailing list