New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-6709] [DebugInfo] Capture Promotion doesn't preserve debug informations #49258
Comments
cc: @adrian-prantl/@eeckstein |
Output before stack promotion: *** SIL module before Guaranteed Passes transformation (0) ***
sil_scope 1 { loc "red.swift":1:6 parent @_T03red19captureStackPromoteSiycyF : $@convention(thin) () -> @owned @callee_guaranteed () -> Int }
sil_scope 2 { loc "red.swift":4:1 parent 1 }
// captureStackPromote()
sil hidden @_T03red19captureStackPromoteSiycyF : $@convention(thin) () -> @owned @callee_guaranteed () -> Int {
bb0:
%0 = alloc_box ${ var Int }, var, name "x", loc "red.swift":2:7, scope 2 // users: %13, %8, %1
%1 = project_box %0 : ${ var Int }, 0, loc "red.swift":2:7, scope 2 // users: %9, %6
%2 = metatype $@thin Int.Type, loc "red.swift":2:11, scope 2 // user: %5
%3 = integer_literal $Builtin.Int2048, 1, loc "red.swift":2:11, scope 2 // user: %5
// function_ref Int.init(_builtinIntegerLiteral:)
%4 = function_ref @_T0Si22_builtinIntegerLiteralSiBi2048__tcfC : $@convention(method) (Builtin.Int2048, @thin Int.Type) -> Int, loc "red.swift":2:11, scope 2 // user: %5
%5 = apply %4(%3, %2) : $@convention(method) (Builtin.Int2048, @thin Int.Type) -> Int, loc "red.swift":2:11, scope 2 // user: %6
store %5 to [trivial] %1 : $*Int, loc "red.swift":2:11, scope 2 // id: %6
// function_ref closure #​1 in captureStackPromote()
%7 = function_ref @_T03red19captureStackPromoteSiycyFSiycfU_ : $@convention(thin) (@guaranteed { var Int }) -> Int, loc "red.swift":3:11, scope 2 // user: %10
%8 = copy_value %0 : ${ var Int }, loc "red.swift":3:11, scope 2 // user: %10
mark_function_escape %1 : $*Int, loc "red.swift":3:11, scope 2 // id: %9
%10 = partial_apply [callee_guaranteed] %7(%8) : $@convention(thin) (@guaranteed { var Int }) -> Int, loc "red.swift":3:11, scope 2 // users: %12, %11
debug_value %10 : $@callee_guaranteed () -> Int, let, name "f", loc "red.swift":3:7, scope 2 // id: %11
destroy_value %10 : $@callee_guaranteed () -> Int, loc "red.swift":4:1, scope 2 // id: %12
destroy_value %0 : ${ var Int }, loc "red.swift":4:1, scope 2 // id: %13
unreachable , loc "red.swift":4:1, scope 2 // id: %14
} // end sil function '_T03red19captureStackPromoteSiycyF'
sil_scope 1 { loc "red.swift":3:11 parent @_T03red19captureStackPromoteSiycyFSiycfU_ : $@convention(thin) (@guaranteed { var Int }) -> Int }
sil_scope 2 { loc "red.swift":3:15 parent 1 } |
It seems that the `project_box` instruction introduced by the pass gets the wrong scope %8 = project_box %7 : ${ var Int }, 0, loc "red.swift":3:11, scope 1 // user: %11 I'll debug this further now that I have a nicely reduced test case 🙂 |
That looks like a legit bug. Probably the fix is a variant of `s/SILBuilder/SILBuilderWithScope/g`. |
@swift-ci create |
This was a case where we didn't attach the correct scope when creating the `project_box` instruction 🙁 Patch: $ git diff
diff --git a/lib/SILOptimizer/IPO/CapturePromotion.cpp b/lib/SILOptimizer/IPO/CapturePromotion.cpp
index 0875a1f9a1..2b16ad8672 100644
--- a/lib/SILOptimizer/IPO/CapturePromotion.cpp
+++ b/lib/SILOptimizer/IPO/CapturePromotion.cpp
@@ -1175,7 +1175,7 @@ constructClonedFunction(PartialApplyInst *PAI, FunctionRefInst *FRI,
static SILValue getOrCreateProjectBoxHelper(SILValue PartialOperand) {
// If we have a copy_value, just create a project_box on the copy and return.
if (auto *CVI = dyn_cast<CopyValueInst>(PartialOperand)) {
- SILBuilder B(std::next(CVI->getIterator()));
+ SILBuilderWithScope B(std::next(CVI->getIterator()));
return B.createProjectBox(CVI->getLoc(), CVI, 0);
} I'll submit a PR soon |
Fixed. #13802 |
Additional Detail from JIRA
md5: c8597b2abafcdc1100387a399c53ea2a
Issue Description:
cmdline:
testcase:
The text was updated successfully, but these errors were encountered: