Implement an incremental compilation cache for Cranelift (#4551)

This is the implementation of https://github.com/bytecodealliance/wasmtime/issues/4155, using the "inverted API" approach suggested by @cfallin (thanks!) in Cranelift, and trait object to provide a backend for an all-included experience in Wasmtime. 

After the suggestion of Chris, `Function` has been split into mostly two parts:

- on the one hand, `FunctionStencil` contains all the fields required during compilation, and that act as a compilation cache key: if two function stencils are the same, then the result of their compilation (`CompiledCodeBase<Stencil>`) will be the same. This makes caching trivial, as the only thing to cache is the `FunctionStencil`.
- on the other hand, `FunctionParameters` contain the... function parameters that are required to finalize the result of compilation into a `CompiledCode` (aka `CompiledCodeBase<Final>`) with proper final relocations etc., by applying fixups and so on.

Most changes are here to accomodate those requirements, in particular that `FunctionStencil` should be `Hash`able to be used as a key in the cache:

- most source locations are now relative to a base source location in the function, and as such they're encoded as `RelSourceLoc` in the `FunctionStencil`. This required changes so that there's no need to explicitly mark a `SourceLoc` as the base source location, it's automatically detected instead the first time a non-default `SourceLoc` is set.
- user-defined external names in the `FunctionStencil` (aka before this patch `ExternalName::User { namespace, index }`) are now references into an external table of `UserExternalNameRef -> UserExternalName`, present in the `FunctionParameters`, and must be explicitly declared using `Function::declare_imported_user_function`.
- some refactorings have been made for function names:
  - `ExternalName` was used as the type for a `Function`'s name; while it thus allowed `ExternalName::Libcall` in this place, this would have been quite confusing to use it there. Instead, a new enum `UserFuncName` is introduced for this name, that's either a user-defined function name (the above `UserExternalName`) or a test case name.
  - The future of `ExternalName` is likely to become a full reference into the `FunctionParameters`'s mapping, instead of being "either a handle for user-defined external names, or the thing itself for other variants". I'm running out of time to do this, and this is not trivial as it implies touching ISLE which I'm less familiar with.

The cache computes a sha256 hash of the `FunctionStencil`, and uses this as the cache key. No equality check (using `PartialEq`) is performed in addition to the hash being the same, as we hope that this is sufficient data to avoid collisions.

A basic fuzz target has been introduced that tries to do the bare minimum:

- check that a function successfully compiled and cached will be also successfully reloaded from the cache, and returns the exact same function.
- check that a trivial modification in the external mapping of `UserExternalNameRef -> UserExternalName` hits the cache, and that other modifications don't hit the cache.
  - This last check is less efficient and less likely to happen, so probably should be rethought a bit.

Thanks to both @alexcrichton and @cfallin for your very useful feedback on Zulip.

Some numbers show that for a large wasm module we're using internally, this is a 20% compile-time speedup, because so many `FunctionStencil`s are the same, even within a single module. For a group of modules that have a lot of code in common, we get hit rates up to 70% when they're used together. When a single function changes in a wasm module, every other function is reloaded; that's still slower than I expect (between 10% and 50% of the overall compile time), so there's likely room for improvement. 

Fixes #4155.
This commit is contained in:
Benjamin Bouvier
2022-08-12 18:47:43 +02:00
committed by GitHub
parent ac9725840d
commit 8a9b1a9025
103 changed files with 2176 additions and 693 deletions

View File

@@ -14,7 +14,7 @@ block0(v0: i64):
; stp fp, lr, [sp, #-16]!
; mov fp, sp
; block0:
; ldr x5, 8 ; b 12 ; data TestCase { length: 1, ascii: [103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x5, 8 ; b 12 ; data TestCase(TestcaseName { length: 1, ascii: [103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x5
; ldp fp, lr, [sp], #16
; autiasp ; ret

View File

@@ -14,7 +14,7 @@ block0(v0: i64):
; stp fp, lr, [sp, #-16]!
; mov fp, sp
; block0:
; ldr x5, 8 ; b 12 ; data TestCase { length: 1, ascii: [103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x5, 8 ; b 12 ; data TestCase(TestcaseName { length: 1, ascii: [103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x5
; ldp fp, lr, [sp], #16
; ret
@@ -30,7 +30,7 @@ block0(v0: i32):
; stp fp, lr, [sp, #-16]!
; mov fp, sp
; block0:
; ldr x5, 8 ; b 12 ; data TestCase { length: 1, ascii: [103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x5, 8 ; b 12 ; data TestCase(TestcaseName { length: 1, ascii: [103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x5
; ldp fp, lr, [sp], #16
; ret
@@ -54,7 +54,7 @@ block0(v0: i32):
; stp fp, lr, [sp, #-16]!
; mov fp, sp
; block0:
; ldr x5, 8 ; b 12 ; data TestCase { length: 1, ascii: [103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x5, 8 ; b 12 ; data TestCase(TestcaseName { length: 1, ascii: [103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x5
; ldp fp, lr, [sp], #16
; ret
@@ -91,7 +91,7 @@ block0(v0: i8):
; movz x6, #42
; movz x7, #42
; strb w15, [sp]
; ldr x15, 8 ; b 12 ; data TestCase { length: 1, ascii: [103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x15, 8 ; b 12 ; data TestCase(TestcaseName { length: 1, ascii: [103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x15
; add sp, sp, #16
; virtual_sp_offset_adjust -16
@@ -140,25 +140,25 @@ block0:
; mov fp, sp
; sub sp, sp, #48
; block0:
; ldr x9, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x9, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x9
; str q0, [sp]
; ldr x11, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x11, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x11
; str q0, [sp, #16]
; ldr x13, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x13, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x13
; str q0, [sp, #32]
; ldr x15, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x15, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x15
; ldr q0, [sp]
; ldr x1, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x1, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x1
; ldr q0, [sp, #16]
; ldr x3, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x3, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x3
; ldr q0, [sp, #32]
; ldr x5, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x5, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x5
; add sp, sp, #48
; ldp fp, lr, [sp], #16
@@ -184,25 +184,25 @@ block0:
; mov fp, sp
; sub sp, sp, #48
; block0:
; ldr x9, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x9, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x9
; str q0, [sp]
; ldr x11, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x11, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x11
; str q0, [sp, #16]
; ldr x13, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x13, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x13
; str q0, [sp, #32]
; ldr x15, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x15, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x15
; ldr q0, [sp]
; ldr x1, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x1, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x1
; ldr q0, [sp, #16]
; ldr x3, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x3, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x3
; ldr q0, [sp, #32]
; ldr x5, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x5, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x5
; add sp, sp, #48
; ldp fp, lr, [sp], #16
@@ -232,25 +232,25 @@ block0:
; mov fp, sp
; sub sp, sp, #48
; block0:
; ldr x9, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x9, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x9
; str q0, [sp]
; ldr x11, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x11, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x11
; str q0, [sp, #16]
; ldr x13, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x13, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x13
; str q0, [sp, #32]
; ldr x15, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x15, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x15
; ldr q0, [sp]
; ldr x1, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x1, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x1
; ldr q0, [sp, #16]
; ldr x3, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x3, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x3
; ldr q0, [sp, #32]
; ldr x5, 8 ; b 12 ; data TestCase { length: 2, ascii: [103, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x5, 8 ; b 12 ; data TestCase(TestcaseName { length: 2, ascii: [103, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x5
; add sp, sp, #48
; ldp fp, lr, [sp], #16
@@ -283,7 +283,7 @@ block0(v0: i64):
; movz x0, #42
; movz x2, #42
; mov x1, x7
; ldr x10, 8 ; b 12 ; data TestCase { length: 3, ascii: [102, 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x10, 8 ; b 12 ; data TestCase(TestcaseName { length: 3, ascii: [102, 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x10
; ldp fp, lr, [sp], #16
; ret
@@ -315,7 +315,7 @@ block0(v0: i64):
; movz x3, #42
; movz x0, #42
; mov x2, x7
; ldr x10, 8 ; b 12 ; data TestCase { length: 3, ascii: [102, 49, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x10, 8 ; b 12 ; data TestCase(TestcaseName { length: 3, ascii: [102, 49, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x10
; ldp fp, lr, [sp], #16
; ret
@@ -347,7 +347,7 @@ block0(v0: i64):
; movz x2, #42
; movz x0, #42
; mov x1, x7
; ldr x10, 8 ; b 12 ; data TestCase { length: 3, ascii: [102, 49, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x10, 8 ; b 12 ; data TestCase(TestcaseName { length: 3, ascii: [102, 49, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x10
; ldp fp, lr, [sp], #16
; ret
@@ -388,7 +388,7 @@ block0(v0: i128, v1: i64):
; mov x6, x14
; str x13, [sp]
; str x15, [sp, #8]
; ldr x7, 8 ; b 12 ; data TestCase { length: 3, ascii: [102, 49, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x7, 8 ; b 12 ; data TestCase(TestcaseName { length: 3, ascii: [102, 49, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x7
; add sp, sp, #16
; virtual_sp_offset_adjust -16
@@ -431,7 +431,7 @@ block0(v0: i128, v1: i64):
; mov x6, x14
; str x13, [sp]
; str x15, [sp, #8]
; ldr x7, 8 ; b 12 ; data TestCase { length: 3, ascii: [102, 49, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x7, 8 ; b 12 ; data TestCase(TestcaseName { length: 3, ascii: [102, 49, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x7
; add sp, sp, #16
; virtual_sp_offset_adjust -16
@@ -477,7 +477,7 @@ block0(v0: i64):
; mov fp, sp
; block0:
; mov x8, x0
; ldr x5, 8 ; b 12 ; data TestCase { length: 1, ascii: [103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x5, 8 ; b 12 ; data TestCase(TestcaseName { length: 1, ascii: [103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x5
; mov x0, x8
; ldp fp, lr, [sp], #16
@@ -496,7 +496,7 @@ block0(v0: i64):
; str x24, [sp, #-16]!
; block0:
; mov x24, x8
; ldr x5, 8 ; b 12 ; data TestCase { length: 1, ascii: [103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x5, 8 ; b 12 ; data TestCase(TestcaseName { length: 1, ascii: [103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x5
; mov x8, x24
; ldr x24, [sp], #16

View File

@@ -69,7 +69,7 @@ block3(v7: r64, v8: r64):
; block0:
; str x1, [sp, #16]
; str x0, [sp, #8]
; ldr x3, 8 ; b 12 ; data TestCase { length: 1, ascii: [102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x3, 8 ; b 12 ; data TestCase(TestcaseName { length: 1, ascii: [102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x3
; mov x9, sp
; ldr x11, [sp, #8]

View File

@@ -42,7 +42,7 @@ block0(v0: i64):
; subs xzr, sp, x0, UXTX
; b.hs 8 ; udf
; block0:
; ldr x2, 8 ; b 12 ; data TestCase { length: 3, ascii: [102, 111, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x2, 8 ; b 12 ; data TestCase(TestcaseName { length: 3, ascii: [102, 111, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x2
; ldp fp, lr, [sp], #16
; ret
@@ -65,7 +65,7 @@ block0(v0: i64):
; subs xzr, sp, x16, UXTX
; b.hs 8 ; udf
; block0:
; ldr x2, 8 ; b 12 ; data TestCase { length: 3, ascii: [102, 111, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x2, 8 ; b 12 ; data TestCase(TestcaseName { length: 3, ascii: [102, 111, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }) + 0
; blr x2
; ldp fp, lr, [sp], #16
; ret

View File

@@ -11,6 +11,6 @@ block0:
}
; block0:
; ldr x0, 8 ; b 12 ; data TestCase { length: 9, ascii: [109, 121, 95, 103, 108, 111, 98, 97, 108, 0, 0, 0, 0, 0, 0, 0] } + 0
; ldr x0, 8 ; b 12 ; data TestCase(TestcaseName { length: 9, ascii: [109, 121, 95, 103, 108, 111, 98, 97, 108, 0, 0, 0, 0, 0, 0, 0] }) + 0
; ret

View File

@@ -19,7 +19,7 @@ block0(v0: i32):
; stp d8, d9, [sp, #-16]!
; block0:
; mov x25, x0
; x0 = elf_tls_get_addr u1:0
; x0 = elf_tls_get_addr userextname0
; mov x1, x0
; mov x0, x25
; ldp d8, d9, [sp], #16

View File

@@ -39,7 +39,7 @@ block0(v0: i64):
; block0:
; mvc 160(63,%r15), 0(%r2)
; la %r2, 160(%r15)
; brasl %r14, u0:0
; brasl %r14, userextname0
; lmg %r14, %r15, 336(%r15)
; br %r14
@@ -57,7 +57,7 @@ block0(v0: i64, v1: i64):
; block0:
; mvc 160(63,%r15), 0(%r3)
; la %r3, 160(%r15)
; brasl %r14, u0:0
; brasl %r14, userextname0
; lmg %r14, %r15, 336(%r15)
; br %r14
@@ -91,7 +91,7 @@ block0(v0: i64, v1: i64, v2: i64):
; mvc 416(63,%r15), 0(%r4)
; la %r3, 160(%r15)
; la %r4, 416(%r15)
; brasl %r14, u0:0
; brasl %r14, userextname0
; lmg %r14, %r15, 592(%r15)
; br %r14
@@ -118,7 +118,7 @@ block0(v0: i64, v1: i64, v2: i64):
; lgr %r2, %r7
; la %r3, 160(%r15)
; la %r4, 1184(%r15)
; brasl %r14, u0:0
; brasl %r14, userextname0
; lmg %r7, %r15, 1304(%r15)
; br %r14

View File

@@ -15,8 +15,8 @@ block0(v0: i32):
; virtual_sp_offset_adjust 160
; block0:
; larl %r12, %ElfGlobalOffsetTable + 0
; bras %r1, 12 ; data u1:0@tlsgd ; lg %r2, 0(%r1)
; brasl %r14, %ElfTlsGetOffset:tls_gdcall:u1:0
; bras %r1, 12 ; data userextname0@tlsgd ; lg %r2, 0(%r1)
; brasl %r14, %ElfTlsGetOffset:tls_gdcall:userextname0
; ear %r3, %a0
; sllg %r4, %r3, 32
; ear %r4, %a1

View File

@@ -54,7 +54,7 @@ block0(v0: i64):
; movl $64, %edx
; load_ext_name %Memcpy+0, %rcx
; call *%rcx
; call User { namespace: 0, index: 0 }
; call User(userextname0)
; addq %rsp, $64, %rsp
; virtual_sp_offset_adjust -64
; movq %rbp, %rsp
@@ -82,7 +82,7 @@ block0(v0: i64, v1: i64):
; load_ext_name %Memcpy+0, %rcx
; call *%rcx
; movq %r12, %rdi
; call User { namespace: 0, index: 0 }
; call User(userextname0)
; addq %rsp, $64, %rsp
; virtual_sp_offset_adjust -64
; movq 0(%rsp), %r12
@@ -139,7 +139,7 @@ block0(v0: i64, v1: i64, v2: i64):
; load_ext_name %Memcpy+0, %rcx
; call *%rcx
; movq %r14, %rdi
; call User { namespace: 0, index: 0 }
; call User(userextname0)
; addq %rsp, $192, %rsp
; virtual_sp_offset_adjust -192
; movq 0(%rsp), %rbx

View File

@@ -14,7 +14,8 @@ block0(v0: i32):
; pushq %rbp
; movq %rsp, %rbp
; block0:
; %rax = coff_tls_get_addr User { namespace: 1, index: 0 }
; %rax = coff_tls_get_addr User(userextname0)
; movq %rbp, %rsp
; popq %rbp
; ret

View File

@@ -13,7 +13,7 @@ block0(v0: i32):
; pushq %rbp
; movq %rsp, %rbp
; block0:
; %rax = elf_tls_get_addr User { namespace: 1, index: 0 }
; %rax = elf_tls_get_addr User(userextname0)
; movq %rbp, %rsp
; popq %rbp
; ret

View File

@@ -40,7 +40,7 @@ function %symbol() -> i32 {
gv0 = symbol %something
; check: gv0 = symbol %something
gv1 = symbol u8:9
; check: gv1 = symbol u8:9
; check: gv1 = symbol userextname0
block0:
v0 = global_value.i32 gv0
; check: v0 = global_value.i32 gv0

View File

@@ -78,11 +78,11 @@ impl SingleFunctionCompiler {
let mut module = JITModule::new(builder);
let mut ctx = module.make_context();
let name = format!("{}", function.name);
let name = function.name.to_string();
let func_id = module.declare_function(&name, Linkage::Local, &function.signature)?;
// Build and declare the trampoline in the module
let trampoline_name = format!("{}", trampoline.name);
let trampoline_name = trampoline.name.to_string();
let trampoline_id =
module.declare_function(&trampoline_name, Linkage::Local, &trampoline.signature)?;
@@ -260,7 +260,7 @@ fn make_trampoline(signature: &ir::Signature, isa: &dyn TargetIsa) -> Function {
wrapper_sig.params.push(ir::AbiParam::new(pointer_type)); // Add the `callee_address` parameter.
wrapper_sig.params.push(ir::AbiParam::new(pointer_type)); // Add the `values_vec` parameter.
let mut func = ir::Function::with_name_signature(ir::ExternalName::user(0, 0), wrapper_sig);
let mut func = ir::Function::with_name_signature(ir::UserFuncName::default(), wrapper_sig);
// The trampoline has a single block filled with loads, one call to callee_address, and some loads.
let mut builder_context = FunctionBuilderContext::new();