Commit Graph

1482 Commits

Author SHA1 Message Date
Nick Fitzgerald
e3a423c3e8 Remove some uses of foo.expect(&format!(...)) pattern
This eagerly evaluates the `format!` and produces a `String` with a heap
allocation, regardless whether `foo` is `Some`/`Ok` or `None`/`Err`. Using
`foo.unwrap_or_else(|| panic!(...))` makes it so that the error message
formatting is only evaluated if `foo` is `None`/`Err`.
2021-10-25 17:35:23 -07:00
Chris Fallin
472b1b2e8a Avoid quadratic behavior in pathological label-alias case in MachBuffer.
Fixes #3468.

If a program has many instances of the pattern "goto next; next:" in a
row (i.e., no-op branches to the fallthrough address), the branch
simplification in `MachBuffer` would remove them all, as expected.
However, in order to work correctly, the algorithm needs to track all
labels that alias the current buffer tail, so that they can be adjusted
later if another branch chomp occurs.

When many thousands of this branch-to-next pattern occur, many thousands
of labels will reference the current buffer tail, and this list of
thousands of labels will be shuffled between the branch metadata struct
and the "labels at tail" struct as branches are appended and then
chomped immediately.

It's possible that with smarter data structure design, we could somehow
share the list of labels -- e.g., a single array of all labels, in order
they are bound, with ranges of indices in this array used to represent
lists of labels (actually, that seems like a better design in general);
but let's leave that to future optimization work.

For now, we can avoid the quadratic behavior by just "giving up" if the
list is too long; it's always valid to not optimize a branch. It is very
unlikely that the "normal" case will have more than 100 "goto next"
branches in a row, so this should not have any perf impact; if it does,
we will leave 1 out of every 100 such branches un-optimized in a long
sequence of thousands.

This takes total compilation time down on my machine from ~300ms to
~72ms for the `foo.wasm` case in #3441. For reference, the old backend
(now removed), built from arbitrarily-chosen-1-year-old commit
`c7fcc344`, takes 158ms, so we're ~twice as fast, which is what I would
expect.
2021-10-21 12:07:39 -07:00
Chris Fallin
e9921574d7 Update to regalloc.rs 0.0.32.
It appears that some allocation heuristics have changed slightly since
0.0.31, so some of the golden-output filetests are updated as well.
Ideally we would rely more on runtests rather than golden-compilation
tests; but for now this is sufficient. (I'm not sure exactly what in
regalloc.rs changed to alter these heuristics; it's actually been almost
a year since the 0.0.31 release with several refactorings and tweaks
merged since then.)

