Skip to content

Commit

Permalink
[IR] Don't print "!DIExpression() = !DIExpression()" when dumping
Browse files Browse the repository at this point in the history
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312168 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
rnk committed Aug 30, 2017
1 parent 5c6206f commit b5b9823
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/IR/AsmWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3592,7 +3592,7 @@ static void printMetadataImpl(raw_ostream &ROS, const Metadata &MD,
/* FromValue */ true);

auto *N = dyn_cast<MDNode>(&MD);
if (OnlyAsOperand || !N)
if (OnlyAsOperand || !N || isa<DIExpression>(MD))
return;

OS << " = ";
Expand Down
17 changes: 17 additions & 0 deletions unittests/IR/AsmWriterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -34,4 +36,19 @@ TEST(AsmWriterTest, DebugPrintDetachedInstruction) {
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());
}

}

0 comments on commit b5b9823

Please sign in to comment.