[llvm] r259733 - [codeview] Don't attempt a cross-section label diff

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 3 16:21:42 PST 2016


Author: rnk
Date: Wed Feb  3 18:21:42 2016
New Revision: 259733

URL: http://llvm.org/viewvc/llvm-project?rev=259733&view=rev
Log:
[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

Added:
    llvm/trunk/test/MC/COFF/cv-inline-linetable-infloop.s
Modified:
    llvm/trunk/lib/MC/MCCodeView.cpp

Modified: llvm/trunk/lib/MC/MCCodeView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCCodeView.cpp?rev=259733&r1=259732&r2=259733&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCCodeView.cpp (original)
+++ llvm/trunk/lib/MC/MCCodeView.cpp Wed Feb  3 18:21:42 2016
@@ -236,8 +236,8 @@ void CodeViewContext::emitInlineLineTabl
       SecondaryFunctionIds, OS.getCurrentSectionOnly());
 }
 
-unsigned computeLabelDiff(MCAsmLayout &Layout, const MCSymbol *Begin,
-                          const MCSymbol *End) {
+static unsigned computeLabelDiff(MCAsmLayout &Layout, const MCSymbol *Begin,
+                                 const MCSymbol *End) {
   MCContext &Ctx = Layout.getAssembler().getContext();
   MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
   const MCExpr *BeginRef = MCSymbolRefExpr::create(Begin, Variant, Ctx),
@@ -338,9 +338,15 @@ void CodeViewContext::encodeInlineLineTa
       computeLabelDiff(Layout, LastLoc->getLabel(), Frag.getFnEndSym());
   unsigned LocAfterLength = ~0U;
   ArrayRef<MCCVLineEntry> LocAfter = getLinesForExtent(LocEnd, LocEnd + 1);
-  if (!LocAfter.empty())
-    LocAfterLength =
-        computeLabelDiff(Layout, LastLoc->getLabel(), LocAfter[0].getLabel());
+  if (!LocAfter.empty()) {
+    // Only try to compute this difference if we're in the same section.
+    const MCCVLineEntry &Loc = LocAfter[0];
+    if (&Loc.getLabel()->getSection(false) ==
+        &LastLoc->getLabel()->getSection(false)) {
+      LocAfterLength =
+          computeLabelDiff(Layout, LastLoc->getLabel(), Loc.getLabel());
+    }
+  }
 
   compressAnnotation(ChangeCodeLength, Buffer);
   compressAnnotation(std::min(EndSymLength, LocAfterLength), Buffer);

Added: llvm/trunk/test/MC/COFF/cv-inline-linetable-infloop.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/cv-inline-linetable-infloop.s?rev=259733&view=auto
==============================================================================
--- llvm/trunk/test/MC/COFF/cv-inline-linetable-infloop.s (added)
+++ llvm/trunk/test/MC/COFF/cv-inline-linetable-infloop.s Wed Feb  3 18:21:42 2016
@@ -0,0 +1,71 @@
+# RUN: llvm-mc -triple=x86_64-pc-win32 -filetype=obj < %s | llvm-readobj -codeview | FileCheck %s
+
+# CHECK:    InlineSite {
+# CHECK:      BinaryAnnotations [
+# CHECK:        ChangeLineOffset: 1
+# CHECK:        ChangeCodeLength: 0x2
+# CHECK:      ]
+# CHECK:    }
+
+	.text
+	.cv_file	1 "D:\\src\\llvm\\build\\t.c"
+
+	.def	 infloop;
+	.scl	2;
+	.type	32;
+	.endef
+	.section	.text,"xr",one_only,infloop
+	.globl	infloop
+	.p2align	4, 0x90
+infloop:                                    # @infloop
+.Lfunc_begin1:
+	.cv_loc	2 1 3 7                 # t.c:3:7
+	jmp	.Lfunc_begin1
+.Lfunc_end1:
+
+	.def	 afterinfloop;
+	.scl	2;
+	.type	32;
+	.endef
+	.section	.text,"xr",one_only,afterinfloop
+	.globl	afterinfloop
+	.p2align	4, 0x90
+afterinfloop:                                    # @afterinfloop
+	.cv_loc	3 1 13 0                # t.c:13:0
+	retq
+
+	.section	.debug$S,"dr"
+	.long 4
+	.long	241                     # Symbol subsection for infloop
+	.long	.Ltmp17-.Ltmp16         # Subsection size
+.Ltmp16:
+	.short	.Ltmp19-.Ltmp18         # Record length
+.Ltmp18:
+	.short	4423                    # Record kind: S_GPROC32_ID
+	.long	0                       # PtrParent
+	.long	0                       # PtrEnd
+	.long	0                       # PtrNext
+	.long	.Lfunc_end1-infloop         # Code size
+	.long	0                       # Offset after prologue
+	.long	0                       # Offset before epilogue
+	.long	0                       # Function type index
+	.secrel32	infloop             # Function section relative address
+	.secidx	infloop                     # Function section index
+	.byte	0                       # Flags
+	.asciz	"infloop"                   # Function name
+.Ltmp19:
+	.short	.Ltmp21-.Ltmp20         # Record length
+.Ltmp20:
+	.short	4429                    # Record kind: S_INLINESITE
+	.long	0                       # PtrParent
+	.long	0                       # PtrEnd
+	.long	4098                    # Inlinee type index
+	.cv_inline_linetable	2 1 2 .Lfunc_begin1 .Lfunc_end1
+.Ltmp21:
+	.short	2                       # Record length
+	.short	4430                    # Record kind: S_INLINESITE_END
+	.short	2                       # Record length
+	.short	4431                    # Record kind: S_PROC_ID_END
+.Ltmp17:
+	.p2align	2
+	.cv_linetable	1, infloop, .Lfunc_end1




More information about the llvm-commits mailing list