2656: update(compiler) switched upstream Inkwell (for #2645) r=Amanieu a=ptitSeb

# Description
Use upstream Inkwell instead of custom version

Co-authored-by: ptitSeb <sebastien.chev@gmail.com>
This commit is contained in:
bors[bot]
2021-11-05 12:58:17 +00:00
committed by GitHub
5 changed files with 58 additions and 43 deletions

42
Cargo.lock generated
View File

@ -1001,10 +1001,25 @@ dependencies = [
]
[[package]]
name = "inkwell_internals"
version = "0.3.0"
name = "inkwell"
version = "0.1.0-beta.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2e1f71330ccec54ee62533ae88574c4169b67fb4b95cbb1196a1322582abd11"
checksum = "2223d0eba0ae6d40a3e4680c6a3209143471e1f38b41746ea309aa36dde9f90b"
dependencies = [
"either",
"inkwell_internals",
"libc",
"llvm-sys",
"once_cell",
"parking_lot",
"regex",
]
[[package]]
name = "inkwell_internals"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c7090af3d300424caa81976b8c97bca41cd70e861272c072e188ae082fb49f9"
dependencies = [
"proc-macro2",
"quote",
@ -1141,9 +1156,9 @@ dependencies = [
[[package]]
name = "llvm-sys"
version = "110.0.1"
version = "110.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21ede189444b8c78907e5d36da5dabcf153170fcff9c1dba48afc4b33c7e19f0"
checksum = "3b7cc88ba864d592f52132ed3a19a97118fe16c92a63961f54b0ab7279c5407f"
dependencies = [
"cc",
"lazy_static",
@ -2820,6 +2835,7 @@ version = "2.0.0"
dependencies = [
"byteorder",
"cc",
"inkwell",
"itertools",
"lazy_static",
"libc",
@ -2834,7 +2850,6 @@ dependencies = [
"wasmer-compiler",
"wasmer-types",
"wasmer-vm",
"wasmer_inkwell",
]
[[package]]
@ -3141,21 +3156,6 @@ dependencies = [
"wasmer-wast",
]
[[package]]
name = "wasmer_inkwell"
version = "0.2.0-alpha.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5eca826323f39b29a38cd31c8eb33de76945c6193f30a2806c6cde6f6cd42cb1"
dependencies = [
"either",
"inkwell_internals",
"libc",
"llvm-sys",
"once_cell",
"parking_lot",
"regex",
]
[[package]]
name = "wasmparser"
version = "0.78.2"

View File

@ -25,8 +25,8 @@ rayon = "1.5"
loupe = "0.1"
[dependencies.inkwell]
package = "wasmer_inkwell"
version = "0.2.0-alpha.2"
package = "inkwell"
version = "0.1.0-beta.4"
default-features = false
features = ["llvm11-0", "target-x86", "target-aarch64"]

View File

@ -14,6 +14,7 @@ use inkwell::{
AddressSpace, DLLStorageClass,
};
use std::cmp;
use std::convert::TryFrom;
use std::convert::TryInto;
use wasmer_compiler::{CompileError, FunctionBody, RelocationTarget};
use wasmer_types::{FunctionType, LocalFunctionIndex};
@ -346,7 +347,8 @@ impl FuncTrampoline {
args_vec.push(arg.into());
}
let call_site = builder.build_call(func_ptr, args_vec.as_slice().into(), "call");
let callable_func = inkwell::values::CallableValue::try_from(func_ptr).unwrap();
let call_site = builder.build_call(callable_func, args_vec.as_slice().into(), "call");
for (attr, attr_loc) in func_attrs {
call_site.add_attribute(*attr_loc, *attr);
}
@ -441,7 +443,8 @@ impl FuncTrampoline {
.into_pointer_value();
let values_ptr = builder.build_pointer_cast(values, intrinsics.i128_ptr_ty, "");
builder.build_call(callee, &[vmctx.into(), values_ptr.into()], "");
let callable_func = inkwell::values::CallableValue::try_from(callee).unwrap();
builder.build_call(callable_func, &[vmctx.into(), values_ptr.into()], "");
if func_sig.results().is_empty() {
builder.build_return(None);

View File

@ -24,6 +24,7 @@ use smallvec::SmallVec;
use crate::abi::{get_abi, Abi};
use crate::config::{CompiledKind, LLVM};
use crate::object_file::{load_object_file, CompiledFunction};
use std::convert::TryFrom;
use wasmer_compiler::wasmparser::{MemoryImmediate, Operator};
use wasmer_compiler::{
wptype_to_type, CompileError, FunctionBinaryReader, FunctionBodyData, MiddlewareBinaryReader,
@ -2225,8 +2226,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
}
*/
let callable_func = inkwell::values::CallableValue::try_from(func).unwrap();
let call_site = self.builder.build_call(
func,
callable_func,
params
.iter()
.copied()
@ -2517,8 +2519,10 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
}
}
*/
let callable_func =
inkwell::values::CallableValue::try_from(typed_func_ptr).unwrap();
let call_site = self.builder.build_call(
typed_func_ptr,
callable_func,
params
.iter()
.copied()
@ -10910,8 +10914,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
let memory_index = MemoryIndex::from_u32(mem);
let delta = self.state.pop1()?;
let grow_fn_ptr = self.ctx.memory_grow(memory_index, self.intrinsics);
let callable_func = inkwell::values::CallableValue::try_from(grow_fn_ptr).unwrap();
let grow = self.builder.build_call(
grow_fn_ptr,
callable_func,
&[
vmctx.as_basic_value_enum().into(),
delta.into(),
@ -10924,8 +10929,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
Operator::MemorySize { mem, mem_byte: _ } => {
let memory_index = MemoryIndex::from_u32(mem);
let size_fn_ptr = self.ctx.memory_size(memory_index, self.intrinsics);
let callable_func = inkwell::values::CallableValue::try_from(size_fn_ptr).unwrap();
let size = self.builder.build_call(
size_fn_ptr,
callable_func,
&[
vmctx.as_basic_value_enum().into(),
self.intrinsics.i32_ty.const_int(mem.into(), false).into(),

View File

@ -1685,7 +1685,9 @@ pub fn tbaa_label<'ctx>(
.get_global_metadata("wasmer_tbaa_root")
.pop()
.unwrap_or_else(|| {
module.add_global_metadata("wasmer_tbaa_root", &context.metadata_node(&[]));
module
.add_global_metadata("wasmer_tbaa_root", &context.metadata_node(&[]))
.unwrap();
module.get_global_metadata("wasmer_tbaa_root")[0]
});
@ -1696,10 +1698,12 @@ pub fn tbaa_label<'ctx>(
.get_global_metadata(label.as_str())
.pop()
.unwrap_or_else(|| {
module.add_global_metadata(
module
.add_global_metadata(
label.as_str(),
&context.metadata_node(&[type_label.into(), tbaa_root.into()]),
);
)
.unwrap();
module.get_global_metadata(label.as_str())[0]
});
@ -1714,18 +1718,20 @@ pub fn tbaa_label<'ctx>(
.get_global_metadata(label.as_str())
.pop()
.unwrap_or_else(|| {
module.add_global_metadata(
module
.add_global_metadata(
label.as_str(),
&context.metadata_node(&[
type_tbaa.into(),
type_tbaa.into(),
intrinsics.i64_zero.into(),
]),
);
)
.unwrap();
module.get_global_metadata(label.as_str())[0]
});
// Attach the access tag to the instruction.
let tbaa_kind = context.get_kind_id("tbaa");
instruction.set_metadata(type_tbaa, tbaa_kind);
instruction.set_metadata(type_tbaa, tbaa_kind).unwrap();
}