aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/CodeGen/MachineInstrTest.cpp
diff options
context:
space:
mode:
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>2018-04-24 11:00:46 +0000
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>2018-04-24 11:00:46 +0000
commit8ed0f741ae3c35bc95c724d867c769934df8373f (patch)
treee12f23f0d7adfe266b169ba30fb9149f07155982 /llvm/unittests/CodeGen/MachineInstrTest.cpp
parentfdfeefd6c29b2f26b69c63bd0a90a9915b94d956 (diff)
downloadllvm-8ed0f741ae3c35bc95c724d867c769934df8373f.zip
llvm-8ed0f741ae3c35bc95c724d867c769934df8373f.tar.gz
llvm-8ed0f741ae3c35bc95c724d867c769934df8373f.tar.bz2
[CodeGen] Print user-friendly debug locations as MI comments
If available, print the file, line and column of the DebugLoc attached to the MachineInstr: MOV16mr $rbp, 1, $noreg, -112, $noreg, killed renamable $ax, debug-location !56 :: (store 2 into %ir.._value12); stepping.swift:10:17 renamable $edx = MOVZX32rm16 $rbp, 1, $noreg, -112, $noreg, debug-location !62 :: (dereferenceable load 2 from %ir.._value13); stepping.swift:10:17 Differential Revision: https://reviews.llvm.org/D45992 llvm-svn: 330709
Diffstat (limited to 'llvm/unittests/CodeGen/MachineInstrTest.cpp')
-rw-r--r--llvm/unittests/CodeGen/MachineInstrTest.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/unittests/CodeGen/MachineInstrTest.cpp b/llvm/unittests/CodeGen/MachineInstrTest.cpp
index c0da2c3..6883d3e 100644
--- a/llvm/unittests/CodeGen/MachineInstrTest.cpp
+++ b/llvm/unittests/CodeGen/MachineInstrTest.cpp
@@ -255,7 +255,11 @@ TEST(MachineInstrPrintingTest, DebugLocPrinting) {
0, nullptr, nullptr, &OpInfo, 0, nullptr};
LLVMContext Ctx;
- DILocation *DIL = DILocation::get(Ctx, 1, 5, (Metadata *)nullptr, nullptr);
+ DIFile *DIF = DIFile::getDistinct(Ctx, "filename", "");
+ DISubprogram *DIS = DISubprogram::getDistinct(
+ Ctx, nullptr, "", "", DIF, 0, nullptr, false, false, 0, nullptr, 0, 0, 0,
+ DINode::FlagZero, false, nullptr);
+ DILocation *DIL = DILocation::get(Ctx, 1, 5, DIS);
DebugLoc DL(DIL);
MachineInstr *MI = MF->CreateMachineInstr(MCID, DL);
MI->addOperand(*MF, MachineOperand::CreateReg(0, /*isDef*/ true));
@@ -265,6 +269,8 @@ TEST(MachineInstrPrintingTest, DebugLocPrinting) {
MI->print(OS);
ASSERT_TRUE(
StringRef(OS.str()).startswith("$noreg = UNKNOWN debug-location "));
+ ASSERT_TRUE(
+ StringRef(OS.str()).endswith("filename:1:5"));
}
} // end namespace