Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 65ece99

Browse files
committed
[codeview] Don't attempt a cross-section label diff
This only comes up when we're trying to find the next .cv_loc label. Fixes PR26467 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259733 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 5a91878 commit 65ece99

File tree

2 files changed

+82
-5
lines changed

2 files changed

+82
-5
lines changed

lib/MC/MCCodeView.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ void CodeViewContext::emitInlineLineTableForFunction(
236236
SecondaryFunctionIds, OS.getCurrentSectionOnly());
237237
}
238238

239-
unsigned computeLabelDiff(MCAsmLayout &Layout, const MCSymbol *Begin,
240-
const MCSymbol *End) {
239+
static unsigned computeLabelDiff(MCAsmLayout &Layout, const MCSymbol *Begin,
240+
const MCSymbol *End) {
241241
MCContext &Ctx = Layout.getAssembler().getContext();
242242
MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
243243
const MCExpr *BeginRef = MCSymbolRefExpr::create(Begin, Variant, Ctx),
@@ -338,9 +338,15 @@ void CodeViewContext::encodeInlineLineTable(MCAsmLayout &Layout,
338338
computeLabelDiff(Layout, LastLoc->getLabel(), Frag.getFnEndSym());
339339
unsigned LocAfterLength = ~0U;
340340
ArrayRef<MCCVLineEntry> LocAfter = getLinesForExtent(LocEnd, LocEnd + 1);
341-
if (!LocAfter.empty())
342-
LocAfterLength =
343-
computeLabelDiff(Layout, LastLoc->getLabel(), LocAfter[0].getLabel());
341+
if (!LocAfter.empty()) {
342+
// Only try to compute this difference if we're in the same section.
343+
const MCCVLineEntry &Loc = LocAfter[0];
344+
if (&Loc.getLabel()->getSection(false) ==
345+
&LastLoc->getLabel()->getSection(false)) {
346+
LocAfterLength =
347+
computeLabelDiff(Layout, LastLoc->getLabel(), Loc.getLabel());
348+
}
349+
}
344350

345351
compressAnnotation(ChangeCodeLength, Buffer);
346352
compressAnnotation(std::min(EndSymLength, LocAfterLength), Buffer);
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# RUN: llvm-mc -triple=x86_64-pc-win32 -filetype=obj < %s | llvm-readobj -codeview | FileCheck %s
2+
3+
# CHECK: InlineSite {
4+
# CHECK: BinaryAnnotations [
5+
# CHECK: ChangeLineOffset: 1
6+
# CHECK: ChangeCodeLength: 0x2
7+
# CHECK: ]
8+
# CHECK: }
9+
10+
.text
11+
.cv_file 1 "D:\\src\\llvm\\build\\t.c"
12+
13+
.def infloop;
14+
.scl 2;
15+
.type 32;
16+
.endef
17+
.section .text,"xr",one_only,infloop
18+
.globl infloop
19+
.p2align 4, 0x90
20+
infloop: # @infloop
21+
.Lfunc_begin1:
22+
.cv_loc 2 1 3 7 # t.c:3:7
23+
jmp .Lfunc_begin1
24+
.Lfunc_end1:
25+
26+
.def afterinfloop;
27+
.scl 2;
28+
.type 32;
29+
.endef
30+
.section .text,"xr",one_only,afterinfloop
31+
.globl afterinfloop
32+
.p2align 4, 0x90
33+
afterinfloop: # @afterinfloop
34+
.cv_loc 3 1 13 0 # t.c:13:0
35+
retq
36+
37+
.section .debug$S,"dr"
38+
.long 4
39+
.long 241 # Symbol subsection for infloop
40+
.long .Ltmp17-.Ltmp16 # Subsection size
41+
.Ltmp16:
42+
.short .Ltmp19-.Ltmp18 # Record length
43+
.Ltmp18:
44+
.short 4423 # Record kind: S_GPROC32_ID
45+
.long 0 # PtrParent
46+
.long 0 # PtrEnd
47+
.long 0 # PtrNext
48+
.long .Lfunc_end1-infloop # Code size
49+
.long 0 # Offset after prologue
50+
.long 0 # Offset before epilogue
51+
.long 0 # Function type index
52+
.secrel32 infloop # Function section relative address
53+
.secidx infloop # Function section index
54+
.byte 0 # Flags
55+
.asciz "infloop" # Function name
56+
.Ltmp19:
57+
.short .Ltmp21-.Ltmp20 # Record length
58+
.Ltmp20:
59+
.short 4429 # Record kind: S_INLINESITE
60+
.long 0 # PtrParent
61+
.long 0 # PtrEnd
62+
.long 4098 # Inlinee type index
63+
.cv_inline_linetable 2 1 2 .Lfunc_begin1 .Lfunc_end1
64+
.Ltmp21:
65+
.short 2 # Record length
66+
.short 4430 # Record kind: S_INLINESITE_END
67+
.short 2 # Record length
68+
.short 4431 # Record kind: S_PROC_ID_END
69+
.Ltmp17:
70+
.p2align 2
71+
.cv_linetable 1, infloop, .Lfunc_end1

0 commit comments

Comments
 (0)