@@ -331,15 +331,13 @@ bool RISCVAsmBackend::relaxDwarfLineAddr(MCFragment &F,
331
331
332
332
int64_t LineDelta = F.getDwarfLineDelta ();
333
333
const MCExpr &AddrDelta = F.getDwarfAddrDelta ();
334
- SmallVector<MCFixup, 1 > Fixups;
335
334
size_t OldSize = F.getVarSize ();
336
335
337
336
int64_t Value;
338
337
[[maybe_unused]] bool IsAbsolute =
339
338
AddrDelta.evaluateKnownAbsolute (Value, *Asm);
340
339
assert (IsAbsolute && " CFA with invalid expression" );
341
340
342
- Fixups.clear ();
343
341
SmallVector<char > Data;
344
342
raw_svector_ostream OS (Data);
345
343
@@ -349,33 +347,23 @@ bool RISCVAsmBackend::relaxDwarfLineAddr(MCFragment &F,
349
347
encodeSLEB128 (LineDelta, OS);
350
348
}
351
349
352
- unsigned Offset;
353
- std::pair<MCFixupKind, MCFixupKind> Fixup;
354
-
355
350
// According to the DWARF specification, the `DW_LNS_fixed_advance_pc` opcode
356
351
// takes a single unsigned half (unencoded) operand. The maximum encodable
357
352
// value is therefore 65535. Set a conservative upper bound for relaxation.
353
+ unsigned PCBytes;
358
354
if (Value > 60000 ) {
359
355
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 ();
366
356
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);
368
360
OS.write_zeros (PtrSize);
369
361
} else {
362
+ PCBytes = 2 ;
370
363
OS << uint8_t (dwarf::DW_LNS_fixed_advance_pc);
371
- Offset = OS.tell ();
372
- Fixup = RISCV::getRelocPairForSize (2 );
373
364
support::endian::write<uint16_t >(OS, 0 , llvm::endianness::little);
374
365
}
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;
379
367
380
368
if (LineDelta == INT64_MAX) {
381
369
OS << uint8_t (dwarf::DW_LNS_extended_op);
@@ -386,7 +374,8 @@ bool RISCVAsmBackend::relaxDwarfLineAddr(MCFragment &F,
386
374
}
387
375
388
376
F.setVarContents (Data);
389
- F.setVarFixups (Fixups);
377
+ F.setVarFixups ({MCFixup::create (Offset, &AddrDelta,
378
+ MCFixup::getDataKindForSize (PCBytes))});
390
379
WasRelaxed = OldSize != Data.size ();
391
380
return true ;
392
381
}
0 commit comments