summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-05-19 05:57:45 +0000
committerZachary Turner <zturner@google.com>2017-05-19 05:57:45 +0000
commit1dfcf8d92c808bd9fcb4d1a0d81582453f80c423 (patch)
tree611a9e1848ebefa1e5a9e22f6939c0482b8ee05e /llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
parent47fdc73771c39a83d97b8eb142dd311eb773e541 (diff)
downloadbcm5719-llvm-1dfcf8d92c808bd9fcb4d1a0d81582453f80c423.tar.gz
bcm5719-llvm-1dfcf8d92c808bd9fcb4d1a0d81582453f80c423.zip
Revert "[CodeView] Provide a common interface for type collections."
This is a squash of ~5 reverts of, well, pretty much everything I did today. Something is seriously broken with lit on Windows right now, and as a result assertions that fire in tests are triggering failures. I've been breaking non-Windows bots all day which has seriously confused me because all my tests have been passing, and after running lit with -a to view the output even on successful runs, I find out that the tool is crashing and yet lit is still reporting it as a success! At this point I don't even know where to start, so rather than leave the tree broken for who knows how long, I will get this back to green, and then once lit is fixed on Windows, hopefully hopefully fix the remaining set of problems for real. llvm-svn: 303409
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp40
1 files changed, 28 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index ae14e000c38..7d945690e9c 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -13,6 +13,7 @@
#include "CodeViewDebug.h"
#include "llvm/ADT/TinyPtrVector.h"
+#include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/Line.h"
@@ -22,7 +23,6 @@
#include "llvm/DebugInfo/CodeView/TypeDumpVisitor.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
-#include "llvm/DebugInfo/CodeView/TypeTableCollection.h"
#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
#include "llvm/IR/Constants.h"
#include "llvm/MC/MCAsmInfo.h"
@@ -469,21 +469,17 @@ void CodeViewDebug::emitTypeInformation() {
CommentPrefix += ' ';
}
- TypeTableCollection Table(TypeTable.records());
- Optional<TypeIndex> B = Table.getFirst();
- do {
- // This will fail if the record data is invalid.
- CVType Record = Table.getType(*B);
-
+ TypeDatabase TypeDB(TypeTable.records().size());
+ CVTypeDumper CVTD(TypeDB);
+ TypeTable.ForEachRecord([&](TypeIndex Index, ArrayRef<uint8_t> Record) {
if (OS.isVerboseAsm()) {
// Emit a block comment describing the type record for readability.
SmallString<512> CommentBlock;
raw_svector_ostream CommentOS(CommentBlock);
ScopedPrinter SP(CommentOS);
SP.setPrefix(CommentPrefix);
- TypeDumpVisitor TDV(Table, &SP, false);
-
- Error E = codeview::visitTypeRecord(Record, *B, TDV);
+ TypeDumpVisitor TDV(TypeDB, &SP, false);
+ Error E = CVTD.dump(Record, TDV);
if (E) {
logAllUnhandledErrors(std::move(E), errs(), "error: ");
llvm_unreachable("produced malformed type record");
@@ -493,9 +489,29 @@ void CodeViewDebug::emitTypeInformation() {
// newline.
OS.emitRawComment(
CommentOS.str().drop_front(CommentPrefix.size() - 1).rtrim());
+ } else {
+#ifndef NDEBUG
+ // Assert that the type data is valid even if we aren't dumping
+ // comments. The MSVC linker doesn't do much type record validation,
+ // so the first link of an invalid type record can succeed while
+ // subsequent links will fail with LNK1285.
+ BinaryByteStream Stream(Record, llvm::support::little);
+ CVTypeArray Types;
+ BinaryStreamReader Reader(Stream);
+ Error E = Reader.readArray(Types, Reader.getLength());
+ if (!E) {
+ TypeVisitorCallbacks C;
+ E = codeview::visitTypeStream(Types, C);
+ }
+ if (E) {
+ logAllUnhandledErrors(std::move(E), errs(), "error: ");
+ llvm_unreachable("produced malformed type record");
+ }
+#endif
}
- OS.EmitBinaryData(Record.str_data());
- } while ((B = Table.getNext(*B)));
+ StringRef S(reinterpret_cast<const char *>(Record.data()), Record.size());
+ OS.EmitBinaryData(S);
+ });
}
namespace {
OpenPOWER on IntegriCloud