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