aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/IR/MetadataTest.cpp
diff options
context:
space:
mode:
authorOCHyams <orlando.hyams@sony.com>2023-04-25 11:24:30 +0100
committerOCHyams <orlando.hyams@sony.com>2023-04-25 14:13:47 +0100
commit1e6fe677f8aa98518e05218affa16e468819f5ed (patch)
tree0e7b15122bf4563ecf46c9b7a383317c01e0bf70 /llvm/unittests/IR/MetadataTest.cpp
parent4b1532a46f66eb71bf80458fa67b86c618803b95 (diff)
downloadllvm-1e6fe677f8aa98518e05218affa16e468819f5ed.zip
llvm-1e6fe677f8aa98518e05218affa16e468819f5ed.tar.gz
llvm-1e6fe677f8aa98518e05218affa16e468819f5ed.tar.bz2
[DebugInfo] Print empty MDTuples wrapped in MetadataAsValue inline
This improves the readability of debugging intrinsics. Instead of: call void @llvm.dbg.value(metadata !2, ...) !2 = !{} We will see: call void @llvm.dbg.value(metadata !{}, ...) !2 = !{} Note that we still get a numbered metadata entry for the node even if it's not used elsewhere. This is to avoid adding more context to the print functions. This is already legal IR - LLVM can parse and understand it - so there is no need to update the parser. The next patches in this stack will make such empty metadata operands more common and semantically important. Related to https://discourse.llvm.org/t/auto-undef-debug-uses-of-a-deleted-value Reviewed By: StephenTozer Differential Revision: https://reviews.llvm.org/D140900
Diffstat (limited to 'llvm/unittests/IR/MetadataTest.cpp')
-rw-r--r--llvm/unittests/IR/MetadataTest.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp
index 5342360..fa559b4 100644
--- a/llvm/unittests/IR/MetadataTest.cpp
+++ b/llvm/unittests/IR/MetadataTest.cpp
@@ -390,18 +390,20 @@ TEST_F(MDNodeTest, PrintFromMetadataAsValue) {
EXPECT_PRINTER_EQ("!0 = distinct !{}", MAV0->print(OS));
EXPECT_PRINTER_EQ("!1 = distinct !{}", MAV1->print(OS));
- EXPECT_PRINTER_EQ("!0", MAV0->printAsOperand(OS, false));
- EXPECT_PRINTER_EQ("!1", MAV1->printAsOperand(OS, false));
- EXPECT_PRINTER_EQ("metadata !0", MAV0->printAsOperand(OS, true));
- EXPECT_PRINTER_EQ("metadata !1", MAV1->printAsOperand(OS, true));
+ EXPECT_PRINTER_EQ("distinct !{}", MAV0->printAsOperand(OS, false));
+ EXPECT_PRINTER_EQ("distinct !{}", MAV1->printAsOperand(OS, false));
+ EXPECT_PRINTER_EQ("metadata distinct !{}", MAV0->printAsOperand(OS, true));
+ EXPECT_PRINTER_EQ("metadata distinct !{}", MAV1->printAsOperand(OS, true));
ModuleSlotTracker MST(&M);
EXPECT_PRINTER_EQ("!0 = distinct !{}", MAV0->print(OS, MST));
EXPECT_PRINTER_EQ("!1 = distinct !{}", MAV1->print(OS, MST));
- EXPECT_PRINTER_EQ("!0", MAV0->printAsOperand(OS, false, MST));
- EXPECT_PRINTER_EQ("!1", MAV1->printAsOperand(OS, false, MST));
- EXPECT_PRINTER_EQ("metadata !0", MAV0->printAsOperand(OS, true, MST));
- EXPECT_PRINTER_EQ("metadata !1", MAV1->printAsOperand(OS, true, MST));
+ EXPECT_PRINTER_EQ("distinct !{}", MAV0->printAsOperand(OS, false, MST));
+ EXPECT_PRINTER_EQ("distinct !{}", MAV1->printAsOperand(OS, false, MST));
+ EXPECT_PRINTER_EQ("metadata distinct !{}",
+ MAV0->printAsOperand(OS, true, MST));
+ EXPECT_PRINTER_EQ("metadata distinct !{}",
+ MAV1->printAsOperand(OS, true, MST));
}
TEST_F(MDNodeTest, PrintWithDroppedCallOperand) {