Skip to content

Conversation

@kripken
Copy link
Member

@kripken kripken commented Jul 2, 2024

Previously the replacement select got the debug info, but we should also copy it
to the values, as often optimizations lead to one of those values remaining by
itself.

Similar to #6652 in general form.

Diff without whitespace is much shorter.

See the very last commit to see the impact on the new test.

@kripken kripken requested a review from aheejin July 2, 2024 17:51
assert(value.globals.size() == 1);
// Create a global.get with temporary name, leaving only the
// updating of the name to later work.
auto* get = builder.makeGlobalGet(value.globals[0],
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
auto* get = builder.makeGlobalGet(value.globals[0],
ret = builder.makeGlobalGet(value.globals[0],

Nit: Can we do this and remove ret = get below?

Copy link
Member Author

Choose a reason for hiding this comment

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

That almost works, but we need the type to be more specific than Expression* on line 441, where we use get in a place that must be GlobalGet*.

;; CHECK: (func $test (type $1) (param $struct (ref null $struct))
;; CHECK-NEXT: ;;@ drop.c:10:1
;; CHECK-NEXT: (drop
;; CHECK-NEXT: ;;@ struct.c:20:2
Copy link
Member

Choose a reason for hiding this comment

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

Why did the select have debug info even before this PR (and not the children)?

Copy link
Member Author

Choose a reason for hiding this comment

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

The select received it because replaceCurrent copies debug info, and we replace the struct.get with the select. But it doesn't copy recursively into children (we've considered that before, but it's not clear if it's correct, and would be slower).

Copy link
Member

Choose a reason for hiding this comment

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

I thought we were doing that..?

// Copy debug info, if present.
if (currFunction) {
debuginfo::copyOriginalToReplacement(
getCurrent(), expression, currFunction);
}

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, but not recursively, just on the replacement:

debugLocations[replacement] = iter->second;

So the select gets it, but not the select's children.

@kripken kripken merged commit 9792f2c into WebAssembly:main Jul 2, 2024
@kripken kripken deleted the gsi.debug branch July 2, 2024 22:42
@gkdn gkdn mentioned this pull request Aug 31, 2024
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.

2 participants