-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Carry MemFlag
s on loads/stores in MachInst backends, and emit trap info only where needed.
#2426
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cfallin
force-pushed
the
machinst-trap-info
branch
from
November 17, 2020 19:11
ec12e11
to
1b16229
Compare
github-actions
bot
added
cranelift
Issues related to the Cranelift code generator
cranelift:area:aarch64
Issues related to AArch64 backend.
cranelift:area:x64
Issues related to x64 codegen
labels
Nov 17, 2020
… unless an op can trap. This end result was previously enacted by carrying a `SourceLoc` on every load/store, which was somewhat cumbersome, and only indirectly encoded metadata about a memory reference (can it trap) by its presence or absence. We have a type for this -- `MemFlags` -- that tells us everything we might want to know about a load or store, and we should plumb it through to code emission instead. This PR attaches a `MemFlags` to an `Amode` on x64, and puts it on load and store `Inst` variants on aarch64. These two choices seem to factor things out in the nicest way: there are relatively few load/store insts on aarch64 but many addressing modes, while the opposite is true on x64.
cfallin
force-pushed
the
machinst-trap-info
branch
from
November 17, 2020 19:43
1b16229
to
073c727
Compare
julian-seward1
approved these changes
Nov 18, 2020
jameysharp
added a commit
to jameysharp/wasmtime
that referenced
this pull request
Mar 13, 2024
In bytecodealliance#2426, @cfallin wrote: > […] don't emit trap info unless an op can trap. > > This end result was previously enacted by carrying a SourceLoc on > every load/store, which was somewhat cumbersome, and only indirectly > encoded metadata about a memory reference (can it trap) by its > presence or absence. That PR changed both backends that existed at the time to check both the source location and the memory flags to determine whether a memory access could trap. Then in bytecodealliance#2685, @cfallin wrote: > Finally, while working out why trap records were not appearing, I had > noticed that isa::x64::emit_std_enc_mem() was only emitting heap-OOB > trap metadata for loads/stores when it had a srcloc. This PR ensures > that the metadata is emitted even when the srcloc is empty. However that PR did not apply the same change to other backends. Since then, the pattern from bytecodealliance#2426 has been copied to new backends. I believe checking the source location has been unnecessary since bytecodealliance#2426 and is now just a source of confusion at best, and possibly bugs at worst. So this PR makes all targets match the behavior of the x64 backend. In addition, this pattern was the only reason why source locations were provided to any backend's emit state, so I'm removing that entirely. The `cur_srcloc` field has been unused on x64 since bytecodealliance#2685. This change is mostly straightforward, but there are two questionable changes in the riscv64 backend: - The riscv64 backend had one use of this pattern for a BadConversionToInteger trap. All other uses on all backends were for HeapOutOfBounds traps. I suspect that was a copy-paste bug so I've removed it just like all the others. - The riscv64 `Inst::Atomic` does not have a MemFlags field, so this means the HeapOutOfBounds trap metadata is added unconditionally for such instructions.
github-merge-queue bot
pushed a commit
that referenced
this pull request
Mar 13, 2024
* cranelift: Remove srcloc from emit state on all targets In #2426, @cfallin wrote: > […] don't emit trap info unless an op can trap. > > This end result was previously enacted by carrying a SourceLoc on > every load/store, which was somewhat cumbersome, and only indirectly > encoded metadata about a memory reference (can it trap) by its > presence or absence. That PR changed both backends that existed at the time to check both the source location and the memory flags to determine whether a memory access could trap. Then in #2685, @cfallin wrote: > Finally, while working out why trap records were not appearing, I had > noticed that isa::x64::emit_std_enc_mem() was only emitting heap-OOB > trap metadata for loads/stores when it had a srcloc. This PR ensures > that the metadata is emitted even when the srcloc is empty. However that PR did not apply the same change to other backends. Since then, the pattern from #2426 has been copied to new backends. I believe checking the source location has been unnecessary since #2426 and is now just a source of confusion at best, and possibly bugs at worst. So this PR makes all targets match the behavior of the x64 backend. In addition, this pattern was the only reason why source locations were provided to any backend's emit state, so I'm removing that entirely. The `cur_srcloc` field has been unused on x64 since #2685. This change is mostly straightforward, but there are two questionable changes in the riscv64 backend: - The riscv64 backend had one use of this pattern for a BadConversionToInteger trap. All other uses on all backends were for HeapOutOfBounds traps. I suspect that was a copy-paste bug so I've removed it just like all the others. - The riscv64 `Inst::Atomic` does not have a MemFlags field, so this means the HeapOutOfBounds trap metadata is added unconditionally for such instructions. * Filetests don't have srclocs so they get traps now
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
cranelift:area:aarch64
Issues related to AArch64 backend.
cranelift:area:x64
Issues related to x64 codegen
cranelift
Issues related to the Cranelift code generator
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
x64 and aarch64: carry MemFlags on loads/stores; don't emit trap info unless an op can trap.
This end result was previously enacted by carrying a
SourceLoc
onevery load/store, which was somewhat cumbersome, and only indirectly
encoded metadata about a memory reference (can it trap) by its presence
or absence. We have a type for this --
MemFlags
-- that tells useverything we might want to know about a load or store, and we should
plumb it through to code emission instead.
This PR attaches a
MemFlags
to anAmode
on x64, and puts it on loadand store
Inst
variants on aarch64. These two choices seem to factorthings out in the nicest way: there are relatively few load/store insts
on aarch64 but many addressing modes, while the opposite is true on x64.
Includes #2389 as prerequisite; will rebase out that commit once #2389 lands.