When an object being finalized references an object declared as needing
a definition, the definition needs to be available. Add asserts to catch
this specific case.
Because of the way that the `pass` subcommand orders its arguments, the
positional "single-file" input cannot be optional with a default value, because
it is followed by required positional arguments. If it were optional, that would
result in argument ambiguity where `clap` cannot tell if the optional positional
argument is supplied, or if the given argument is the next required positional
argument.
Before this commit:
```
$ cargo run --bin clif-util -- pass ./filetests/dce/basic.clif dce
Compiling cranelift-tools v0.21.0 (file:///Users/fitzgen/src/cranelift)
Finished dev [unoptimized + debuginfo] target(s) in 4.38s
Running `target/debug/clif-util pass ./filetests/dce/basic.clif dce`
thread 'main' panicked at 'Found positional argument which is not required with a lower index than a required positional argument: "single-file" index 1', /Users/fitzgen/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.32.0/src/app/parser.rs:612:21
note: Run with `RUST_BACKTRACE=1` for a backtrace.
```
After this commit:
```
$ cargo run --bin clif-util -- pass ./filetests/dce/basic.clif dce
Compiling cranelift-filetests v0.21.0 (file:///Users/fitzgen/src/cranelift/lib/filetests)
Compiling cranelift-tools v0.21.0 (file:///Users/fitzgen/src/cranelift)
Finished dev [unoptimized + debuginfo] target(s) in 5.96s
Running `target/debug/clif-util pass ./filetests/dce/basic.clif dce`
1 tests
```
* Reorganize the global value kinds.
This:
- renames "deref" global values to "load" and gives it a offset that works
like the "load" instructions' does
- adds an explicit "iadd_imm" global value kind, which replaces the
builtin iadd in "vmctx" and "deref" global values.
- also renames "globalsym" to "symbol"
One of the big advantages of PrimaryMap is that it protects against
using the wrong indices via a distinct index type. A Deref trait that
returns a plain slice would accept other indices. Add a comment
explaining this.
Add `publish()` function to cranelift-module's `Backend` trait, which
allows `finalize_all()` to defer making memory executable until it
has finished all of the patching it needs to do.
This makes several changes:
- It adds an index_type to heap declarations, allowing heaps to specify the
type for indexing. This also anticipates 64-bit heap support.
- It adds a memory_type to deref global values, allowing deref globals to
have types other than pointers. This is used to allow the bound variable
in dynamic heaps to have type i32, to match the index type in heaps
with i32 index type.
- And, it fixes heap legalization to do the bounds check in the heap's
index type.