@@ -344,6 +344,12 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
344
344
// / Convert a SILLocation into the corresponding LLVM Loc.
345
345
FileAndLocation computeLLVMLoc (const SILDebugScope *DS, SILLocation Loc);
346
346
347
+ // / Compute the LLVM DebugLoc when targeting CodeView. In CodeView, zero is
348
+ // / not an artificial line location; attempt to avoid those line locations near
349
+ // / user code to reduce the number of breaks in the linetables.
350
+ FileAndLocation computeLLVMLocCodeView (const SILDebugScope *DS,
351
+ SILLocation Loc);
352
+
347
353
static StringRef getFilenameFromDC (const DeclContext *DC) {
348
354
if (auto *LF = dyn_cast<LoadedFile>(DC))
349
355
return LF->getFilename ();
@@ -2614,11 +2620,21 @@ bool IRGenDebugInfoImpl::lineEntryIsSane(FileAndLocation DL,
2614
2620
}
2615
2621
#endif
2616
2622
2623
+ IRGenDebugInfoImpl::FileAndLocation
2624
+ IRGenDebugInfoImpl::computeLLVMLocCodeView (const SILDebugScope *DS,
2625
+ SILLocation Loc) {
2626
+ // If the scope has not changed and the line number is either zero or
2627
+ // artificial, we want to keep the most recent debug location.
2628
+ if (DS == LastScope &&
2629
+ (Loc.is <ArtificialUnreachableLocation>() || Loc.isLineZero (SM)))
2630
+ return LastFileAndLocation;
2631
+
2632
+ // Decode the location.
2633
+ return decodeFileAndLocation (Loc);
2634
+ }
2635
+
2617
2636
IRGenDebugInfoImpl::FileAndLocation
2618
2637
IRGenDebugInfoImpl::computeLLVMLoc (const SILDebugScope *DS, SILLocation Loc) {
2619
- // NOTE: In CodeView, zero is not an artificial line location. We try to
2620
- // avoid those line locations near user code to reduce the number
2621
- // of breaks in the linetables.
2622
2638
SILFunction *Fn = DS->getInlinedFunction ();
2623
2639
if (Fn && (Fn->isThunk () || Fn->isTransparent ()))
2624
2640
return {0 , 0 , CompilerGeneratedFile};
@@ -2628,24 +2644,14 @@ IRGenDebugInfoImpl::computeLLVMLoc(const SILDebugScope *DS, SILLocation Loc) {
2628
2644
if (DS == LastScope && Loc.isHiddenFromDebugInfo ())
2629
2645
return LastFileAndLocation;
2630
2646
2631
- // If the scope has not changed and the line number is either zero or
2632
- // artificial, we want to keep the most recent debug location.
2633
- if (DS == LastScope &&
2634
- (Loc.is <ArtificialUnreachableLocation>() || Loc.isLineZero (SM)) &&
2635
- Opts.DebugInfoFormat == IRGenDebugInfoFormat::CodeView)
2636
- return LastFileAndLocation;
2647
+ if (Opts.DebugInfoFormat == IRGenDebugInfoFormat::CodeView)
2648
+ return computeLLVMLocCodeView (DS, Loc);
2637
2649
2638
- FileAndLocation L;
2639
- // Decode the location.
2640
- if (!Loc.isInPrologue () ||
2641
- Opts.DebugInfoFormat == IRGenDebugInfoFormat::CodeView)
2642
- L = decodeFileAndLocation (Loc);
2643
-
2644
- // Otherwise use a line 0 artificial location, but the file from the
2645
- // location. If we are emitting CodeView, we do not want to use line zero
2646
- // since it does not represent an artificial line location.
2647
- if (Loc.isHiddenFromDebugInfo () &&
2648
- Opts.DebugInfoFormat != IRGenDebugInfoFormat::CodeView) {
2650
+ FileAndLocation L =
2651
+ Loc.isInPrologue () ? FileAndLocation () : decodeFileAndLocation (Loc);
2652
+
2653
+ // Otherwise use a line 0 artificial location, but the file from the location.
2654
+ if (Loc.isHiddenFromDebugInfo ()) {
2649
2655
L.Line = 0 ;
2650
2656
L.Column = 0 ;
2651
2657
}
0 commit comments