[PATCH] D85293: [DebugInfo] Simplify DIEInteger::SizeOf().
Igor Kudrin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 16 22:48:09 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG027d47d1c7ce: [DebugInfo] Simplify DIEInteger::SizeOf(). (authored by ikudrin).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85293/new/
https://reviews.llvm.org/D85293
Files:
llvm/lib/CodeGen/AsmPrinter/DIE.cpp
llvm/unittests/CodeGen/DIEHashTest.cpp
Index: llvm/unittests/CodeGen/DIEHashTest.cpp
===================================================================
--- llvm/unittests/CodeGen/DIEHashTest.cpp
+++ llvm/unittests/CodeGen/DIEHashTest.cpp
@@ -7,12 +7,15 @@
//===----------------------------------------------------------------------===//
#include "../lib/CodeGen/AsmPrinter/DIEHash.h"
+#include "TestAsmPrinter.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/CodeGen/DIE.h"
#include "llvm/CodeGen/DwarfStringPoolEntry.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Format.h"
+#include "llvm/Support/Host.h"
+#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"
using namespace llvm;
@@ -26,6 +29,14 @@
private:
StringMap<DwarfStringPoolEntry> Pool;
+ std::unique_ptr<TestAsmPrinter> TestPrinter;
+
+ void setupTestPrinter() {
+ auto ExpectedTestPrinter = TestAsmPrinter::create(
+ sys::getDefaultTargetTriple(), /*DwarfVersion=*/4, dwarf::DWARF32);
+ ASSERT_THAT_EXPECTED(ExpectedTestPrinter, Succeeded());
+ TestPrinter = std::move(ExpectedTestPrinter.get());
+ }
public:
DIEString getString(StringRef S) {
@@ -33,6 +44,12 @@
return DIEString(DwarfStringPoolEntryRef(
*Pool.insert(std::make_pair(S, Entry)).first, Entry.isIndexed()));
}
+
+ AsmPrinter *getAsmPrinter() {
+ if (!TestPrinter)
+ setupTestPrinter();
+ return TestPrinter ? TestPrinter->getAP() : nullptr;
+ }
};
TEST_F(DIEHashTest, Data1) {
@@ -644,6 +661,10 @@
// };
// A a;
TEST_F(DIEHashTest, MemberBlock) {
+ if (!this->getAsmPrinter())
+ // TODO: Use GTEST_SKIP() when GTest is updated to version 1.10.0
+ return;
+
DIE &A = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
DIEInteger One(1);
DIEString AStr = getString("A");
@@ -692,7 +713,7 @@
A.addChild(std::move(PI));
- uint64_t MD5Res = DIEHash().computeTypeSignature(A);
+ uint64_t MD5Res = DIEHash(this->getAsmPrinter()).computeTypeSignature(A);
ASSERT_EQ(0x493af53ad3d3f651ULL, MD5Res);
}
}
Index: llvm/lib/CodeGen/AsmPrinter/DIE.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DIE.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DIE.cpp
@@ -428,10 +428,10 @@
/// SizeOf - Determine size of integer value in bytes.
///
unsigned DIEInteger::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
- dwarf::FormParams Params = {0, 0, dwarf::DWARF32};
- if (AP)
- Params = {AP->getDwarfVersion(), uint8_t(AP->getPointerSize()),
- AP->OutStreamer->getContext().getDwarfFormat()};
+ assert(AP && "AsmPrinter is required to set FormParams");
+ dwarf::FormParams Params = {AP->getDwarfVersion(),
+ uint8_t(AP->getPointerSize()),
+ AP->OutStreamer->getContext().getDwarfFormat()};
if (Optional<uint8_t> FixedSize = dwarf::getFixedFormByteSize(Form, Params))
return *FixedSize;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85293.292407.patch
Type: text/x-patch
Size: 2965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200917/6fa01cd0/attachment.bin>
More information about the llvm-commits
mailing list