@@ -331,15 +331,13 @@ bool RISCVAsmBackend::relaxDwarfLineAddr(MCFragment &F,
331331
332332 int64_t LineDelta = F.getDwarfLineDelta ();
333333 const MCExpr &AddrDelta = F.getDwarfAddrDelta ();
334- SmallVector<MCFixup, 1 > Fixups;
335334 size_t OldSize = F.getVarSize ();
336335
337336 int64_t Value;
338337 [[maybe_unused]] bool IsAbsolute =
339338 AddrDelta.evaluateKnownAbsolute (Value, *Asm);
340339 assert (IsAbsolute && " CFA with invalid expression" );
341340
342- Fixups.clear ();
343341 SmallVector<char > Data;
344342 raw_svector_ostream OS (Data);
345343
@@ -349,33 +347,23 @@ bool RISCVAsmBackend::relaxDwarfLineAddr(MCFragment &F,
349347 encodeSLEB128 (LineDelta, OS);
350348 }
351349
352- unsigned Offset;
353- std::pair<MCFixupKind, MCFixupKind> Fixup;
354-
355350 // According to the DWARF specification, the `DW_LNS_fixed_advance_pc` opcode
356351 // takes a single unsigned half (unencoded) operand. The maximum encodable
357352 // value is therefore 65535. Set a conservative upper bound for relaxation.
353+ unsigned PCBytes;
358354 if (Value > 60000 ) {
359355 unsigned PtrSize = C.getAsmInfo ()->getCodePointerSize ();
360-
361- OS << uint8_t (dwarf::DW_LNS_extended_op);
362- encodeULEB128 (PtrSize + 1 , OS);
363-
364- OS << uint8_t (dwarf::DW_LNE_set_address);
365- Offset = OS.tell ();
366356 assert ((PtrSize == 4 || PtrSize == 8 ) && " Unexpected pointer size" );
367- Fixup = RISCV::getRelocPairForSize (PtrSize);
357+ PCBytes = PtrSize;
358+ OS << uint8_t (dwarf::DW_LNS_extended_op) << uint8_t (PtrSize + 1 )
359+ << uint8_t (dwarf::DW_LNE_set_address);
368360 OS.write_zeros (PtrSize);
369361 } else {
362+ PCBytes = 2 ;
370363 OS << uint8_t (dwarf::DW_LNS_fixed_advance_pc);
371- Offset = OS.tell ();
372- Fixup = RISCV::getRelocPairForSize (2 );
373364 support::endian::write<uint16_t >(OS, 0 , llvm::endianness::little);
374365 }
375-
376- const MCBinaryExpr &MBE = cast<MCBinaryExpr>(AddrDelta);
377- Fixups.push_back (MCFixup::create (Offset, MBE.getLHS (), std::get<0 >(Fixup)));
378- Fixups.push_back (MCFixup::create (Offset, MBE.getRHS (), std::get<1 >(Fixup)));
366+ auto Offset = OS.tell () - PCBytes;
379367
380368 if (LineDelta == INT64_MAX) {
381369 OS << uint8_t (dwarf::DW_LNS_extended_op);
@@ -386,7 +374,8 @@ bool RISCVAsmBackend::relaxDwarfLineAddr(MCFragment &F,
386374 }
387375
388376 F.setVarContents (Data);
389- F.setVarFixups (Fixups);
377+ F.setVarFixups ({MCFixup::create (Offset, &AddrDelta,
378+ MCFixup::getDataKindForSize (PCBytes))});
390379 WasRelaxed = OldSize != Data.size ();
391380 return true ;
392381}
0 commit comments