llvm.org GIT mirror llvm / e97eca6
[CodeGen] Unify printing format of debug-location in both MIR and -debug Use "debug-location" instead of "; dbg:" in MI::print. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322936 91177308-0d34-0410-b5e6-96231b3b80d8 Francis Visoiu Mistrih 2 years ago
3 changed file(s) with 37 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
685685 NeedComma = true;
686686 }
687687
688 if (MI.getDebugLoc()) {
688 if (const DebugLoc &DL = MI.getDebugLoc()) {
689689 if (NeedComma)
690690 OS << ',';
691691 OS << " debug-location ";
692 MI.getDebugLoc()->printAsOperand(OS, MST);
692 DL->printAsOperand(OS, MST);
693693 }
694694
695695 if (!MI.memoperands_empty()) {
14241424 }
14251425 }
14261426
1427 if (!SkipDebugLoc) {
1428 if (const DebugLoc &DL = getDebugLoc()) {
1429 if (!FirstOp)
1430 OS << ',';
1431 OS << " debug-location ";
1432 DL->printAsOperand(OS, MST);
1433 }
1434 }
1435
14271436 bool HaveSemi = false;
14281437 if (!memoperands_empty()) {
14291438 if (!HaveSemi) {
14391448 OS << " ";
14401449 }
14411450 }
1451
1452 if (SkipDebugLoc)
1453 return;
14421454
14431455 // Print debug location information.
14441456 if (isDebugValue() && getOperand(e - 2).isMetadata()) {
14561468 }
14571469 if (isIndirectDebugValue())
14581470 OS << " indirect";
1459 } else if (SkipDebugLoc) {
1460 return;
1461 } else if (debugLoc && MF) {
1462 if (!HaveSemi)
1463 OS << ";";
1464 OS << " dbg:";
1465 debugLoc.print(OS);
14661471 }
14671472
14681473 OS << '\n';
1313 #include "llvm/CodeGen/TargetInstrInfo.h"
1414 #include "llvm/CodeGen/TargetLowering.h"
1515 #include "llvm/CodeGen/TargetSubtargetInfo.h"
16 #include "llvm/IR/DebugInfoMetadata.h"
17 #include "llvm/IR/ModuleSlotTracker.h"
1618 #include "llvm/Support/TargetRegistry.h"
1719 #include "llvm/Support/TargetSelect.h"
1820 #include "llvm/Target/TargetMachine.h"
243245
244246 checkHashAndIsEqualMatch(VD2PU, VD2PD);
245247 }
248
249 TEST(MachineInstrPrintingTest, DebugLocPrinting) {
250 auto MF = createMachineFunction();
251
252 MCOperandInfo OpInfo{0, 0, MCOI::OPERAND_REGISTER, 0};
253 MCInstrDesc MCID = {0, 1, 1, 0, 0, 0,
254 0, nullptr, nullptr, &OpInfo, 0, nullptr};
255
256 LLVMContext Ctx;
257 DILocation *DIL = DILocation::get(Ctx, 1, 5, (Metadata *)nullptr, nullptr);
258 DebugLoc DL(DIL);
259 MachineInstr *MI = MF->CreateMachineInstr(MCID, DL);
260 MI->addOperand(*MF, MachineOperand::CreateReg(0, /*isDef*/ true));
261
262 std::string str;
263 raw_string_ostream OS(str);
264 MI->print(OS);
265 ASSERT_TRUE(
266 StringRef(OS.str()).startswith("%noreg = UNKNOWN debug-location "));
267 }
268
246269 } // end namespace