Skip to content

Commit f85c6b7

Browse files
committed
Fix a fragment overflow problem when composing super-registers.
Addresses #53342 Differential Revision: https://reviews.llvm.org/D118412
1 parent 6e4f7c0 commit f85c6b7

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,17 @@ bool DwarfExpression::addMachineRegExpression(const TargetRegisterInfo &TRI,
287287
// expression representing a value, rather than a location.
288288
if ((!isParameterValue() && !isMemoryLocation() && !HasComplexExpression) ||
289289
isEntryValue()) {
290+
auto FragmentInfo = ExprCursor.getFragmentInfo();
291+
unsigned RegSize = 0;
290292
for (auto &Reg : DwarfRegs) {
293+
RegSize += Reg.SubRegSize;
291294
if (Reg.DwarfRegNo >= 0)
292295
addReg(Reg.DwarfRegNo, Reg.Comment);
296+
if (FragmentInfo)
297+
if (RegSize > FragmentInfo->SizeInBits)
298+
// If the register is larger than the current fragment stop
299+
// once the fragment is covered.
300+
break;
293301
addOpPiece(Reg.SubRegSize);
294302
}
295303

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# RUN: llc -mtriple aarch64-linux-gnu -start-after=livedebugvalues -filetype=obj -o - %s \
2+
# RUN: | llvm-dwarfdump - | FileCheck %s
3+
# The value needs to be composed of sub-registers, but the
4+
# sub-registers cross the fragment boundary.
5+
# CHECK: DW_OP_piece 0x8, DW_OP_regx B16, DW_OP_piece 0x8
6+
--- |
7+
target triple = "aarch64-none-linux-android21"
8+
define linkonce_odr dso_local void @_f() !dbg !1590 {
9+
entry:
10+
ret void, !dbg !1809
11+
}
12+
declare i32 @__gxx_personality_v0(...)
13+
!llvm.dbg.cu = !{!0}
14+
!llvm.module.flags = !{!1586,!1587}
15+
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
16+
!1 = !DIFile(filename: "bug.cpp", directory: "/")
17+
!1586 = !{i32 2, !"Debug Info Version", i32 3}
18+
!1587 = !{i32 7, !"frame-pointer", i32 1}
19+
!1590 = distinct !DISubprogram(name: "f", scope: !0, file: !1, line: 278, type: !1591, scopeLine: 279, flags: DIFlagPrototyped, unit: !0, declaration: !1593)
20+
!1591 = !DISubroutineType(types: !1592)
21+
!1592 = !{null }
22+
!1593 = !DISubprogram(name: "f", linkageName: "_f", scope: !0, file: !1, line: 195, type: !1591, scopeLine: 195, flags:
23+
DIFlagProtected
24+
, spFlags: DISPFlagOptimized)
25+
!1694 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "uint8x8x3_t", file: !1, line: 235, size: 192, flags: DIFlagTypePassByValue, elements: !1695, identifier: "_ZTS11uint8x8x3_t")
26+
!1695 = !{}
27+
!1715 = !DILocalVariable(name: "__ret", scope: !1590, file: !1, line: 379, type: !1694)
28+
!1809 = !DILocation(line: 0, scope: !1590 )
29+
---
30+
name: _f
31+
body: |
32+
bb.0.entry:
33+
renamable $d16_d17_d18 = LD3Threev8b killed renamable $x15, debug-location !1809
34+
DBG_VALUE $d16_d17_d18, $noreg, !1715, !DIExpression(DW_OP_LLVM_fragment, 64, 64), debug-location !1809

0 commit comments

Comments
 (0)