[llvm] r312168 - [IR] Don't print "!DIExpression() = !DIExpression()" when dumping
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 30 13:40:36 PDT 2017
Author: rnk
Date: Wed Aug 30 13:40:36 2017
New Revision: 312168
URL: http://llvm.org/viewvc/llvm-project?rev=312168&view=rev
Log:
[IR] Don't print "!DIExpression() = !DIExpression()" when dumping
Now that we print DIExpressions inline everywhere, we don't need to
print them once as an operand and again as a value. This is only really
visible when calling dump() or print() directly on a DIExpression during
debugging.
Modified:
llvm/trunk/lib/IR/AsmWriter.cpp
llvm/trunk/unittests/IR/AsmWriterTest.cpp
Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=312168&r1=312167&r2=312168&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Wed Aug 30 13:40:36 2017
@@ -3592,7 +3592,7 @@ static void printMetadataImpl(raw_ostrea
/* FromValue */ true);
auto *N = dyn_cast<MDNode>(&MD);
- if (OnlyAsOperand || !N)
+ if (OnlyAsOperand || !N || isa<DIExpression>(MD))
return;
OS << " = ";
Modified: llvm/trunk/unittests/IR/AsmWriterTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/AsmWriterTest.cpp?rev=312168&r1=312167&r2=312168&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/AsmWriterTest.cpp (original)
+++ llvm/trunk/unittests/IR/AsmWriterTest.cpp Wed Aug 30 13:40:36 2017
@@ -6,6 +6,8 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
+#include "llvm/BinaryFormat/Dwarf.h"
+#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LLVMContext.h"
@@ -34,4 +36,19 @@ TEST(AsmWriterTest, DebugPrintDetachedIn
EXPECT_TRUE(r != std::string::npos);
}
+TEST(AsmWriterTest, DumpDIExpression) {
+ LLVMContext Ctx;
+ uint64_t Ops[] = {
+ dwarf::DW_OP_constu, 4,
+ dwarf::DW_OP_minus,
+ dwarf::DW_OP_deref,
+ };
+ DIExpression *Expr = DIExpression::get(Ctx, Ops);
+ std::string S;
+ raw_string_ostream OS(S);
+ Expr->print(OS);
+ EXPECT_EQ("!DIExpression(DW_OP_constu, 4, DW_OP_minus, DW_OP_deref)",
+ OS.str());
+}
+
}
More information about the llvm-commits
mailing list