-
Notifications
You must be signed in to change notification settings - Fork 787
Fix IRBuilder location tracking of If starts #7617
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
Conversation
src/wasm/wasm-ir-builder.cpp
Outdated
auto end = BinaryLocation(*binaryPos - codeSectionOffset); | ||
// Some expressions already have their start noted, and we are just seeing | ||
// their last segment (like an Else). | ||
auto iter = func->expressionLocations.find(expr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's always do just one lookup by using .insert()
here to get an iterator, then fixing up just the end
if an entry already exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
// Note the start of the if (which will be lost as the If is closed and the | ||
// Else begins, but the if spans them both). | ||
func->expressionLocations[iff].start = scope.startPos - codeSectionOffset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we either fix this for try-catch
as well, or add a TODO to do so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a TODO. I'm not sure offhand how to handle multiple catches. Anyhow, only If is urgent atm.
@@ -259,6 +259,128 @@ | |||
) | |||
) | |||
|
|||
;; CHECK: (func $branch-hints-if-else (type $0) (param $x i32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to this test, can we have another test that directly shows the correct binary offsets? Or do we not have a way to print IR annotated with binary offsets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, we don't have an option to show binary offsets by a flag. We show them when DWARF sections exist, or code annotations, atm. Might be worth adding though.
The old code forgot the If scope when it started the Else, so any if-else would get
a binary location span that started in the else (and ends in the right place).
To fix this, note the if start location when we have it, and don't trample.
Fixes branch hints on if-elses.