@@ -273,15 +273,14 @@ bool LoongArchAsmBackend::relaxDwarfLineAddr(MCFragment &F,
273
273
274
274
int64_t LineDelta = F.getDwarfLineDelta ();
275
275
const MCExpr &AddrDelta = F.getDwarfAddrDelta ();
276
- SmallVector<MCFixup, 1 > Fixups;
277
276
size_t OldSize = F.getVarSize ();
278
277
279
278
int64_t Value;
280
279
if (AddrDelta.evaluateAsAbsolute (Value, *Asm))
281
280
return false ;
282
- bool IsAbsolute = AddrDelta. evaluateKnownAbsolute (Value, *Asm);
283
- assert (IsAbsolute && " CFA with invalid expression " );
284
- ( void ) IsAbsolute;
281
+ [[maybe_unused]] bool IsAbsolute =
282
+ AddrDelta. evaluateKnownAbsolute (Value, *Asm );
283
+ assert ( IsAbsolute) ;
285
284
286
285
SmallVector<char > Data;
287
286
raw_svector_ostream OS (Data);
@@ -292,33 +291,23 @@ bool LoongArchAsmBackend::relaxDwarfLineAddr(MCFragment &F,
292
291
encodeSLEB128 (LineDelta, OS);
293
292
}
294
293
295
- unsigned Offset;
296
- std::pair<MCFixupKind, MCFixupKind> FK;
297
-
298
294
// According to the DWARF specification, the `DW_LNS_fixed_advance_pc` opcode
299
295
// takes a single unsigned half (unencoded) operand. The maximum encodable
300
296
// value is therefore 65535. Set a conservative upper bound for relaxation.
297
+ unsigned PCBytes;
301
298
if (Value > 60000 ) {
302
299
unsigned PtrSize = C.getAsmInfo ()->getCodePointerSize ();
303
-
304
- OS << uint8_t (dwarf::DW_LNS_extended_op);
305
- encodeULEB128 (PtrSize + 1 , OS);
306
-
307
- OS << uint8_t (dwarf::DW_LNE_set_address);
308
- Offset = OS.tell ();
309
300
assert ((PtrSize == 4 || PtrSize == 8 ) && " Unexpected pointer size" );
310
- FK = getRelocPairForSize (PtrSize == 4 ? 32 : 64 );
301
+ PCBytes = PtrSize;
302
+ OS << uint8_t (dwarf::DW_LNS_extended_op) << uint8_t (PtrSize + 1 )
303
+ << uint8_t (dwarf::DW_LNE_set_address);
311
304
OS.write_zeros (PtrSize);
312
305
} else {
306
+ PCBytes = 2 ;
313
307
OS << uint8_t (dwarf::DW_LNS_fixed_advance_pc);
314
- Offset = OS.tell ();
315
- FK = getRelocPairForSize (16 );
316
308
support::endian::write<uint16_t >(OS, 0 , llvm::endianness::little);
317
309
}
318
-
319
- const MCBinaryExpr &MBE = cast<MCBinaryExpr>(AddrDelta);
320
- Fixups.push_back (MCFixup::create (Offset, MBE.getLHS (), std::get<0 >(FK)));
321
- Fixups.push_back (MCFixup::create (Offset, MBE.getRHS (), std::get<1 >(FK)));
310
+ auto Offset = OS.tell () - PCBytes;
322
311
323
312
if (LineDelta == INT64_MAX) {
324
313
OS << uint8_t (dwarf::DW_LNS_extended_op);
@@ -329,7 +318,8 @@ bool LoongArchAsmBackend::relaxDwarfLineAddr(MCFragment &F,
329
318
}
330
319
331
320
F.setVarContents (Data);
332
- F.setVarFixups (Fixups);
321
+ F.setVarFixups ({MCFixup::create (Offset, &AddrDelta,
322
+ MCFixup::getDataKindForSize (PCBytes))});
333
323
WasRelaxed = OldSize != Data.size ();
334
324
return true ;
335
325
}
0 commit comments