Fixes #3441.
2021-10-20 15:28:42 -07:00
Alex Crichton
fb585fde40 Update the wast crate dependency (#3464)
Pulls in a few minor fixes for stack overflows with module linking as
well as some updates to other various wasm proposals.
2021-10-20 11:25:52 -05:00
Alex Crichton
e8d3b8e3ea Fix an off-by-two condition in heap legalization (#3462)
This commit fixes an issue in Cranelift where legalization of
`heap_addr` instructions (used by wasm to represent heap accesses) could
be off-by-two where loads that should be valid were actually treated as
invalid. The bug here happened in an optimization where tests against
odd constants were being altered to tests against even constants by
subtracting one from the limit instead of adding one to the limit. The
comment around this area has been updated in accordance with a little
more math-stuff as well to help future readers.
2021-10-19 13:19:20 -05:00
Chris Fallin
14cde24377 Merge pull request #3447 from bjorn3/remove_unused_inst_flags
Remove various unused things from the meta crate
2021-10-13 11:31:31 -07:00
bjorn3
b2d9faa472 Slightly simplify build script 2021-10-12 15:12:26 +02:00
bjorn3
b0b8c1edbf Remove default_map 2021-10-12 15:12:26 +02:00
bjorn3
6b32fcfcea Remove Constraint 2021-10-12 15:12:26 +02:00
bjorn3
466a446f8c Remove OpcodeNumber 2021-10-12 15:12:26 +02:00
bjorn3
99114547be Remove clobbers_all_regs 2021-10-12 15:12:26 +02:00
bjorn3
e8b18b58a1 Remove is_ghost 2021-10-12 15:12:26 +02:00
bjorn3
a05bf2bf42 Remove instructions necessary for the old regalloc 2021-10-12 14:37:36 +02:00
bjorn3
1fd491dadd Remove fallthrough instruction 2021-10-12 14:22:07 +02:00
bjorn3
5b24e117ee Remove instructions used by old br_table legalization 2021-10-12 14:18:52 +02:00
Chris Fallin
5c2a629871 Merge pull request #2455 from Hywan/feat-cranelift-codegen-re-export-gimli
feat(cranelift-codegen) Re-export `gimli` when `unwind` feature is enabled
2021-10-11 13:09:16 -07:00
Alex Crichton
713ce07d35 Add some debug logging for timing in module compiles (#3417)
* Add some debug logging for timing in module compiles

This is sometimes helpful when debugging slow compiles from fuzz bugs or
similar.

* Fix total duration calculation to not double-count
2021-10-11 12:50:15 -05:00
bjorn3
20463d60f3 Replace StackSlots struct with a type alias 2021-10-11 16:41:45 +02:00
bjorn3
fd59a3e045 Remove all unused stackslot handling code 2021-10-11 16:41:45 +02:00
Pat Hickey
f3d06d61d2 Merge pull request #3428 from bjorn3/fix_cranelift_codegen_benches
Fix cranelift-codegen benches
2021-10-10 10:01:27 -07:00
Pat Hickey
d3f81a3cb9 Merge pull request #3435 from bjorn3/remove_various_dead_code
Remove various dead code
2021-10-10 10:00:42 -07:00
Pat Hickey
ccab8c5357 Merge pull request #3434 from bjorn3/remove_cssa_verifier
Remove the CSSA verifier
2021-10-10 10:00:19 -07:00
Pat Hickey
bca6946a9d Merge pull request #3432 from bjorn3/remove_reloc_constant
ConstantData related cleanups for the removal of the old backend
2021-10-10 09:59:13 -07:00
Pat Hickey
b7375817b1 Merge pull request #3431 from bjorn3/remove_sarg_t
Remove the sarg_t type and dummy_sarg_t instruction
2021-10-10 09:58:14 -07:00
Pat Hickey
b0fbab67ba Merge pull request #3429 from bjorn3/shrink_cranelift_codegen_shared
Move condcodes from cranelift-codegen-shared to cranelift-codegen
2021-10-10 09:56:44 -07:00
bjorn3
80709ab624 Rustfmt 2021-10-10 15:26:43 +02:00
bjorn3
54293a5929 Remove predicates module
It is dead code now
2021-10-10 15:25:29 +02:00
bjorn3
fad3868c1d Remove no longer existing passes from timing.rs 2021-10-10 15:25:29 +02:00
bjorn3
f7ce91e174 Remove the CSSA verifier
The old register allocator required CSSA as intermediate step. The new
register allocator doesn't use SSA at all.
2021-10-10 15:17:19 +02:00
bjorn3
355dd996a2 Fix tests 2021-10-10 15:00:25 +02:00
bjorn3
aa0486eb15 Remove offset fields from ConstantPool 2021-10-10 14:47:53 +02:00
bjorn3
d78f436daf Remove reloc_constant
It is no longer used by the new backends
2021-10-10 14:43:55 +02:00
bjorn3
8a8797b911 Remove the sarg_t type and dummy_sarg_t instruction
They are no longer necessary with the new style backends
2021-10-10 14:38:35 +02:00
bjorn3
eec3528254 Make ValueType::number unfailable 2021-10-10 14:37:41 +02:00
bjorn3
2b89b13c57 Move condcodes from cranelift-codegen-shared to cranelift-codegen 2021-10-10 14:23:35 +02:00
bjorn3
ed5764c79f Fix cranelift-codegen benches 2021-10-10 14:19:08 +02:00
Nick Fitzgerald
dbe01ff51e Remove references to the old postopt pass 2021-10-07 14:44:07 -07:00
Anton Kirilov
a986cf2438 Increase the default code section alignment to 64 KB for AArch64 targets (#3424)
Some platforms such as AArch64 Linux support different memory page
sizes, so we need to be conservative when choosing the code section
alignment (which is equal to the page size) by using the maximum.

Copyright (c) 2021, Arm Limited.
2021-10-07 12:49:40 -05:00
bjorn3
2db3b5b9df Remove code offsets from Function (#3412)
* Remove code offsets from Function

* Remove reloc_jt and fix wasmtime-cranelift
2021-10-07 15:54:00 +02:00
Chris Fallin
df5fa773ef Merge pull request #3413 from bjorn3/no_stack_layout
Remove StackLayoutInfo
2021-10-04 11:17:13 -07:00
bjorn3
a0f777b677 Remove BranchRange 2021-10-04 19:40:58 +02:00
bjorn3
c5c7508289 Remove StackLayoutInfo 2021-10-04 19:39:33 +02:00
bjorn3
b3702f5821 Remove old_signature 2021-10-04 19:39:33 +02:00
Benjamin Bouvier
772176dbfb Cranelift: remove unused EncCursor 2021-10-04 19:11:52 +02:00
Benjamin Bouvier
43a86f14d5 Remove more old backend ISA concepts (#3402)
This also paves the way for unifying TargetIsa and MachBackend, since now they map one to one. In theory the two traits could be merged, which would be nice to limit the number of total concepts. Also they have quite different responsibilities, so it might be fine to keep them separate.

Interestingly, this PR started as removing RegInfo from the TargetIsa trait since the adapter returned a dummy value there. From the fallout, noticed that all Display implementations didn't needed an ISA anymore (since these were only used to render ISA specific registers). Also the whole family of RegInfo / ValueLoc / RegUnit was exclusively used for the old backend, and these could be removed. Notably, some IR instructions needed to be removed, because they were using RegUnit too: this was the oddball of regfill / regmove / regspill / copy_special, which were IR instructions inserted by the old regalloc. Fare thee well!
2021-10-04 10:36:12 +02:00
Alex Crichton
5b3b459ad5 Fix some nightly dead code warnings (#3404)
* Fix some nightly dead code warnings

Looks like the "struct field not used" lint has improved on nightly and
caught a few more instances of fields that were never actually read.

* Fix windows
2021-10-01 14:26:30 -05:00
Benjamin Bouvier
bae4ec6427 Remove ancient register allocation (#3401) 2021-09-30 21:27:23 +02:00
Chris Fallin
b695ca4f9c Merge pull request #3398 from uweigand/s390x-addlogical
s390x: Enable most memory64 tests
2021-09-30 10:38:42 -07:00
Ulrich Weigand
d9e6902b69 s390x: Enable most memory64 tests
* Support full set of ADD LOGICAL / SUBTRACT LOGICAL instructions

* Full implementation of IaddIfcout lowering

* Enable most memory64 tests (except simd and threads)
2021-09-30 18:52:05 +02:00
bjorn3
d590e6bc1f Remove x86 old-backend special case from cranelift-codegen-meta 2021-09-30 18:29:49 +02:00