Skip to content

Conversation

Snowy1803
Copy link
Member

@Snowy1803 Snowy1803 commented May 8, 2024

An alloc_stack, just like a debug_value, should ignore location overrides for their variable.

Additionally, for this to work correctly, we need to use the variable's location and not the instruction's location when generating anonymous variables in IRGen (which uses getDecl).

To implement this more easily, the variable's location is always set, and when there is no override, the duplicate location information is removed in AllocStackInst::create.

Fixes #73338
rdar://127348128

Snowy1803 added 3 commits May 7, 2024 13:58
When a store is salvaged, its debug_value will have two locations:
the location of the store, attached to the debug_value instruction,
and the location of the variable, attached to the SILDebugVariable.

The getDecl function was using the location of the store, instead
of the location of the variable, and so was returning nullptr.
An alloc_stack, just like a debug_value, should ignore location
overrides for their variable.

Fixes swiftlang#73338
rdar://127348128
@Snowy1803 Snowy1803 requested a review from adrian-prantl as a code owner May 8, 2024 01:52
@Snowy1803
Copy link
Member Author

@swift-ci please test

1 similar comment
@Snowy1803
Copy link
Member Author

@swift-ci please test

return x as? T // expected-remark @:12 {{conditional runtime cast of value with type 'NS' to 'T'}}
// expected-note @-9:42 {{of 'ns2'}}
// expected-note @-5:42 {{of 'ns2'}}
// expected-note @-4:7 {{of 'x'}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, so this actually fixes another bug?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, now that getDecl() returns the correct variable declaration after a store, this pass is able to point back to the x value! After optimizations. the SILValue will be associated with both debug variables, so the pass prints both of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Building postgres-nio crashes 6.0 nightly

2 participants