Repository: wasmerio/wasmer (language: rust)

Issue:
Update LLVM
Latest LLVM version is 18. We use - through the `inkwell` crate - version 15. We should: 

1. Update Inkwell to the latest version (`0.1.1` -> `0.5.0`)
2. Update LLVM (`15` -> `18)`


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 783cb0fbdb7..ab0437253db 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -46,14 +46,14 @@ jobs:
           - build: linux-x64
             os: ubuntu-20.04
             artifact_name: 'wasmer-linux-amd64'
-            llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/15.x/llvm-linux-amd64.tar.xz'
+            llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-linux-amd64.tar.xz'
             cross_compilation_artifact_name: 'cross_compiled_from_linux'
             use_sccache: false
             use_llvm: true
             build_wasm: true
           - build: macos-x64
             os: macos-12
-            llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/15.x/llvm-darwin-amd64.tar.xz'
+            llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-darwin-amd64.tar.xz'
             artifact_name: 'wasmer-darwin-amd64'
             cross_compilation_artifact_name: 'cross_compiled_from_mac'
             use_sccache: false
@@ -66,10 +66,12 @@ jobs:
             use_sccache: false
             use_llvm: false
             build_wasm: false
+            # [todo] xdoardo: Reinstate when the code we generate for aarch64 is working correctly. 
+            # llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-darwin-aarch64.tar.xz'
           - build: windows-x64
             os: windows-2019
             artifact_name: 'wasmer-windows-amd64'
-            llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/15.x/llvm-windows-amd64.tar.xz'
+            llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-windows-amd64.tar.xz'
             cross_compilation_artifact_name: 'cross_compiled_from_win'
             use_sccache: false
             use_llvm: true
@@ -77,7 +79,6 @@ jobs:
           - build: linux-musl-x64
             os: ubuntu-latest
             artifact_name: 'wasmer-linux-musl-amd64'
-            #llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/15.x/llvm-linux-amd64.tar.xz'
             container: alpine:latest
             use_sccache: false
             use_llvm: false
@@ -113,13 +114,16 @@ jobs:
           echo "${LLVM_DIR}/bin" >> $GITHUB_PATH
         env:
           LLVM_DIR: .llvm
+      - name: Install MSVC dev-cmd (Windows)
+        uses: ilammy/msvc-dev-cmd@v1
+        if: ${{ matrix.metadata.build == 'windows-x64' }}
       - name: Configure LLVM (Windows)
         # The Custom Windows build does not contains llvm-config.exe, so need to setup manualy here
         if: matrix.build == 'windows-x64' && matrix.llvm_url
         shell: bash
         run: |
           LLVM_DIR=$(pwd)/${{ env.LLVM_DIR }}
-          echo LLVM_SYS_150_PREFIX="${LLVM_DIR}" >> $GITHUB_ENV
+          echo LLVM_SYS_180_PREFIX="${LLVM_DIR}" >> $GITHUB_ENV
           echo LLVM_ENABLE=1 >> $GITHUB_ENV
         env:
           LLVM_DIR: .llvm
diff --git a/Cargo.lock b/Cargo.lock
index 4261170ea9b..22d60da7d99 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2519,27 +2519,27 @@ dependencies = [
 
 [[package]]
 name = "inkwell"
-version = "0.1.1"
+version = "0.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bbac11e485159a525867fb7e6aa61981453e6a72f625fde6a4ab3047b0c6dec9"
+checksum = "40fb405537710d51f6bdbc8471365ddd4cd6d3a3c3ad6e0c8291691031ba94b2"
 dependencies = [
  "either",
  "inkwell_internals",
  "libc",
  "llvm-sys",
  "once_cell",
- "parking_lot 0.12.3",
+ "thiserror",
 ]
 
 [[package]]
 name = "inkwell_internals"
-version = "0.7.0"
+version = "0.10.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "87d00c17e264ce02be5bc23d7bff959188ec7137beddd06b8b6b05a7c680ea85"
+checksum = "9dd28cfd4cfba665d47d31c08a6ba637eed16770abca2eccbbc3ca831fef1e44"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 1.0.109",
+ "syn 2.0.74",
 ]
 
 [[package]]
@@ -2822,14 +2822,15 @@ checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5"
 
 [[package]]
 name = "llvm-sys"
-version = "150.2.1"
+version = "180.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa55828745895d37233756307ded95a235b058aeb89cd12717ec7c3912089ee9"
+checksum = "778fa5fa02e32728e718f11eec147e6f134137399ab02fd2c13d32476337affa"
 dependencies = [
+ "anyhow",
  "cc",
  "lazy_static",
  "libc",
- "regex",
+ "regex-lite",
  "semver 1.0.23",
 ]
 
@@ -4072,6 +4073,12 @@ dependencies = [
  "regex-syntax 0.8.4",
 ]
 
+[[package]]
+name = "regex-lite"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a"
+
 [[package]]
 name = "regex-syntax"
 version = "0.6.29"
diff --git a/lib/compiler-llvm/Cargo.toml b/lib/compiler-llvm/Cargo.toml
index a0ae6dd9f3f..e93620d7999 100644
--- a/lib/compiler-llvm/Cargo.toml
+++ b/lib/compiler-llvm/Cargo.toml
@@ -29,9 +29,9 @@ rayon = "1.5"
 
 [dependencies.inkwell]
 package = "inkwell"
-version = "0.1.1"
+version = "0.5.0"
 default-features = false
-features = ["llvm15-0", "target-x86", "target-aarch64", "target-riscv"]
+features = ["llvm18-0-prefer-static", "target-x86", "target-aarch64", "target-riscv"]
 
 [build-dependencies]
 cc = "1.0"
diff --git a/lib/compiler-llvm/src/abi/aarch64_systemv.rs b/lib/compiler-llvm/src/abi/aarch64_systemv.rs
index 7ebf68b840d..a67b84a9d52 100644
--- a/lib/compiler-llvm/src/abi/aarch64_systemv.rs
+++ b/lib/compiler-llvm/src/abi/aarch64_systemv.rs
@@ -1,4 +1,5 @@
 use crate::abi::Abi;
+use crate::error::{err, err_nt};
 use crate::translator::intrinsics::{type_to_llvm, Intrinsics};
 use inkwell::{
     attributes::{Attribute, AttributeLoc},
@@ -44,7 +45,7 @@ impl Abi for Aarch64SystemV {
         let user_param_types = sig.params().iter().map(|&ty| type_to_llvm(intrinsics, ty));
 
         let param_types =
-            std::iter::once(Ok(intrinsics.ctx_ptr_ty.as_basic_type_enum())).chain(user_param_types);
+            std::iter::once(Ok(intrinsics.ptr_ty.as_basic_type_enum())).chain(user_param_types);
 
         let vmctx_attributes = |i: u32| {
             vec![
@@ -202,7 +203,7 @@ impl Abi for Aarch64SystemV {
                             .collect::<Result<_, _>>()?;
 
                         let sret = context.struct_type(&basic_types, false);
-                        let sret_ptr = sret.ptr_type(AddressSpace::default());
+                        let sret_ptr = context.ptr_type(AddressSpace::default());
 
                         let param_types =
                             std::iter::once(Ok(sret_ptr.as_basic_type_enum())).chain(param_types);
@@ -241,7 +242,7 @@ impl Abi for Aarch64SystemV {
         ctx_ptr: PointerValue<'ctx>,
         values: &[BasicValueEnum<'ctx>],
         intrinsics: &Intrinsics<'ctx>,
-    ) -> Vec<BasicValueEnum<'ctx>> {
+    ) -> Result<Vec<BasicValueEnum<'ctx>>, CompileError> {
         // If it's an sret, allocate the return space.
         let sret = if llvm_fn_ty.get_return_type().is_none() && func_sig.results().len() > 1 {
             let llvm_params: Vec<_> = func_sig
@@ -252,20 +253,22 @@ impl Abi for Aarch64SystemV {
             let llvm_params = llvm_fn_ty
                 .get_context()
                 .struct_type(llvm_params.as_slice(), false);
-            Some(alloca_builder.build_alloca(llvm_params, "sret"))
+            Some(err!(alloca_builder.build_alloca(llvm_params, "sret")))
         } else {
             None
         };
 
         let values = std::iter::once(ctx_ptr.as_basic_value_enum()).chain(values.iter().copied());
 
-        if let Some(sret) = sret {
+        let ret = if let Some(sret) = sret {
             std::iter::once(sret.as_basic_value_enum())
                 .chain(values)
                 .collect()
         } else {
             values.collect()
-        }
+        };
+
+        Ok(ret)
     }
 
     // Given a CallSite, extract the returned values and return them in a Vec.
@@ -275,72 +278,78 @@ impl Abi for Aarch64SystemV {
         intrinsics: &Intrinsics<'ctx>,
         call_site: CallSiteValue<'ctx>,
         func_sig: &FuncSig,
-    ) -> Vec<BasicValueEnum<'ctx>> {
-        let split_i64 = |value: IntValue<'ctx>| -> (IntValue<'ctx>, IntValue<'ctx>) {
-            assert!(value.get_type() == intrinsics.i64_ty);
-            let low = builder.build_int_truncate(value, intrinsics.i32_ty, "");
-            let lshr =
-                builder.build_right_shift(value, intrinsics.i64_ty.const_int(32, false), false, "");
-            let high = builder.build_int_truncate(lshr, intrinsics.i32_ty, "");
-            (low, high)
-        };
+    ) -> Result<Vec<BasicValueEnum<'ctx>>, CompileError> {
+        let split_i64 =
+            |value: IntValue<'ctx>| -> Result<(IntValue<'ctx>, IntValue<'ctx>), CompileError> {
+                assert!(value.get_type() == intrinsics.i64_ty);
+                let low = err!(builder.build_int_truncate(value, intrinsics.i32_ty, ""));
+                let lshr = err!(builder.build_right_shift(
+                    value,
+                    intrinsics.i64_ty.const_int(32, false),
+                    false,
+                    "",
+                ));
+                let high = err!(builder.build_int_truncate(lshr, intrinsics.i32_ty, ""));
+                Ok((low, high))
+            };
 
-        let casted = |value: BasicValueEnum<'ctx>, ty: Type| -> BasicValueEnum<'ctx> {
-            match ty {
-                Type::I32 => {
-                    assert!(
-                        value.get_type() == intrinsics.i32_ty.as_basic_type_enum()
-                            || value.get_type() == intrinsics.f32_ty.as_basic_type_enum()
-                    );
-                    builder.build_bitcast(value, intrinsics.i32_ty, "")
-                }
-                Type::F32 => {
-                    assert!(
-                        value.get_type() == intrinsics.i32_ty.as_basic_type_enum()
-                            || value.get_type() == intrinsics.f32_ty.as_basic_type_enum()
-                    );
-                    builder.build_bitcast(value, intrinsics.f32_ty, "")
-                }
-                Type::I64 => {
-                    assert!(
-                        value.get_type() == intrinsics.i64_ty.as_basic_type_enum()
-                            || value.get_type() == intrinsics.f64_ty.as_basic_type_enum()
-                    );
-                    builder.build_bitcast(value, intrinsics.i64_ty, "")
-                }
-                Type::F64 => {
-                    assert!(
-                        value.get_type() == intrinsics.i64_ty.as_basic_type_enum()
-                            || value.get_type() == intrinsics.f64_ty.as_basic_type_enum()
-                    );
-                    builder.build_bitcast(value, intrinsics.f64_ty, "")
-                }
-                Type::V128 => {
-                    assert!(value.get_type() == intrinsics.i128_ty.as_basic_type_enum());
-                    value
-                }
-                Type::ExternRef | Type::FuncRef => {
-                    assert!(value.get_type() == intrinsics.funcref_ty.as_basic_type_enum());
-                    value
+        let casted =
+            |value: BasicValueEnum<'ctx>, ty: Type| -> Result<BasicValueEnum<'ctx>, CompileError> {
+                match ty {
+                    Type::I32 => {
+                        assert!(
+                            value.get_type() == intrinsics.i32_ty.as_basic_type_enum()
+                                || value.get_type() == intrinsics.f32_ty.as_basic_type_enum()
+                        );
+                        err_nt!(builder.build_bit_cast(value, intrinsics.i32_ty, ""))
+                    }
+                    Type::F32 => {
+                        assert!(
+                            value.get_type() == intrinsics.i32_ty.as_basic_type_enum()
+                                || value.get_type() == intrinsics.f32_ty.as_basic_type_enum()
+                        );
+                        err_nt!(builder.build_bit_cast(value, intrinsics.f32_ty, ""))
+                    }
+                    Type::I64 => {
+                        assert!(
+                            value.get_type() == intrinsics.i64_ty.as_basic_type_enum()
+                                || value.get_type() == intrinsics.f64_ty.as_basic_type_enum()
+                        );
+                        err_nt!(builder.build_bit_cast(value, intrinsics.i64_ty, ""))
+                    }
+                    Type::F64 => {
+                        assert!(
+                            value.get_type() == intrinsics.i64_ty.as_basic_type_enum()
+                                || value.get_type() == intrinsics.f64_ty.as_basic_type_enum()
+                        );
+                        err_nt!(builder.build_bit_cast(value, intrinsics.f64_ty, ""))
+                    }
+                    Type::V128 => {
+                        assert!(value.get_type() == intrinsics.i128_ty.as_basic_type_enum());
+                        Ok(value)
+                    }
+                    Type::ExternRef | Type::FuncRef => {
+                        assert!(value.get_type() == intrinsics.ptr_ty.as_basic_type_enum());
+                        Ok(value)
+                    }
                 }
-            }
-        };
+            };
 
         if let Some(basic_value) = call_site.try_as_basic_value().left() {
             if func_sig.results().len() > 1 {
                 if basic_value.get_type() == intrinsics.i64_ty.as_basic_type_enum() {
                     assert!(func_sig.results().len() == 2);
                     let value = basic_value.into_int_value();
-                    let (low, high) = split_i64(value);
-                    let low = casted(low.into(), func_sig.results()[0]);
-                    let high = casted(high.into(), func_sig.results()[1]);
-                    return vec![low, high];
+                    let (low, high) = split_i64(value)?;
+                    let low = casted(low.into(), func_sig.results()[0])?;
+                    let high = casted(high.into(), func_sig.results()[1])?;
+                    return Ok(vec![low, high]);
                 }
                 if basic_value.is_struct_value() {
                     let struct_value = basic_value.into_struct_value();
-                    return (0..struct_value.get_type().count_fields())
+                    return Ok((0..struct_value.get_type().count_fields())
                         .map(|i| builder.build_extract_value(struct_value, i, "").unwrap())
-                        .collect::<Vec<_>>();
+                        .collect::<Vec<_>>());
                 }
                 let array_value = basic_value.into_array_value();
                 let low = builder
@@ -364,58 +373,58 @@ impl Abi for Aarch64SystemV {
 
                 match func_sig_returns_bitwidths.as_slice() {
                     [32, 64] => {
-                        let (low, _) = split_i64(low);
-                        let low = casted(low.into(), func_sig.results()[0]);
-                        let high = casted(high.into(), func_sig.results()[1]);
-                        vec![low, high]
+                        let (low, _) = split_i64(low)?;
+                        let low = casted(low.into(), func_sig.results()[0])?;
+                        let high = casted(high.into(), func_sig.results()[1])?;
+                        Ok(vec![low, high])
                     }
                     [64, 32] => {
-                        let (high, _) = split_i64(high);
-                        let low = casted(low.into(), func_sig.results()[0]);
-                        let high = casted(high.into(), func_sig.results()[1]);
-                        vec![low, high]
+                        let (high, _) = split_i64(high)?;
+                        let low = casted(low.into(), func_sig.results()[0])?;
+                        let high = casted(high.into(), func_sig.results()[1])?;
+                        Ok(vec![low, high])
                     }
                     [64, 64] => {
-                        let low = casted(low.into(), func_sig.results()[0]);
-                        let high = casted(high.into(), func_sig.results()[1]);
-                        vec![low, high]
+                        let low = casted(low.into(), func_sig.results()[0])?;
+                        let high = casted(high.into(), func_sig.results()[1])?;
+                        Ok(vec![low, high])
                     }
                     [32, 32, 32] => {
-                        let (v1, v2) = split_i64(low);
-                        let (v3, _) = split_i64(high);
-                        let v1 = casted(v1.into(), func_sig.results()[0]);
-                        let v2 = casted(v2.into(), func_sig.results()[1]);
-                        let v3 = casted(v3.into(), func_sig.results()[2]);
-                        vec![v1, v2, v3]
+                        let (v1, v2) = split_i64(low)?;
+                        let (v3, _) = split_i64(high)?;
+                        let v1 = casted(v1.into(), func_sig.results()[0])?;
+                        let v2 = casted(v2.into(), func_sig.results()[1])?;
+                        let v3 = casted(v3.into(), func_sig.results()[2])?;
+                        Ok(vec![v1, v2, v3])
                     }
                     [32, 32, 64] => {
-                        let (v1, v2) = split_i64(low);
-                        let v1 = casted(v1.into(), func_sig.results()[0]);
-                        let v2 = casted(v2.into(), func_sig.results()[1]);
-                        let v3 = casted(high.into(), func_sig.results()[2]);
-                        vec![v1, v2, v3]
+                        let (v1, v2) = split_i64(low)?;
+                        let v1 = casted(v1.into(), func_sig.results()[0])?;
+                        let v2 = casted(v2.into(), func_sig.results()[1])?;
+                        let v3 = casted(high.into(), func_sig.results()[2])?;
+                        Ok(vec![v1, v2, v3])
                     }
                     [64, 32, 32] => {
-                        let v1 = casted(low.into(), func_sig.results()[0]);
-                        let (v2, v3) = split_i64(high);
-                        let v2 = casted(v2.into(), func_sig.results()[1]);
-                        let v3 = casted(v3.into(), func_sig.results()[2]);
-                        vec![v1, v2, v3]
+                        let v1 = casted(low.into(), func_sig.results()[0])?;
+                        let (v2, v3) = split_i64(high)?;
+                        let v2 = casted(v2.into(), func_sig.results()[1])?;
+                        let v3 = casted(v3.into(), func_sig.results()[2])?;
+                        Ok(vec![v1, v2, v3])
                     }
                     [32, 32, 32, 32] => {
-                        let (v1, v2) = split_i64(low);
-                        let (v3, v4) = split_i64(high);
-                        let v1 = casted(v1.into(), func_sig.results()[0]);
-                        let v2 = casted(v2.into(), func_sig.results()[1]);
-                        let v3 = casted(v3.into(), func_sig.results()[2]);
-                        let v4 = casted(v4.into(), func_sig.results()[3]);
-                        vec![v1, v2, v3, v4]
+                        let (v1, v2) = split_i64(low)?;
+                        let (v3, v4) = split_i64(high)?;
+                        let v1 = casted(v1.into(), func_sig.results()[0])?;
+                        let v2 = casted(v2.into(), func_sig.results()[1])?;
+                        let v3 = casted(v3.into(), func_sig.results()[2])?;
+                        let v4 = casted(v4.into(), func_sig.results()[3])?;
+                        Ok(vec![v1, v2, v3, v4])
                     }
                     _ => unreachable!("expected an sret for this type"),
                 }
             } else {
                 assert!(func_sig.results().len() == 1);
-                vec![basic_value]
+                Ok(vec![basic_value])
             }
         } else {
             assert!(call_site.count_arguments() > 0); // Either sret or vmctx.
@@ -446,19 +455,18 @@ impl Abi for Aarch64SystemV {
                     .get_context()
                     .struct_type(llvm_results.as_slice(), false);
 
-                let struct_value = builder
-                    .build_load(struct_type, sret, "")
-                    .into_struct_value();
+                let struct_value =
+                    err!(builder.build_load(struct_type, sret, "")).into_struct_value();
                 let mut rets: Vec<_> = Vec::new();
                 for i in 0..struct_value.get_type().count_fields() {
-                    let value = builder.build_extract_value(struct_value, i, "").unwrap();
+                    let value = err!(builder.build_extract_value(struct_value, i, ""));
                     rets.push(value);
                 }
                 assert!(func_sig.results().len() == rets.len());
-                rets
+                Ok(rets)
             } else {
                 assert!(func_sig.results().is_empty());
-                vec![]
+                Ok(vec![])
             }
         }
     }
@@ -511,56 +519,59 @@ impl Abi for Aarch64SystemV {
             assert!(low.get_type() == intrinsics.i32_ty.as_basic_type_enum());
             assert!(high.get_type() == intrinsics.i32_ty.as_basic_type_enum());
             let (low, high) = (low.into_int_value(), high.into_int_value());
-            let low = builder.build_int_z_extend(low, intrinsics.i64_ty, "");
-            let high = builder.build_int_z_extend(high, intrinsics.i64_ty, "");
-            let high = builder.build_left_shift(high, intrinsics.i64_ty.const_int(32, false), "");
-            builder.build_or(low, high, "").as_basic_value_enum()
+            let low = err!(builder.build_int_z_extend(low, intrinsics.i64_ty, ""));
+            let high = err!(builder.build_int_z_extend(high, intrinsics.i64_ty, ""));
+            let high =
+                err!(builder.build_left_shift(high, intrinsics.i64_ty.const_int(32, false), ""));
+            err_nt!(builder
+                .build_or(low, high, "")
+                .map(|v| v.as_basic_value_enum()))
         };
 
-        let to_i64 = |v: BasicValueEnum<'ctx>| {
+        let to_i64 = |v: BasicValueEnum<'ctx>| -> Result<BasicValueEnum<'_>, CompileError> {
             if v.is_float_value() {
                 let v = v.into_float_value();
                 if v.get_type() == intrinsics.f32_ty {
-                    let v = builder
-                        .build_bitcast(v, intrinsics.i32_ty, "")
-                        .into_int_value();
-                    let v = builder.build_int_z_extend(v, intrinsics.i64_ty, "");
-                    v.as_basic_value_enum()
+                    let v = err!(builder.build_bit_cast(v, intrinsics.i32_ty, "")).into_int_value();
+                    let v = err!(builder.build_int_z_extend(v, intrinsics.i64_ty, ""));
+                    Ok(v.as_basic_value_enum())
                 } else {
                     debug_assert!(v.get_type() == intrinsics.f64_ty);
-                    let v = builder.build_bitcast(v, intrinsics.i64_ty, "");
-                    v.as_basic_value_enum()
+                    let v = err!(builder.build_bit_cast(v, intrinsics.i64_ty, ""));
+                    Ok(v.as_basic_value_enum())
                 }
             } else {
                 let v = v.into_int_value();
                 if v.get_type() == intrinsics.i32_ty {
-                    let v = builder.build_int_z_extend(v, intrinsics.i64_ty, "");
-                    v.as_basic_value_enum()
+                    let v = err!(builder.build_int_z_extend(v, intrinsics.i64_ty, ""));
+                    Ok(v.as_basic_value_enum())
                 } else {
                     debug_assert!(v.get_type() == intrinsics.i64_ty);
-                    v.as_basic_value_enum()
+                    Ok(v.as_basic_value_enum())
                 }
             }
         };
 
-        let build_struct = |ty: StructType<'ctx>, values: &[BasicValueEnum<'ctx>]| {
+        let build_struct = |ty: StructType<'ctx>,
+                            values: &[BasicValueEnum<'ctx>]|
+         -> Result<BasicValueEnum<'_>, CompileError> {
             let mut struct_value = ty.get_undef();
             for (i, v) in values.iter().enumerate() {
-                struct_value = builder
-                    .build_insert_value(struct_value, *v, i as u32, "")
-                    .unwrap()
+                struct_value = err!(builder.build_insert_value(struct_value, *v, i as u32, ""))
                     .into_struct_value();
             }
-            struct_value.as_basic_value_enum()
+            Ok(struct_value.as_basic_value_enum())
         };
 
-        let build_2xi64 = |low: BasicValueEnum<'ctx>, high: BasicValueEnum<'ctx>| {
-            let low = to_i64(low);
-            let high = to_i64(high);
+        let build_2xi64 = |low: BasicValueEnum<'ctx>,
+                           high: BasicValueEnum<'ctx>|
+         -> Result<BasicValueEnum<'_>, CompileError> {
+            let low = to_i64(low)?;
+            let high = to_i64(high)?;
             let value = intrinsics.i64_ty.array_type(2).get_undef();
-            let value = builder.build_insert_value(value, low, 0, "").unwrap();
-            let value = builder.build_insert_value(value, high, 1, "").unwrap();
-            value.as_basic_value_enum()
+            let value = err!(builder.build_insert_value(value, low, 0, ""));
+            let value = err!(builder.build_insert_value(value, high, 1, ""));
+            Ok(value.as_basic_value_enum())
         };
 
         Ok(match *values {
@@ -573,14 +584,14 @@ impl Abi for Aarch64SystemV {
                 build_struct(
                     func_type.get_return_type().unwrap().into_struct_type(),
                     &[v1, v2],
-                )
+                )?
             }
             [v1, v2] if is_32(v1) && is_32(v2) => {
-                let v1 = builder.build_bitcast(v1, intrinsics.i32_ty, "");
-                let v2 = builder.build_bitcast(v2, intrinsics.i32_ty, "");
-                pack_i32s(v1, v2)
+                let v1 = err!(builder.build_bit_cast(v1, intrinsics.i32_ty, ""));
+                let v2 = err!(builder.build_bit_cast(v2, intrinsics.i32_ty, ""));
+                pack_i32s(v1, v2)?
             }
-            [v1, v2] => build_2xi64(v1, v2),
+            [v1, v2] => build_2xi64(v1, v2)?,
             [v1, v2, v3]
                 if is_32(v1)
                     && is_32(v2)
@@ -592,19 +603,19 @@ impl Abi for Aarch64SystemV {
                 build_struct(
                     func_type.get_return_type().unwrap().into_struct_type(),
                     &[v1, v2, v3],
-                )
+                )?
             }
             [v1, v2, v3] if is_32(v1) && is_32(v2) => {
-                let v1 = builder.build_bitcast(v1, intrinsics.i32_ty, "");
-                let v2 = builder.build_bitcast(v2, intrinsics.i32_ty, "");
-                let v1v2_pack = pack_i32s(v1, v2);
-                build_2xi64(v1v2_pack, v3)
+                let v1 = err!(builder.build_bit_cast(v1, intrinsics.i32_ty, ""));
+                let v2 = err!(builder.build_bit_cast(v2, intrinsics.i32_ty, ""));
+                let v1v2_pack = pack_i32s(v1, v2)?;
+                build_2xi64(v1v2_pack, v3)?
             }
             [v1, v2, v3] if is_64(v1) && is_32(v2) && is_32(v3) => {
-                let v2 = builder.build_bitcast(v2, intrinsics.i32_ty, "");
-                let v3 = builder.build_bitcast(v3, intrinsics.i32_ty, "");
-                let v2v3_pack = pack_i32s(v2, v3);
-                build_2xi64(v1, v2v3_pack)
+                let v2 = err!(builder.build_bit_cast(v2, intrinsics.i32_ty, ""));
+                let v3 = err!(builder.build_bit_cast(v3, intrinsics.i32_ty, ""));
+                let v2v3_pack = pack_i32s(v2, v3)?;
+                build_2xi64(v1, v2v3_pack)?
             }
             [v1, v2, v3, v4]
                 if is_32(v1)
@@ -619,16 +630,16 @@ impl Abi for Aarch64SystemV {
                 build_struct(
                     func_type.get_return_type().unwrap().into_struct_type(),
                     &[v1, v2, v3, v4],
-                )
+                )?
             }
             [v1, v2, v3, v4] if is_32(v1) && is_32(v2) && is_32(v3) && is_32(v4) => {
-                let v1 = builder.build_bitcast(v1, intrinsics.i32_ty, "");
-                let v2 = builder.build_bitcast(v2, intrinsics.i32_ty, "");
-                let v1v2_pack = pack_i32s(v1, v2);
-                let v3 = builder.build_bitcast(v3, intrinsics.i32_ty, "");
-                let v4 = builder.build_bitcast(v4, intrinsics.i32_ty, "");
-                let v3v4_pack = pack_i32s(v3, v4);
-                build_2xi64(v1v2_pack, v3v4_pack)
+                let v1 = err!(builder.build_bit_cast(v1, intrinsics.i32_ty, ""));
+                let v2 = err!(builder.build_bit_cast(v2, intrinsics.i32_ty, ""));
+                let v1v2_pack = pack_i32s(v1, v2)?;
+                let v3 = err!(builder.build_bit_cast(v3, intrinsics.i32_ty, ""));
+                let v4 = err!(builder.build_bit_cast(v4, intrinsics.i32_ty, ""));
+                let v3v4_pack = pack_i32s(v3, v4)?;
+                build_2xi64(v1v2_pack, v3v4_pack)?
             }
             _ => {
                 unreachable!("called to perform register return on struct return or void function")
diff --git a/lib/compiler-llvm/src/abi/mod.rs b/lib/compiler-llvm/src/abi/mod.rs
index 06c3bbf993b..6e3a46b98dd 100644
--- a/lib/compiler-llvm/src/abi/mod.rs
+++ b/lib/compiler-llvm/src/abi/mod.rs
@@ -63,7 +63,7 @@ pub trait Abi {
         ctx_ptr: PointerValue<'ctx>,
         values: &[BasicValueEnum<'ctx>],
         intrinsics: &Intrinsics<'ctx>,
-    ) -> Vec<BasicValueEnum<'ctx>>;
+    ) -> Result<Vec<BasicValueEnum<'ctx>>, CompileError>;
 
     /// Given a CallSite, extract the returned values and return them in a Vec.
     fn rets_from_call<'ctx>(
@@ -72,7 +72,7 @@ pub trait Abi {
         intrinsics: &Intrinsics<'ctx>,
         call_site: CallSiteValue<'ctx>,
         func_sig: &FuncSig,
-    ) -> Vec<BasicValueEnum<'ctx>>;
+    ) -> Result<Vec<BasicValueEnum<'ctx>>, CompileError>;
 
     /// Whether the llvm equivalent of this wasm function has an `sret` attribute.
     fn is_sret(&self, func_sig: &FuncSig) -> Result<bool, CompileError>;
diff --git a/lib/compiler-llvm/src/abi/x86_64_systemv.rs b/lib/compiler-llvm/src/abi/x86_64_systemv.rs
index 47f1f75d162..f8529f67db2 100644
--- a/lib/compiler-llvm/src/abi/x86_64_systemv.rs
+++ b/lib/compiler-llvm/src/abi/x86_64_systemv.rs
@@ -1,4 +1,5 @@
 use crate::abi::Abi;
+use crate::error::{err, err_nt};
 use crate::translator::intrinsics::{type_to_llvm, Intrinsics};
 use inkwell::{
     attributes::{Attribute, AttributeLoc},
@@ -46,7 +47,7 @@ impl Abi for X86_64SystemV {
         let user_param_types = sig.params().iter().map(|&ty| type_to_llvm(intrinsics, ty));
 
         let param_types =
-            std::iter::once(Ok(intrinsics.ctx_ptr_ty.as_basic_type_enum())).chain(user_param_types);
+            std::iter::once(Ok(intrinsics.ptr_ty.as_basic_type_enum())).chain(user_param_types);
 
         // TODO: figure out how many bytes long vmctx is, and mark it dereferenceable. (no need to mark it nonnull once we do this.)
         let vmctx_attributes = |i: u32| {
@@ -258,7 +259,7 @@ impl Abi for X86_64SystemV {
                     .collect::<Result<_, _>>()?;
 
                 let sret = context.struct_type(&basic_types, false);
-                let sret_ptr = sret.ptr_type(AddressSpace::default());
+                let sret_ptr = context.ptr_type(AddressSpace::default());
 
                 let param_types =
                     std::iter::once(Ok(sret_ptr.as_basic_type_enum())).chain(param_types);
@@ -295,7 +296,7 @@ impl Abi for X86_64SystemV {
         ctx_ptr: PointerValue<'ctx>,
         values: &[BasicValueEnum<'ctx>],
         intrinsics: &Intrinsics<'ctx>,
-    ) -> Vec<BasicValueEnum<'ctx>> {
+    ) -> Result<Vec<BasicValueEnum<'ctx>>, CompileError> {
         // If it's an sret, allocate the return space.
         let sret = if llvm_fn_ty.get_return_type().is_none() && func_sig.results().len() > 1 {
             let llvm_params: Vec<_> = func_sig
@@ -306,20 +307,22 @@ impl Abi for X86_64SystemV {
             let llvm_params = llvm_fn_ty
                 .get_context()
                 .struct_type(llvm_params.as_slice(), false);
-            Some(alloca_builder.build_alloca(llvm_params, "sret"))
+            Some(err!(alloca_builder.build_alloca(llvm_params, "sret")))
         } else {
             None
         };
 
         let values = std::iter::once(ctx_ptr.as_basic_value_enum()).chain(values.iter().copied());
 
-        if let Some(sret) = sret {
+        let ret = if let Some(sret) = sret {
             std::iter::once(sret.as_basic_value_enum())
                 .chain(values)
                 .collect()
         } else {
             values.collect()
-        }
+        };
+
+        Ok(ret)
     }
 
     // Given a CallSite, extract the returned values and return them in a Vec.
@@ -329,62 +332,68 @@ impl Abi for X86_64SystemV {
         intrinsics: &Intrinsics<'ctx>,
         call_site: CallSiteValue<'ctx>,
         func_sig: &FuncSig,
-    ) -> Vec<BasicValueEnum<'ctx>> {
-        let split_i64 = |value: IntValue<'ctx>| -> (IntValue<'ctx>, IntValue<'ctx>) {
-            assert!(value.get_type() == intrinsics.i64_ty);
-            let low = builder.build_int_truncate(value, intrinsics.i32_ty, "");
-            let lshr =
-                builder.build_right_shift(value, intrinsics.i64_ty.const_int(32, false), false, "");
-            let high = builder.build_int_truncate(lshr, intrinsics.i32_ty, "");
-            (low, high)
-        };
+    ) -> Result<Vec<BasicValueEnum<'ctx>>, CompileError> {
+        let split_i64 =
+            |value: IntValue<'ctx>| -> Result<(IntValue<'ctx>, IntValue<'ctx>), CompileError> {
+                assert!(value.get_type() == intrinsics.i64_ty);
+                let low = err!(builder.build_int_truncate(value, intrinsics.i32_ty, ""));
+                let lshr = err!(builder.build_right_shift(
+                    value,
+                    intrinsics.i64_ty.const_int(32, false),
+                    false,
+                    ""
+                ));
+                let high = err!(builder.build_int_truncate(lshr, intrinsics.i32_ty, ""));
+                Ok((low, high))
+            };
 
         let f32x2_ty = intrinsics.f32_ty.vec_type(2).as_basic_type_enum();
-        let extract_f32x2 = |value: VectorValue<'ctx>| -> (FloatValue<'ctx>, FloatValue<'ctx>) {
+        let extract_f32x2 = |value: VectorValue<'ctx>| -> Result<(FloatValue<'ctx>, FloatValue<'ctx>), CompileError> {
             assert!(value.get_type() == f32x2_ty.into_vector_type());
-            let ret0 = builder
-                .build_extract_element(value, intrinsics.i32_ty.const_int(0, false), "")
+            let ret0 = err!(builder
+                .build_extract_element(value, intrinsics.i32_ty.const_int(0, false), ""))
                 .into_float_value();
-            let ret1 = builder
-                .build_extract_element(value, intrinsics.i32_ty.const_int(1, false), "")
+            let ret1 = err!(builder
+                .build_extract_element(value, intrinsics.i32_ty.const_int(1, false), ""))
                 .into_float_value();
-            (ret0, ret1)
+            Ok((ret0, ret1))
         };
 
-        let casted = |value: BasicValueEnum<'ctx>, ty: Type| -> BasicValueEnum<'ctx> {
-            match ty {
-                Type::I32 => {
-                    assert!(
-                        value.get_type() == intrinsics.i32_ty.as_basic_type_enum()
-                            || value.get_type() == intrinsics.f32_ty.as_basic_type_enum()
-                    );
-                    builder.build_bitcast(value, intrinsics.i32_ty, "")
-                }
-                Type::F32 => {
-                    assert!(
-                        value.get_type() == intrinsics.i32_ty.as_basic_type_enum()
-                            || value.get_type() == intrinsics.f32_ty.as_basic_type_enum()
-                    );
-                    builder.build_bitcast(value, intrinsics.f32_ty, "")
+        let casted =
+            |value: BasicValueEnum<'ctx>, ty: Type| -> Result<BasicValueEnum<'ctx>, CompileError> {
+                match ty {
+                    Type::I32 => {
+                        assert!(
+                            value.get_type() == intrinsics.i32_ty.as_basic_type_enum()
+                                || value.get_type() == intrinsics.f32_ty.as_basic_type_enum()
+                        );
+                        err_nt!(builder.build_bit_cast(value, intrinsics.i32_ty, ""))
+                    }
+                    Type::F32 => {
+                        assert!(
+                            value.get_type() == intrinsics.i32_ty.as_basic_type_enum()
+                                || value.get_type() == intrinsics.f32_ty.as_basic_type_enum()
+                        );
+                        err_nt!(builder.build_bit_cast(value, intrinsics.f32_ty, ""))
+                    }
+                    _ => panic!("should only be called to repack 32-bit values"),
                 }
-                _ => panic!("should only be called to repack 32-bit values"),
-            }
-        };
+            };
 
         if let Some(basic_value) = call_site.try_as_basic_value().left() {
             if func_sig.results().len() > 1 {
                 if basic_value.get_type() == intrinsics.i64_ty.as_basic_type_enum() {
                     assert!(func_sig.results().len() == 2);
                     let value = basic_value.into_int_value();
-                    let (low, high) = split_i64(value);
-                    let low = casted(low.into(), func_sig.results()[0]);
-                    let high = casted(high.into(), func_sig.results()[1]);
-                    return vec![low, high];
+                    let (low, high) = split_i64(value)?;
+                    let low = casted(low.into(), func_sig.results()[0])?;
+                    let high = casted(high.into(), func_sig.results()[1])?;
+                    return Ok(vec![low, high]);
                 }
                 if basic_value.get_type() == f32x2_ty {
                     assert!(func_sig.results().len() == 2);
-                    let (ret0, ret1) = extract_f32x2(basic_value.into_vector_value());
-                    return vec![ret0.into(), ret1.into()];
+                    let (ret0, ret1) = extract_f32x2(basic_value.into_vector_value())?;
+                    return Ok(vec![ret0.into(), ret1.into()]);
                 }
                 let struct_value = basic_value.into_struct_value();
                 let rets = (0..struct_value.get_type().count_fields())
@@ -401,7 +410,7 @@ impl Abi for X86_64SystemV {
                     })
                     .collect::<Vec<i32>>();
 
-                match func_sig_returns_bitwidths.as_slice() {
+                let ret = match func_sig_returns_bitwidths.as_slice() {
                     [32, 64] | [64, 32] | [64, 64] => {
                         assert!(func_sig.results().len() == 2);
                         vec![rets[0], rets[1]]
@@ -411,14 +420,14 @@ impl Abi for X86_64SystemV {
                             == intrinsics.f32_ty.vec_type(2).as_basic_type_enum() =>
                     {
                         assert!(func_sig.results().len() == 3);
-                        let (rets0, rets1) = extract_f32x2(rets[0].into_vector_value());
+                        let (rets0, rets1) = extract_f32x2(rets[0].into_vector_value())?;
                         vec![rets0.into(), rets1.into(), rets[1]]
                     }
                     [32, 32, _] => {
                         assert!(func_sig.results().len() == 3);
-                        let (low, high) = split_i64(rets[0].into_int_value());
-                        let low = casted(low.into(), func_sig.results()[0]);
-                        let high = casted(high.into(), func_sig.results()[1]);
+                        let (low, high) = split_i64(rets[0].into_int_value())?;
+                        let low = casted(low.into(), func_sig.results()[0])?;
+                        let high = casted(high.into(), func_sig.results()[1])?;
                         vec![low, high, rets[1]]
                     }
                     [64, 32, 32]
@@ -426,14 +435,14 @@ impl Abi for X86_64SystemV {
                             == intrinsics.f32_ty.vec_type(2).as_basic_type_enum() =>
                     {
                         assert!(func_sig.results().len() == 3);
-                        let (rets1, rets2) = extract_f32x2(rets[1].into_vector_value());
+                        let (rets1, rets2) = extract_f32x2(rets[1].into_vector_value())?;
                         vec![rets[0], rets1.into(), rets2.into()]
                     }
                     [64, 32, 32] => {
                         assert!(func_sig.results().len() == 3);
-                        let (rets1, rets2) = split_i64(rets[1].into_int_value());
-                        let rets1 = casted(rets1.into(), func_sig.results()[1]);
-                        let rets2 = casted(rets2.into(), func_sig.results()[2]);
+                        let (rets1, rets2) = split_i64(rets[1].into_int_value())?;
+                        let rets1 = casted(rets1.into(), func_sig.results()[1])?;
+                        let rets2 = casted(rets2.into(), func_sig.results()[2])?;
                         vec![rets[0], rets1, rets2]
                     }
                     [32, 32, 32, 32] => {
@@ -441,32 +450,34 @@ impl Abi for X86_64SystemV {
                         let (low0, high0) = if rets[0].get_type()
                             == intrinsics.f32_ty.vec_type(2).as_basic_type_enum()
                         {
-                            let (x, y) = extract_f32x2(rets[0].into_vector_value());
+                            let (x, y) = extract_f32x2(rets[0].into_vector_value())?;
                             (x.into(), y.into())
                         } else {
-                            let (x, y) = split_i64(rets[0].into_int_value());
+                            let (x, y) = split_i64(rets[0].into_int_value())?;
                             (x.into(), y.into())
                         };
                         let (low1, high1) = if rets[1].get_type()
                             == intrinsics.f32_ty.vec_type(2).as_basic_type_enum()
                         {
-                            let (x, y) = extract_f32x2(rets[1].into_vector_value());
+                            let (x, y) = extract_f32x2(rets[1].into_vector_value())?;
                             (x.into(), y.into())
                         } else {
-                            let (x, y) = split_i64(rets[1].into_int_value());
+                            let (x, y) = split_i64(rets[1].into_int_value())?;
                             (x.into(), y.into())
                         };
-                        let low0 = casted(low0, func_sig.results()[0]);
-                        let high0 = casted(high0, func_sig.results()[1]);
-                        let low1 = casted(low1, func_sig.results()[2]);
-                        let high1 = casted(high1, func_sig.results()[3]);
+                        let low0 = casted(low0, func_sig.results()[0])?;
+                        let high0 = casted(high0, func_sig.results()[1])?;
+                        let low1 = casted(low1, func_sig.results()[2])?;
+                        let high1 = casted(high1, func_sig.results()[3])?;
                         vec![low0, high0, low1, high1]
                     }
                     _ => unreachable!("expected an sret for this type"),
-                }
+                };
+
+                Ok(ret)
             } else {
                 assert!(func_sig.results().len() == 1);
-                vec![basic_value]
+                Ok(vec![basic_value])
             }
         } else {
             assert!(call_site.count_arguments() > 0); // Either sret or vmctx.
@@ -497,19 +508,18 @@ impl Abi for X86_64SystemV {
                     .get_context()
                     .struct_type(llvm_results.as_slice(), false);
 
-                let struct_value = builder
-                    .build_load(struct_type, sret, "")
-                    .into_struct_value();
+                let struct_value =
+                    err!(builder.build_load(struct_type, sret, "")).into_struct_value();
                 let mut rets: Vec<_> = Vec::new();
                 for i in 0..struct_value.get_type().count_fields() {
                     let value = builder.build_extract_value(struct_value, i, "").unwrap();
                     rets.push(value);
                 }
                 assert!(func_sig.results().len() == rets.len());
-                rets
+                Ok(rets)
             } else {
                 assert!(func_sig.results().is_empty());
-                vec![]
+                Ok(vec![])
             }
         }
     }
@@ -565,24 +575,31 @@ impl Abi for X86_64SystemV {
             assert!(low.get_type() == intrinsics.i32_ty.as_basic_type_enum());
             assert!(high.get_type() == intrinsics.i32_ty.as_basic_type_enum());
             let (low, high) = (low.into_int_value(), high.into_int_value());
-            let low = builder.build_int_z_extend(low, intrinsics.i64_ty, "");
-            let high = builder.build_int_z_extend(high, intrinsics.i64_ty, "");
-            let high = builder.build_left_shift(high, intrinsics.i64_ty.const_int(32, false), "");
-            builder.build_or(low, high, "").as_basic_value_enum()
+            let low = err!(builder.build_int_z_extend(low, intrinsics.i64_ty, ""));
+            let high = err!(builder.build_int_z_extend(high, intrinsics.i64_ty, ""));
+            let high =
+                err!(builder.build_left_shift(high, intrinsics.i64_ty.const_int(32, false), ""));
+            err_nt!(builder
+                .build_or(low, high, "")
+                .map(|v| v.as_basic_value_enum()))
         };
 
         let pack_f32s = |first: BasicValueEnum<'ctx>,
                          second: BasicValueEnum<'ctx>|
-         -> BasicValueEnum<'ctx> {
+         -> Result<BasicValueEnum<'ctx>, CompileError> {
             assert!(first.get_type() == intrinsics.f32_ty.as_basic_type_enum());
             assert!(second.get_type() == intrinsics.f32_ty.as_basic_type_enum());
             let (first, second) = (first.into_float_value(), second.into_float_value());
             let vec_ty = intrinsics.f32_ty.vec_type(2);
-            let vec =
-                builder.build_insert_element(vec_ty.get_undef(), first, intrinsics.i32_zero, "");
-            builder
+            let vec = err!(builder.build_insert_element(
+                vec_ty.get_undef(),
+                first,
+                intrinsics.i32_zero,
+                ""
+            ));
+            err_nt!(builder
                 .build_insert_element(vec, second, intrinsics.i32_ty.const_int(1, false), "")
-                .as_basic_value_enum()
+                .map(|v| v.as_basic_value_enum()))
         };
 
         let build_struct = |ty: StructType<'ctx>, values: &[BasicValueEnum<'ctx>]| {
@@ -598,11 +615,11 @@ impl Abi for X86_64SystemV {
 
         Ok(match *values {
             [one_value] => one_value,
-            [v1, v2] if is_f32(v1) && is_f32(v2) => pack_f32s(v1, v2),
+            [v1, v2] if is_f32(v1) && is_f32(v2) => pack_f32s(v1, v2)?,
             [v1, v2] if is_32(v1) && is_32(v2) => {
-                let v1 = builder.build_bitcast(v1, intrinsics.i32_ty, "");
-                let v2 = builder.build_bitcast(v2, intrinsics.i32_ty, "");
-                pack_i32s(v1, v2)
+                let v1 = err!(builder.build_bit_cast(v1, intrinsics.i32_ty, ""));
+                let v2 = err!(builder.build_bit_cast(v2, intrinsics.i32_ty, ""));
+                pack_i32s(v1, v2)?
             }
             [v1, v2] => {
                 assert!(!(is_32(v1) && is_32(v2)));
@@ -613,42 +630,42 @@ impl Abi for X86_64SystemV {
             }
             [v1, v2, v3] if is_f32(v1) && is_f32(v2) => build_struct(
                 func_type.get_return_type().unwrap().into_struct_type(),
-                &[pack_f32s(v1, v2), v3],
+                &[pack_f32s(v1, v2)?, v3],
             ),
             [v1, v2, v3] if is_32(v1) && is_32(v2) => {
-                let v1 = builder.build_bitcast(v1, intrinsics.i32_ty, "");
-                let v2 = builder.build_bitcast(v2, intrinsics.i32_ty, "");
+                let v1 = err!(builder.build_bit_cast(v1, intrinsics.i32_ty, ""));
+                let v2 = err!(builder.build_bit_cast(v2, intrinsics.i32_ty, ""));
                 build_struct(
                     func_type.get_return_type().unwrap().into_struct_type(),
-                    &[pack_i32s(v1, v2), v3],
+                    &[pack_i32s(v1, v2)?, v3],
                 )
             }
             [v1, v2, v3] if is_64(v1) && is_f32(v2) && is_f32(v3) => build_struct(
                 func_type.get_return_type().unwrap().into_struct_type(),
-                &[v1, pack_f32s(v2, v3)],
+                &[v1, pack_f32s(v2, v3)?],
             ),
             [v1, v2, v3] if is_64(v1) && is_32(v2) && is_32(v3) => {
-                let v2 = builder.build_bitcast(v2, intrinsics.i32_ty, "");
-                let v3 = builder.build_bitcast(v3, intrinsics.i32_ty, "");
+                let v2 = err!(builder.build_bit_cast(v2, intrinsics.i32_ty, ""));
+                let v3 = err!(builder.build_bit_cast(v3, intrinsics.i32_ty, ""));
                 build_struct(
                     func_type.get_return_type().unwrap().into_struct_type(),
-                    &[v1, pack_i32s(v2, v3)],
+                    &[v1, pack_i32s(v2, v3)?],
                 )
             }
             [v1, v2, v3, v4] if is_32(v1) && is_32(v2) && is_32(v3) && is_32(v4) => {
                 let v1v2_pack = if is_f32(v1) && is_f32(v2) {
-                    pack_f32s(v1, v2)
+                    pack_f32s(v1, v2)?
                 } else {
-                    let v1 = builder.build_bitcast(v1, intrinsics.i32_ty, "");
-                    let v2 = builder.build_bitcast(v2, intrinsics.i32_ty, "");
-                    pack_i32s(v1, v2)
+                    let v1 = err!(builder.build_bit_cast(v1, intrinsics.i32_ty, ""));
+                    let v2 = err!(builder.build_bit_cast(v2, intrinsics.i32_ty, ""));
+                    pack_i32s(v1, v2)?
                 };
                 let v3v4_pack = if is_f32(v3) && is_f32(v4) {
-                    pack_f32s(v3, v4)
+                    pack_f32s(v3, v4)?
                 } else {
-                    let v3 = builder.build_bitcast(v3, intrinsics.i32_ty, "");
-                    let v4 = builder.build_bitcast(v4, intrinsics.i32_ty, "");
-                    pack_i32s(v3, v4)
+                    let v3 = err!(builder.build_bit_cast(v3, intrinsics.i32_ty, ""));
+                    let v4 = err!(builder.build_bit_cast(v4, intrinsics.i32_ty, ""));
+                    pack_i32s(v3, v4)?
                 };
                 build_struct(
                     func_type.get_return_type().unwrap().into_struct_type(),
diff --git a/lib/compiler-llvm/src/error.rs b/lib/compiler-llvm/src/error.rs
new file mode 100644
index 00000000000..0ebe4ade2c5
--- /dev/null
+++ b/lib/compiler-llvm/src/error.rs
@@ -0,0 +1,14 @@
+macro_rules! err_nt {
+    ($e: expr) => {
+        $e.map_err(|v| CompileError::Codegen(v.to_string()))
+    };
+}
+
+macro_rules! err {
+    ($e: expr) => {
+        $e.map_err(|v| CompileError::Codegen(v.to_string()))?
+    };
+}
+
+pub(crate) use err;
+pub(crate) use err_nt;
diff --git a/lib/compiler-llvm/src/lib.rs b/lib/compiler-llvm/src/lib.rs
index 49231b7324f..fc077739835 100644
--- a/lib/compiler-llvm/src/lib.rs
+++ b/lib/compiler-llvm/src/lib.rs
@@ -17,6 +17,7 @@
 mod abi;
 mod compiler;
 mod config;
+mod error;
 mod object_file;
 mod trampoline;
 mod translator;
diff --git a/lib/compiler-llvm/src/trampoline/wasm.rs b/lib/compiler-llvm/src/trampoline/wasm.rs
index a3be2314c05..ee614cc8b9d 100644
--- a/lib/compiler-llvm/src/trampoline/wasm.rs
+++ b/lib/compiler-llvm/src/trampoline/wasm.rs
@@ -1,15 +1,16 @@
 use crate::abi::{get_abi, Abi};
 use crate::config::{CompiledKind, LLVM};
+use crate::error::{err, err_nt};
 use crate::object_file::{load_object_file, CompiledFunction};
 use crate::translator::intrinsics::{type_to_llvm, type_to_llvm_ptr, Intrinsics};
+use inkwell::passes::PassBuilderOptions;
 use inkwell::values::BasicMetadataValueEnum;
 use inkwell::{
     attributes::{Attribute, AttributeLoc},
     context::Context,
     module::{Linkage, Module},
-    passes::PassManager,
     targets::{FileType, TargetMachine},
-    types::{BasicType, FunctionType},
+    types::FunctionType,
     values::FunctionValue,
     AddressSpace, DLLStorageClass,
 };
@@ -58,9 +59,9 @@ impl FuncTrampoline {
                 .func_type_to_llvm(&self.ctx, &intrinsics, None, ty)?;
         let trampoline_ty = intrinsics.void_ty.fn_type(
             &[
-                intrinsics.ctx_ptr_ty.into(),                       // vmctx ptr
-                callee_ty.ptr_type(AddressSpace::default()).into(), // callee function address
-                intrinsics.i128_ptr_ty.into(),                      // in/out values ptr
+                intrinsics.ptr_ty.into(), // vmctx ptr
+                intrinsics.ptr_ty.into(), // callee function address
+                intrinsics.ptr_ty.into(), // in/out values ptr
             ],
             false,
         );
@@ -88,15 +89,20 @@ impl FuncTrampoline {
             callbacks.preopt_ir(&function, &module);
         }
 
-        let pass_manager = PassManager::create(());
+        let mut passes = vec![];
 
         if config.enable_verifier {
-            pass_manager.add_verifier_pass();
+            passes.push("verify");
         }
 
-        pass_manager.add_early_cse_pass();
-
-        pass_manager.run_on(&module);
+        passes.push("instcombine");
+        module
+            .run_passes(
+                passes.join(",").as_str(),
+                target_machine,
+                PassBuilderOptions::create(),
+            )
+            .unwrap();
 
         if let Some(ref callbacks) = config.callbacks {
             callbacks.postopt_ir(&function, &module);
@@ -208,15 +214,20 @@ impl FuncTrampoline {
             callbacks.preopt_ir(&function, &module);
         }
 
-        let pass_manager = PassManager::create(());
+        let mut passes = vec![];
 
         if config.enable_verifier {
-            pass_manager.add_verifier_pass();
+            passes.push("verify");
         }
 
-        pass_manager.add_early_cse_pass();
-
-        pass_manager.run_on(&module);
+        passes.push("early-cse");
+        module
+            .run_passes(
+                passes.join(",").as_str(),
+                target_machine,
+                PassBuilderOptions::create(),
+            )
+            .unwrap();
 
         if let Some(ref callbacks) = config.callbacks {
             callbacks.postopt_ir(&function, &module);
@@ -328,7 +339,7 @@ impl FuncTrampoline {
                 .collect::<Result<_, _>>()?;
 
             let sret_ty = context.struct_type(&basic_types, false);
-            args_vec.push(builder.build_alloca(sret_ty, "sret").into());
+            args_vec.push(err!(builder.build_alloca(sret_ty, "sret")).into());
         }
 
         args_vec.push(callee_vmctx_ptr.into());
@@ -336,45 +347,58 @@ impl FuncTrampoline {
         for (i, param_ty) in func_sig.params().iter().enumerate() {
             let index = intrinsics.i32_ty.const_int(i as _, false);
             let item_pointer = unsafe {
-                builder.build_in_bounds_gep(intrinsics.i128_ty, args_rets_ptr, &[index], "arg_ptr")
+                err!(builder.build_in_bounds_gep(
+                    intrinsics.i128_ty,
+                    args_rets_ptr,
+                    &[index],
+                    "arg_ptr"
+                ))
             };
 
             let casted_type = type_to_llvm(intrinsics, *param_ty)?;
             let casted_pointer_type = type_to_llvm_ptr(intrinsics, *param_ty)?;
 
-            let typed_item_pointer =
-                builder.build_pointer_cast(item_pointer, casted_pointer_type, "typed_arg_pointer");
+            let typed_item_pointer = err!(builder.build_pointer_cast(
+                item_pointer,
+                casted_pointer_type,
+                "typed_arg_pointer"
+            ));
 
-            let arg = builder.build_load(casted_type, typed_item_pointer, "arg");
+            let arg = err!(builder.build_load(casted_type, typed_item_pointer, "arg"));
             args_vec.push(arg.into());
         }
 
-        let call_site =
-            builder.build_indirect_call(llvm_func_type, func_ptr, args_vec.as_slice(), "call");
+        let call_site = err!(builder.build_indirect_call(
+            llvm_func_type,
+            func_ptr,
+            args_vec.as_slice(),
+            "call"
+        ));
         for (attr, attr_loc) in func_attrs {
             call_site.add_attribute(*attr_loc, *attr);
         }
 
         let rets = self
             .abi
-            .rets_from_call(&builder, intrinsics, call_site, func_sig);
-        let mut idx = 0;
-        rets.iter().for_each(|v| {
+            .rets_from_call(&builder, intrinsics, call_site, func_sig)?;
+        for (idx, v) in rets.into_iter().enumerate() {
             let ptr = unsafe {
-                builder.build_gep(
+                err!(builder.build_gep(
                     intrinsics.i128_ty,
                     args_rets_ptr,
-                    &[intrinsics.i32_ty.const_int(idx, false)],
+                    &[intrinsics.i32_ty.const_int(idx as u64, false)],
                     "",
-                )
+                ))
             };
-            let ptr =
-                builder.build_pointer_cast(ptr, v.get_type().ptr_type(AddressSpace::default()), "");
-            builder.build_store(ptr, *v);
-            idx += 1;
-        });
+            let ptr = err!(builder.build_pointer_cast(
+                ptr,
+                self.ctx.ptr_type(AddressSpace::default()),
+                ""
+            ));
+            err!(builder.build_store(ptr, v));
+        }
 
-        builder.build_return(None);
+        err!(builder.build_return(None));
         Ok(())
     }
 
@@ -390,61 +414,63 @@ impl FuncTrampoline {
         builder.position_at_end(entry_block);
 
         // Allocate stack space for the params and results.
-        let values = builder.build_alloca(
+        let values = err!(builder.build_alloca(
             intrinsics.i128_ty.array_type(cmp::max(
                 func_sig.params().len().try_into().unwrap(),
                 func_sig.results().len().try_into().unwrap(),
             )),
             "",
-        );
+        ));
 
         // Copy params to 'values'.
         let first_user_param = if self.abi.is_sret(func_sig)? { 2 } else { 1 };
         for i in 0..func_sig.params().len() {
             let ptr = unsafe {
-                builder.build_in_bounds_gep(
+                err!(builder.build_in_bounds_gep(
                     intrinsics.i128_ty,
                     values,
                     &[intrinsics.i32_ty.const_int(i.try_into().unwrap(), false)],
                     "args",
-                )
+                ))
             };
-            let ptr = builder
-                .build_bitcast(ptr, type_to_llvm_ptr(intrinsics, func_sig.params()[i])?, "")
-                .into_pointer_value();
-            builder.build_store(
+            let ptr = err!(builder.build_bit_cast(
+                ptr,
+                type_to_llvm_ptr(intrinsics, func_sig.params()[i])?,
+                ""
+            ))
+            .into_pointer_value();
+            err!(builder.build_store(
                 ptr,
                 trampoline_func
                     .get_nth_param(i as u32 + first_user_param)
                     .unwrap(),
-            );
+            ));
         }
 
         let callee_ptr_ty = intrinsics.void_ty.fn_type(
             &[
-                intrinsics.ctx_ptr_ty.into(),  // vmctx ptr
-                intrinsics.i128_ptr_ty.into(), // in/out values ptr
+                intrinsics.ptr_ty.into(), // vmctx ptr
+                intrinsics.ptr_ty.into(), // in/out values ptr
             ],
             false,
         );
-        let callee_ty = callee_ptr_ty.ptr_type(AddressSpace::default());
         let vmctx = self.abi.get_vmctx_ptr_param(&trampoline_func);
         let callee_ty =
-            builder.build_bitcast(vmctx, callee_ty.ptr_type(AddressSpace::default()), "");
-        let callee = builder
-            .build_load(intrinsics.ctx_ptr_ty, callee_ty.into_pointer_value(), "")
-            .into_pointer_value();
+            err!(builder.build_bit_cast(vmctx, self.ctx.ptr_type(AddressSpace::default()), ""));
+        let callee =
+            err!(builder.build_load(intrinsics.ptr_ty, callee_ty.into_pointer_value(), ""))
+                .into_pointer_value();
 
-        let values_ptr = builder.build_pointer_cast(values, intrinsics.i128_ptr_ty, "");
-        builder.build_indirect_call(
+        let values_ptr = err!(builder.build_pointer_cast(values, intrinsics.ptr_ty, ""));
+        err!(builder.build_indirect_call(
             callee_ptr_ty,
             callee,
             &[vmctx.into(), values_ptr.into()],
             "",
-        );
+        ));
 
         if func_sig.results().is_empty() {
-            builder.build_return(None);
+            err!(builder.build_return(None));
         } else {
             let results = func_sig
                 .results()
@@ -452,16 +478,19 @@ impl FuncTrampoline {
                 .enumerate()
                 .map(|(idx, ty)| {
                     let ptr = unsafe {
-                        builder.build_gep(
+                        err!(builder.build_gep(
                             intrinsics.i128_ty,
                             values,
                             &[intrinsics.i32_ty.const_int(idx.try_into().unwrap(), false)],
                             "",
-                        )
+                        ))
                     };
-                    let ptr =
-                        builder.build_pointer_cast(ptr, type_to_llvm_ptr(intrinsics, *ty)?, "");
-                    Ok(builder.build_load(type_to_llvm(intrinsics, *ty)?, ptr, ""))
+                    let ptr = err!(builder.build_pointer_cast(
+                        ptr,
+                        type_to_llvm_ptr(intrinsics, *ty)?,
+                        ""
+                    ));
+                    err_nt!(builder.build_load(type_to_llvm(intrinsics, *ty)?, ptr, ""))
                 })
                 .collect::<Result<Vec<_>, CompileError>>()?;
 
@@ -479,25 +508,26 @@ impl FuncTrampoline {
                 let mut struct_value = context.struct_type(&basic_types, false).get_undef();
 
                 for (idx, value) in results.iter().enumerate() {
-                    let value = builder.build_bitcast(
+                    let value = err!(builder.build_bit_cast(
                         *value,
                         type_to_llvm(intrinsics, func_sig.results()[idx])?,
                         "",
-                    );
-                    struct_value = builder
-                        .build_insert_value(struct_value, value, idx as u32, "")
-                        .unwrap()
-                        .into_struct_value();
+                    ));
+                    struct_value =
+                        err!(builder.build_insert_value(struct_value, value, idx as u32, ""))
+                            .into_struct_value();
                 }
-                builder.build_store(sret, struct_value);
-                builder.build_return(None);
+                err!(builder.build_store(sret, struct_value));
+                err!(builder.build_return(None));
             } else {
-                builder.build_return(Some(&self.abi.pack_values_for_register_return(
-                    intrinsics,
-                    &builder,
-                    results.as_slice(),
-                    &trampoline_func.get_type(),
-                )?));
+                err!(
+                    builder.build_return(Some(&self.abi.pack_values_for_register_return(
+                        intrinsics,
+                        &builder,
+                        results.as_slice(),
+                        &trampoline_func.get_type(),
+                    )?))
+                );
             }
         }
 
diff --git a/lib/compiler-llvm/src/translator/code.rs b/lib/compiler-llvm/src/translator/code.rs
index 92d004658ae..a7441326c81 100644
--- a/lib/compiler-llvm/src/translator/code.rs
+++ b/lib/compiler-llvm/src/translator/code.rs
@@ -10,7 +10,7 @@ use inkwell::{
     builder::Builder,
     context::Context,
     module::{Linkage, Module},
-    passes::PassManager,
+    passes::PassBuilderOptions,
     targets::{FileType, TargetMachine},
     types::{BasicType, BasicTypeEnum, FloatMathType, IntType, PointerType, VectorType},
     values::{
@@ -21,9 +21,15 @@ use inkwell::{
 };
 use smallvec::SmallVec;
 
-use crate::abi::{get_abi, Abi};
-use crate::config::{CompiledKind, LLVM};
 use crate::object_file::{load_object_file, CompiledFunction};
+use crate::{
+    abi::{get_abi, Abi},
+    error::err,
+};
+use crate::{
+    config::{CompiledKind, LLVM},
+    error::err_nt,
+};
 use wasmer_compiler::wasmparser::{MemArg, Operator};
 use wasmer_compiler::{
     from_binaryreadererror_wasmerror, wpheaptype_to_type, wptype_to_type, FunctionBinaryReader,
@@ -38,10 +44,6 @@ use wasmer_vm::{MemoryStyle, TableStyle, VMOffsets};
 
 const FUNCTION_SECTION: &str = "__TEXT,wasmer_function";
 
-fn to_compile_error(err: impl std::error::Error) -> CompileError {
-    CompileError::Codegen(format!("{}", err))
-}
-
 pub struct FuncTranslator {
     ctx: Context,
     target_machine: TargetMachine,
@@ -117,7 +119,7 @@ impl FuncTranslator {
         let cache_builder = self.ctx.create_builder();
         let builder = self.ctx.create_builder();
         cache_builder.position_at_end(entry);
-        let br = cache_builder.build_unconditional_branch(start_of_code);
+        let br = err!(cache_builder.build_unconditional_branch(start_of_code));
         alloca_builder.position_before(&br);
         cache_builder.position_before(&br);
         builder.position_at_end(start_of_code);
@@ -127,7 +129,9 @@ impl FuncTranslator {
         let phis: SmallVec<[PhiValue; 1]> = wasm_fn_type
             .results()
             .iter()
-            .map(|&wasm_ty| type_to_llvm(&intrinsics, wasm_ty).map(|ty| builder.build_phi(ty, "")))
+            .map(|&wasm_ty| {
+                type_to_llvm(&intrinsics, wasm_ty).map(|ty| builder.build_phi(ty, "").unwrap())
+            })
             .collect::<Result<_, _>>()?;
         state.push_block(return_, phis);
         builder.position_at_end(start_of_code);
@@ -150,13 +154,13 @@ impl FuncTranslator {
                 1
             };
         let mut is_first_alloca = true;
-        let mut insert_alloca = |ty, name| {
-            let alloca = alloca_builder.build_alloca(ty, name);
+        let mut insert_alloca = |ty, name| -> Result<PointerValue, CompileError> {
+            let alloca = err!(alloca_builder.build_alloca(ty, name));
             if is_first_alloca {
                 alloca_builder.position_at(entry, &alloca.as_instruction_value().unwrap());
                 is_first_alloca = false;
             }
-            alloca
+            Ok(alloca)
         };
 
         for idx in 0..wasm_fn_type.params().len() {
@@ -165,8 +169,8 @@ impl FuncTranslator {
             let value = func
                 .get_nth_param((idx as u32).checked_add(first_param).unwrap())
                 .unwrap();
-            let alloca = insert_alloca(ty, "param");
-            cache_builder.build_store(alloca, value);
+            let alloca = insert_alloca(ty, "param")?;
+            err!(cache_builder.build_store(alloca, value));
             params.push((ty, alloca));
         }
 
@@ -174,11 +178,11 @@ impl FuncTranslator {
         let num_locals = reader.read_local_count()?;
         for _ in 0..num_locals {
             let (count, ty) = reader.read_local_decl()?;
-            let ty = wptype_to_type(ty).map_err(to_compile_error)?;
+            let ty = err!(wptype_to_type(ty));
             let ty = type_to_llvm(&intrinsics, ty)?;
             for _ in 0..count {
-                let alloca = insert_alloca(ty, "local");
-                cache_builder.build_store(alloca, ty.const_zero());
+                let alloca = insert_alloca(ty, "local")?;
+                err!(cache_builder.build_store(alloca, ty.const_zero()));
                 locals.push((ty, alloca));
             }
         }
@@ -225,42 +229,46 @@ impl FuncTranslator {
             callbacks.preopt_ir(&function, &module);
         }
 
-        let pass_manager = PassManager::create(());
+        let mut passes = vec![];
 
         if config.enable_verifier {
-            pass_manager.add_verifier_pass();
+            passes.push("verify");
         }
 
-        pass_manager.add_type_based_alias_analysis_pass();
-        pass_manager.add_sccp_pass();
-        pass_manager.add_prune_eh_pass();
-        pass_manager.add_dead_arg_elimination_pass();
-        pass_manager.add_lower_expect_intrinsic_pass();
-        pass_manager.add_scalar_repl_aggregates_pass();
-        pass_manager.add_instruction_combining_pass();
-        pass_manager.add_jump_threading_pass();
-        pass_manager.add_correlated_value_propagation_pass();
-        pass_manager.add_cfg_simplification_pass();
-        pass_manager.add_reassociate_pass();
-        pass_manager.add_loop_rotate_pass();
-        pass_manager.add_ind_var_simplify_pass();
-        pass_manager.add_licm_pass();
-        pass_manager.add_loop_vectorize_pass();
-        pass_manager.add_instruction_combining_pass();
-        pass_manager.add_sccp_pass();
-        pass_manager.add_reassociate_pass();
-        pass_manager.add_cfg_simplification_pass();
-        pass_manager.add_gvn_pass();
-        pass_manager.add_memcpy_optimize_pass();
-        pass_manager.add_dead_store_elimination_pass();
-        pass_manager.add_bit_tracking_dce_pass();
-        pass_manager.add_instruction_combining_pass();
-        pass_manager.add_reassociate_pass();
-        pass_manager.add_cfg_simplification_pass();
-        pass_manager.add_slp_vectorize_pass();
-        pass_manager.add_early_cse_pass();
-
-        pass_manager.run_on(&module);
+        passes.push("sccp");
+        passes.push("early-cse");
+        //passes.push("deadargelim");
+        passes.push("adce");
+        passes.push("sroa");
+        passes.push("aggressive-instcombine");
+        passes.push("jump-threading");
+        //passes.push("ipsccp");
+        passes.push("simplifycfg");
+        passes.push("reassociate");
+        passes.push("loop-rotate");
+        passes.push("indvars");
+        //passes.push("lcssa");
+        //passes.push("licm");
+        //passes.push("instcombine");
+        passes.push("sccp");
+        passes.push("reassociate");
+        passes.push("simplifycfg");
+        passes.push("gvn");
+        passes.push("memcpyopt");
+        passes.push("dse");
+        passes.push("dce");
+        //passes.push("instcombine");
+        passes.push("reassociate");
+        passes.push("simplifycfg");
+        passes.push("mem2reg");
+
+        module
+            .run_passes(
+                passes.join(",").as_str(),
+                target_machine,
+                PassBuilderOptions::create(),
+            )
+            .unwrap();
 
         if let Some(ref callbacks) = config.callbacks {
             callbacks.postopt_ir(&function, &module);
@@ -327,23 +335,23 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
         &self,
         value: BasicValueEnum<'ctx>,
         vec_ty: VectorType<'ctx>,
-    ) -> VectorValue<'ctx> {
+    ) -> Result<VectorValue<'ctx>, CompileError> {
         // Use insert_element to insert the element into an undef vector, then use
         // shuffle vector to copy that lane to all lanes.
-        self.builder.build_shuffle_vector(
-            self.builder.build_insert_element(
+        err_nt!(self.builder.build_shuffle_vector(
+            err!(self.builder.build_insert_element(
                 vec_ty.get_undef(),
                 value,
                 self.intrinsics.i32_zero,
                 "",
-            ),
+            )),
             vec_ty.get_undef(),
             self.intrinsics
                 .i32_ty
                 .vec_type(vec_ty.get_size())
                 .const_zero(),
             "",
-        )
+        ))
     }
 
     // Convert floating point vector to integer and saturate when out of range.
@@ -358,7 +366,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
         int_min_value: u64,
         int_max_value: u64,
         value: IntValue<'ctx>,
-    ) -> VectorValue<'ctx> {
+    ) -> Result<VectorValue<'ctx>, CompileError> {
         // a) Compare vector with itself to identify NaN lanes.
         // b) Compare vector with splat of inttofp(upper_bound) to identify
         //    lanes that need to saturate to max.
@@ -383,70 +391,69 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 .const_int(int_min_value, is_signed)
                 .as_basic_value_enum(),
             ivec_ty,
-        );
+        )?;
         let int_max_value = self.splat_vector(
             ivec_element_ty
                 .const_int(int_max_value, is_signed)
                 .as_basic_value_enum(),
             ivec_ty,
-        );
+        )?;
         let lower_bound = if is_signed {
-            self.builder.build_signed_int_to_float(
+            err!(self.builder.build_signed_int_to_float(
                 ivec_element_ty.const_int(lower_bound, is_signed),
                 fvec_element_ty,
                 "",
-            )
+            ))
         } else {
-            self.builder.build_unsigned_int_to_float(
+            err!(self.builder.build_unsigned_int_to_float(
                 ivec_element_ty.const_int(lower_bound, is_signed),
                 fvec_element_ty,
                 "",
-            )
+            ))
         };
         let upper_bound = if is_signed {
-            self.builder.build_signed_int_to_float(
+            err!(self.builder.build_signed_int_to_float(
                 ivec_element_ty.const_int(upper_bound, is_signed),
                 fvec_element_ty,
                 "",
-            )
+            ))
         } else {
-            self.builder.build_unsigned_int_to_float(
+            err!(self.builder.build_unsigned_int_to_float(
                 ivec_element_ty.const_int(upper_bound, is_signed),
                 fvec_element_ty,
                 "",
-            )
+            ))
         };
 
-        let value = self
-            .builder
-            .build_bitcast(value, fvec_ty, "")
-            .into_vector_value();
+        let value = err!(self.builder.build_bit_cast(value, fvec_ty, "")).into_vector_value();
         let zero = fvec_ty.const_zero();
-        let lower_bound = self.splat_vector(lower_bound.as_basic_value_enum(), fvec_ty);
-        let upper_bound = self.splat_vector(upper_bound.as_basic_value_enum(), fvec_ty);
-        let nan_cmp = self
-            .builder
-            .build_float_compare(FloatPredicate::UNO, value, zero, "nan");
-        let above_upper_bound_cmp = self.builder.build_float_compare(
+        let lower_bound = self.splat_vector(lower_bound.as_basic_value_enum(), fvec_ty)?;
+        let upper_bound = self.splat_vector(upper_bound.as_basic_value_enum(), fvec_ty)?;
+        let nan_cmp =
+            err!(self
+                .builder
+                .build_float_compare(FloatPredicate::UNO, value, zero, "nan"));
+        let above_upper_bound_cmp = err!(self.builder.build_float_compare(
             FloatPredicate::OGT,
             value,
             upper_bound,
             "above_upper_bound",
-        );
-        let below_lower_bound_cmp = self.builder.build_float_compare(
+        ));
+        let below_lower_bound_cmp = err!(self.builder.build_float_compare(
             FloatPredicate::OLT,
             value,
             lower_bound,
             "below_lower_bound",
-        );
-        let not_representable = self.builder.build_or(
-            self.builder.build_or(nan_cmp, above_upper_bound_cmp, ""),
+        ));
+        let not_representable = err!(self.builder.build_or(
+            err!(self.builder.build_or(nan_cmp, above_upper_bound_cmp, "")),
             below_lower_bound_cmp,
             "not_representable_as_int",
-        );
-        let value = self
-            .builder
-            .build_select(not_representable, zero, value, "safe_to_convert")
+        ));
+        let value =
+            err!(self
+                .builder
+                .build_select(not_representable, zero, value, "safe_to_convert"))
             .into_vector_value();
         let value = if is_signed {
             self.builder
@@ -455,13 +462,17 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             self.builder
                 .build_float_to_unsigned_int(value, ivec_ty, "as_int")
         };
-        let value = self
-            .builder
-            .build_select(above_upper_bound_cmp, int_max_value, value, "")
+
+        let value = err!(value);
+        let value =
+            err!(self
+                .builder
+                .build_select(above_upper_bound_cmp, int_max_value, value, ""))
             .into_vector_value();
-        self.builder
+        err_nt!(self
+            .builder
             .build_select(below_lower_bound_cmp, int_min_value, value, "")
-            .into_vector_value()
+            .map(|v| v.into_vector_value()))
     }
 
     // Convert floating point vector to integer and saturate when out of range.
@@ -476,7 +487,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
         int_min_value: u64,
         int_max_value: u64,
         value: IntValue<'ctx>,
-    ) -> IntValue<'ctx> {
+    ) -> Result<IntValue<'ctx>, CompileError> {
         let res = self.trunc_sat(
             fvec_ty,
             ivec_ty,
@@ -485,10 +496,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             int_min_value,
             int_max_value,
             value,
-        );
-        self.builder
-            .build_bitcast(res, self.intrinsics.i128_ty, "")
-            .into_int_value()
+        )?;
+        err_nt!(self
+            .builder
+            .build_bit_cast(res, self.intrinsics.i128_ty, "")
+            .map(|v| v.into_int_value()))
     }
 
     // Convert floating point vector to integer and saturate when out of range.
@@ -501,7 +513,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
         int_min_value: u64,
         int_max_value: u64,
         value: FloatValue<'ctx>,
-    ) -> IntValue<'ctx> {
+    ) -> Result<IntValue<'ctx>, CompileError> {
         // TODO: this is a scalarized version of the process in trunc_sat. Either
         // we should merge with trunc_sat, or we should simplify this function.
 
@@ -522,76 +534,84 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
         let int_max_value = int_ty.const_int(int_max_value, is_signed);
 
         let lower_bound = if is_signed {
-            self.builder.build_signed_int_to_float(
+            err!(self.builder.build_signed_int_to_float(
                 int_ty.const_int(lower_bound, is_signed),
                 value.get_type(),
                 "",
-            )
+            ))
         } else {
-            self.builder.build_unsigned_int_to_float(
+            err!(self.builder.build_unsigned_int_to_float(
                 int_ty.const_int(lower_bound, is_signed),
                 value.get_type(),
                 "",
-            )
+            ))
         };
         let upper_bound = if is_signed {
-            self.builder.build_signed_int_to_float(
+            err!(self.builder.build_signed_int_to_float(
                 int_ty.const_int(upper_bound, is_signed),
                 value.get_type(),
                 "",
-            )
+            ))
         } else {
-            self.builder.build_unsigned_int_to_float(
+            err!(self.builder.build_unsigned_int_to_float(
                 int_ty.const_int(upper_bound, is_signed),
                 value.get_type(),
                 "",
-            )
+            ))
         };
 
         let zero = value.get_type().const_zero();
 
-        let nan_cmp = self
-            .builder
-            .build_float_compare(FloatPredicate::UNO, value, zero, "nan");
-        let above_upper_bound_cmp = self.builder.build_float_compare(
+        let nan_cmp =
+            err!(self
+                .builder
+                .build_float_compare(FloatPredicate::UNO, value, zero, "nan"));
+        let above_upper_bound_cmp = err!(self.builder.build_float_compare(
             FloatPredicate::OGT,
             value,
             upper_bound,
             "above_upper_bound",
-        );
-        let below_lower_bound_cmp = self.builder.build_float_compare(
+        ));
+        let below_lower_bound_cmp = err!(self.builder.build_float_compare(
             FloatPredicate::OLT,
             value,
             lower_bound,
             "below_lower_bound",
-        );
-        let not_representable = self.builder.build_or(
-            self.builder.build_or(nan_cmp, above_upper_bound_cmp, ""),
+        ));
+        let not_representable = err!(self.builder.build_or(
+            err!(self.builder.build_or(nan_cmp, above_upper_bound_cmp, "")),
             below_lower_bound_cmp,
             "not_representable_as_int",
-        );
-        let value = self
-            .builder
-            .build_select(not_representable, zero, value, "safe_to_convert")
+        ));
+        let value =
+            err!(self
+                .builder
+                .build_select(not_representable, zero, value, "safe_to_convert"))
             .into_float_value();
         let value = if is_signed {
-            self.builder
-                .build_float_to_signed_int(value, int_ty, "as_int")
+            err!(self
+                .builder
+                .build_float_to_signed_int(value, int_ty, "as_int"))
         } else {
-            self.builder
-                .build_float_to_unsigned_int(value, int_ty, "as_int")
+            err!(self
+                .builder
+                .build_float_to_unsigned_int(value, int_ty, "as_int"))
         };
-        let value = self
-            .builder
-            .build_select(above_upper_bound_cmp, int_max_value, value, "")
+        let value =
+            err!(self
+                .builder
+                .build_select(above_upper_bound_cmp, int_max_value, value, ""))
             .into_int_value();
-        let value = self
-            .builder
-            .build_select(below_lower_bound_cmp, int_min_value, value, "")
+        let value =
+            err!(self
+                .builder
+                .build_select(below_lower_bound_cmp, int_min_value, value, ""))
             .into_int_value();
-        self.builder
-            .build_bitcast(value, int_ty, "")
-            .into_int_value()
+
+        err_nt!(self
+            .builder
+            .build_bit_cast(value, int_ty, "")
+            .map(|v| v.into_int_value()))
     }
 
     fn trap_if_not_representable_as_int(
@@ -599,7 +619,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
         lower_bound: u64, // Inclusive (not a trapping value)
         upper_bound: u64, // Inclusive (not a trapping value)
         value: FloatValue,
-    ) {
+    ) -> Result<(), CompileError> {
         let float_ty = value.get_type();
         let int_ty = if float_ty == self.intrinsics.f32_ty {
             self.intrinsics.i32_ty
@@ -607,35 +627,37 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             self.intrinsics.i64_ty
         };
 
-        let lower_bound = self
-            .builder
-            .build_bitcast(int_ty.const_int(lower_bound, false), float_ty, "")
+        let lower_bound =
+            err!(self
+                .builder
+                .build_bit_cast(int_ty.const_int(lower_bound, false), float_ty, ""))
             .into_float_value();
-        let upper_bound = self
-            .builder
-            .build_bitcast(int_ty.const_int(upper_bound, false), float_ty, "")
+        let upper_bound =
+            err!(self
+                .builder
+                .build_bit_cast(int_ty.const_int(upper_bound, false), float_ty, ""))
             .into_float_value();
 
         // The 'U' in the float predicate is short for "unordered" which means that
         // the comparison will compare true if either operand is a NaN. Thus, NaNs
         // are out of bounds.
-        let above_upper_bound_cmp = self.builder.build_float_compare(
+        let above_upper_bound_cmp = err!(self.builder.build_float_compare(
             FloatPredicate::UGT,
             value,
             upper_bound,
             "above_upper_bound",
-        );
-        let below_lower_bound_cmp = self.builder.build_float_compare(
+        ));
+        let below_lower_bound_cmp = err!(self.builder.build_float_compare(
             FloatPredicate::ULT,
             value,
             lower_bound,
             "below_lower_bound",
-        );
-        let out_of_bounds = self.builder.build_or(
+        ));
+        let out_of_bounds = err!(self.builder.build_or(
             above_upper_bound_cmp,
             below_lower_bound_cmp,
             "out_of_bounds",
-        );
+        ));
 
         let failure_block = self
             .context
@@ -644,25 +666,34 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             .context
             .append_basic_block(self.function, "conversion_success_block");
 
-        self.builder
-            .build_conditional_branch(out_of_bounds, failure_block, continue_block);
-        self.builder.position_at_end(failure_block);
-        let is_nan = self
+        err!(self
             .builder
-            .build_float_compare(FloatPredicate::UNO, value, value, "is_nan");
-        let trap_code = self.builder.build_select(
+            .build_conditional_branch(out_of_bounds, failure_block, continue_block));
+        self.builder.position_at_end(failure_block);
+        let is_nan =
+            err!(self
+                .builder
+                .build_float_compare(FloatPredicate::UNO, value, value, "is_nan"));
+        let trap_code = err!(self.builder.build_select(
             is_nan,
             self.intrinsics.trap_bad_conversion_to_integer,
             self.intrinsics.trap_illegal_arithmetic,
             "",
-        );
-        self.builder
-            .build_call(self.intrinsics.throw_trap, &[trap_code.into()], "throw");
-        self.builder.build_unreachable();
+        ));
+        err!(self
+            .builder
+            .build_call(self.intrinsics.throw_trap, &[trap_code.into()], "throw"));
+        err!(self.builder.build_unreachable());
         self.builder.position_at_end(continue_block);
+
+        Ok(())
     }
 
-    fn trap_if_zero_or_overflow(&self, left: IntValue, right: IntValue) {
+    fn trap_if_zero_or_overflow(
+        &self,
+        left: IntValue,
+        right: IntValue,
+    ) -> Result<(), CompileError> {
         let int_type = left.get_type();
 
         let (min_value, neg_one_value) = if int_type == self.intrinsics.i32_ty {
@@ -677,42 +708,44 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             unreachable!()
         };
 
-        let divisor_is_zero = self.builder.build_int_compare(
+        let divisor_is_zero = err!(self.builder.build_int_compare(
             IntPredicate::EQ,
             right,
             int_type.const_zero(),
             "divisor_is_zero",
-        );
-        let should_trap = self.builder.build_or(
+        ));
+        let should_trap = err!(self.builder.build_or(
             divisor_is_zero,
-            self.builder.build_and(
-                self.builder
-                    .build_int_compare(IntPredicate::EQ, left, min_value, "left_is_min"),
-                self.builder.build_int_compare(
+            err!(self.builder.build_and(
+                err!(self.builder.build_int_compare(
+                    IntPredicate::EQ,
+                    left,
+                    min_value,
+                    "left_is_min"
+                )),
+                err!(self.builder.build_int_compare(
                     IntPredicate::EQ,
                     right,
                     neg_one_value,
                     "right_is_neg_one",
-                ),
+                )),
                 "div_will_overflow",
-            ),
+            )),
             "div_should_trap",
-        );
-
-        let should_trap = self
-            .builder
-            .build_call(
-                self.intrinsics.expect_i1,
-                &[
-                    should_trap.into(),
-                    self.intrinsics.i1_ty.const_zero().into(),
-                ],
-                "should_trap_expect",
-            )
-            .try_as_basic_value()
-            .left()
-            .unwrap()
-            .into_int_value();
+        ));
+
+        let should_trap = err!(self.builder.build_call(
+            self.intrinsics.expect_i1,
+            &[
+                should_trap.into(),
+                self.intrinsics.i1_ty.const_zero().into(),
+            ],
+            "should_trap_expect",
+        ))
+        .try_as_basic_value()
+        .left()
+        .unwrap()
+        .into_int_value();
 
         let shouldnt_trap_block = self
             .context
@@ -720,44 +753,48 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
         let should_trap_block = self
             .context
             .append_basic_block(self.function, "should_trap_block");
-        self.builder
-            .build_conditional_branch(should_trap, should_trap_block, shouldnt_trap_block);
+        err!(self.builder.build_conditional_branch(
+            should_trap,
+            should_trap_block,
+            shouldnt_trap_block
+        ));
         self.builder.position_at_end(should_trap_block);
-        let trap_code = self.builder.build_select(
+        let trap_code = err!(self.builder.build_select(
             divisor_is_zero,
             self.intrinsics.trap_integer_division_by_zero,
             self.intrinsics.trap_illegal_arithmetic,
             "",
-        );
-        self.builder
-            .build_call(self.intrinsics.throw_trap, &[trap_code.into()], "throw");
-        self.builder.build_unreachable();
+        ));
+        err!(self
+            .builder
+            .build_call(self.intrinsics.throw_trap, &[trap_code.into()], "throw"));
+        err!(self.builder.build_unreachable());
         self.builder.position_at_end(shouldnt_trap_block);
+
+        Ok(())
     }
 
-    fn trap_if_zero(&self, value: IntValue) {
+    fn trap_if_zero(&self, value: IntValue) -> Result<(), CompileError> {
         let int_type = value.get_type();
-        let should_trap = self.builder.build_int_compare(
+        let should_trap = err!(self.builder.build_int_compare(
             IntPredicate::EQ,
             value,
             int_type.const_zero(),
             "divisor_is_zero",
-        );
-
-        let should_trap = self
-            .builder
-            .build_call(
-                self.intrinsics.expect_i1,
-                &[
-                    should_trap.into(),
-                    self.intrinsics.i1_ty.const_zero().into(),
-                ],
-                "should_trap_expect",
-            )
-            .try_as_basic_value()
-            .left()
-            .unwrap()
-            .into_int_value();
+        ));
+
+        let should_trap = err!(self.builder.build_call(
+            self.intrinsics.expect_i1,
+            &[
+                should_trap.into(),
+                self.intrinsics.i1_ty.const_zero().into(),
+            ],
+            "should_trap_expect",
+        ))
+        .try_as_basic_value()
+        .left()
+        .unwrap()
+        .into_int_value();
 
         let shouldnt_trap_block = self
             .context
@@ -765,16 +802,21 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
         let should_trap_block = self
             .context
             .append_basic_block(self.function, "should_trap_block");
-        self.builder
-            .build_conditional_branch(should_trap, should_trap_block, shouldnt_trap_block);
+        err!(self.builder.build_conditional_branch(
+            should_trap,
+            should_trap_block,
+            shouldnt_trap_block
+        ));
         self.builder.position_at_end(should_trap_block);
-        self.builder.build_call(
+        err!(self.builder.build_call(
             self.intrinsics.throw_trap,
             &[self.intrinsics.trap_integer_division_by_zero.into()],
             "throw",
-        );
-        self.builder.build_unreachable();
+        ));
+        err!(self.builder.build_unreachable());
         self.builder.position_at_end(shouldnt_trap_block);
+
+        Ok(())
     }
 
     fn v128_into_int_vec(
@@ -782,33 +824,31 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
         value: BasicValueEnum<'ctx>,
         info: ExtraInfo,
         int_vec_ty: VectorType<'ctx>,
-    ) -> (VectorValue<'ctx>, ExtraInfo) {
+    ) -> Result<(VectorValue<'ctx>, ExtraInfo), CompileError> {
         let (value, info) = if info.has_pending_f32_nan() {
-            let value = self
+            let value = err!(self
                 .builder
-                .build_bitcast(value, self.intrinsics.f32x4_ty, "");
-            (self.canonicalize_nans(value), info.strip_pending())
+                .build_bit_cast(value, self.intrinsics.f32x4_ty, ""));
+            (self.canonicalize_nans(value)?, info.strip_pending())
         } else if info.has_pending_f64_nan() {
-            let value = self
+            let value = err!(self
                 .builder
-                .build_bitcast(value, self.intrinsics.f64x2_ty, "");
-            (self.canonicalize_nans(value), info.strip_pending())
+                .build_bit_cast(value, self.intrinsics.f64x2_ty, ""));
+            (self.canonicalize_nans(value)?, info.strip_pending())
         } else {
             (value, info)
         };
-        (
-            self.builder
-                .build_bitcast(value, int_vec_ty, "")
-                .into_vector_value(),
+        Ok((
+            err!(self.builder.build_bit_cast(value, int_vec_ty, "")).into_vector_value(),
             info,
-        )
+        ))
     }
 
     fn v128_into_i8x16(
         &self,
         value: BasicValueEnum<'ctx>,
         info: ExtraInfo,
-    ) -> (VectorValue<'ctx>, ExtraInfo) {
+    ) -> Result<(VectorValue<'ctx>, ExtraInfo), CompileError> {
         self.v128_into_int_vec(value, info, self.intrinsics.i8x16_ty)
     }
 
@@ -816,7 +856,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
         &self,
         value: BasicValueEnum<'ctx>,
         info: ExtraInfo,
-    ) -> (VectorValue<'ctx>, ExtraInfo) {
+    ) -> Result<(VectorValue<'ctx>, ExtraInfo), CompileError> {
         self.v128_into_int_vec(value, info, self.intrinsics.i16x8_ty)
     }
 
@@ -824,7 +864,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
         &self,
         value: BasicValueEnum<'ctx>,
         info: ExtraInfo,
-    ) -> (VectorValue<'ctx>, ExtraInfo) {
+    ) -> Result<(VectorValue<'ctx>, ExtraInfo), CompileError> {
         self.v128_into_int_vec(value, info, self.intrinsics.i32x4_ty)
     }
 
@@ -832,7 +872,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
         &self,
         value: BasicValueEnum<'ctx>,
         info: ExtraInfo,
-    ) -> (VectorValue<'ctx>, ExtraInfo) {
+    ) -> Result<(VectorValue<'ctx>, ExtraInfo), CompileError> {
         self.v128_into_int_vec(value, info, self.intrinsics.i64x2_ty)
     }
 
@@ -842,21 +882,22 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
         &self,
         value: BasicValueEnum<'ctx>,
         info: ExtraInfo,
-    ) -> (VectorValue<'ctx>, ExtraInfo) {
+    ) -> Result<(VectorValue<'ctx>, ExtraInfo), CompileError> {
         let (value, info) = if info.has_pending_f64_nan() {
-            let value = self
+            let value = err!(self
                 .builder
-                .build_bitcast(value, self.intrinsics.f64x2_ty, "");
-            (self.canonicalize_nans(value), info.strip_pending())
+                .build_bit_cast(value, self.intrinsics.f64x2_ty, ""));
+            (self.canonicalize_nans(value)?, info.strip_pending())
         } else {
             (value, info)
         };
-        (
-            self.builder
-                .build_bitcast(value, self.intrinsics.f32x4_ty, "")
-                .into_vector_value(),
+        Ok((
+            err!(self
+                .builder
+                .build_bit_cast(value, self.intrinsics.f32x4_ty, ""))
+            .into_vector_value(),
             info,
-        )
+        ))
     }
 
     // If the value is pending a 32-bit canonicalization, do it now.
@@ -865,30 +906,31 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
         &self,
         value: BasicValueEnum<'ctx>,
         info: ExtraInfo,
-    ) -> (VectorValue<'ctx>, ExtraInfo) {
+    ) -> Result<(VectorValue<'ctx>, ExtraInfo), CompileError> {
         let (value, info) = if info.has_pending_f32_nan() {
-            let value = self
+            let value = err!(self
                 .builder
-                .build_bitcast(value, self.intrinsics.f32x4_ty, "");
-            (self.canonicalize_nans(value), info.strip_pending())
+                .build_bit_cast(value, self.intrinsics.f32x4_ty, ""));
+            (self.canonicalize_nans(value)?, info.strip_pending())
         } else {
             (value, info)
         };
-        (
-            self.builder
-                .build_bitcast(value, self.intrinsics.f64x2_ty, "")
-                .into_vector_value(),
+        Ok((
+            err!(self
+                .builder
+                .build_bit_cast(value, self.intrinsics.f64x2_ty, ""))
+            .into_vector_value(),
             info,
-        )
+        ))
     }
 
     fn apply_pending_canonicalization(
         &self,
         value: BasicValueEnum<'ctx>,
         info: ExtraInfo,
-    ) -> BasicValueEnum<'ctx> {
+    ) -> Result<BasicValueEnum<'ctx>, CompileError> {
         if !self.config.enable_nan_canonicalization {
-            return value;
+            return Ok(value);
         }
 
         if info.has_pending_f32_nan() {
@@ -896,11 +938,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 || value.get_type() == self.intrinsics.i128_ty.as_basic_type_enum()
             {
                 let ty = value.get_type();
-                let value = self
+                let value = err!(self
                     .builder
-                    .build_bitcast(value, self.intrinsics.f32x4_ty, "");
-                let value = self.canonicalize_nans(value);
-                self.builder.build_bitcast(value, ty, "")
+                    .build_bit_cast(value, self.intrinsics.f32x4_ty, ""));
+                let value = self.canonicalize_nans(value)?;
+                err_nt!(self.builder.build_bit_cast(value, ty, ""))
             } else {
                 self.canonicalize_nans(value)
             }
@@ -909,23 +951,26 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 || value.get_type() == self.intrinsics.i128_ty.as_basic_type_enum()
             {
                 let ty = value.get_type();
-                let value = self
+                let value = err!(self
                     .builder
-                    .build_bitcast(value, self.intrinsics.f64x2_ty, "");
-                let value = self.canonicalize_nans(value);
-                self.builder.build_bitcast(value, ty, "")
+                    .build_bit_cast(value, self.intrinsics.f64x2_ty, ""));
+                let value = self.canonicalize_nans(value)?;
+                err_nt!(self.builder.build_bit_cast(value, ty, ""))
             } else {
                 self.canonicalize_nans(value)
             }
         } else {
-            value
+            Ok(value)
         }
     }
 
     // Replaces any NaN with the canonical QNaN, otherwise leaves the value alone.
-    fn canonicalize_nans(&self, value: BasicValueEnum<'ctx>) -> BasicValueEnum<'ctx> {
+    fn canonicalize_nans(
+        &self,
+        value: BasicValueEnum<'ctx>,
+    ) -> Result<BasicValueEnum<'ctx>, CompileError> {
         if !self.config.enable_nan_canonicalization {
-            return value;
+            return Ok(value);
         }
 
         let f_ty = value.get_type();
@@ -933,32 +978,36 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             let value = value.into_vector_value();
             let f_ty = f_ty.into_vector_type();
             let zero = f_ty.const_zero();
-            let nan_cmp = self
-                .builder
-                .build_float_compare(FloatPredicate::UNO, value, zero, "nan");
+            let nan_cmp =
+                err!(self
+                    .builder
+                    .build_float_compare(FloatPredicate::UNO, value, zero, "nan"));
             let canonical_qnan = f_ty
                 .get_element_type()
                 .into_float_type()
                 .const_float(std::f64::NAN);
-            let canonical_qnan = self.splat_vector(canonical_qnan.as_basic_value_enum(), f_ty);
-            self.builder
+            let canonical_qnan = self.splat_vector(canonical_qnan.as_basic_value_enum(), f_ty)?;
+            err_nt!(self
+                .builder
                 .build_select(nan_cmp, canonical_qnan, value, "")
-                .as_basic_value_enum()
+                .map(|v| v.as_basic_value_enum()))
         } else {
             let value = value.into_float_value();
             let f_ty = f_ty.into_float_type();
             let zero = f_ty.const_zero();
-            let nan_cmp = self
-                .builder
-                .build_float_compare(FloatPredicate::UNO, value, zero, "nan");
+            let nan_cmp =
+                err!(self
+                    .builder
+                    .build_float_compare(FloatPredicate::UNO, value, zero, "nan"));
             let canonical_qnan = f_ty.const_float(std::f64::NAN);
-            self.builder
+            err_nt!(self
+                .builder
                 .build_select(nan_cmp, canonical_qnan, value, "")
-                .as_basic_value_enum()
+                .map(|v| v.as_basic_value_enum()))
         }
     }
 
-    fn quiet_nan(&self, value: BasicValueEnum<'ctx>) -> BasicValueEnum<'ctx> {
+    fn quiet_nan(&self, value: BasicValueEnum<'ctx>) -> Result<BasicValueEnum<'ctx>, CompileError> {
         let intrinsic = if value
             .get_type()
             .eq(&self.intrinsics.f32_ty.as_basic_type_enum())
@@ -984,7 +1033,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
         };
 
         match intrinsic {
-            Some(intrinsic) => self
+            Some(intrinsic) => err_nt!(self
                 .builder
                 .build_call(
                     intrinsic,
@@ -996,10 +1045,8 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     ],
                     "",
                 )
-                .try_as_basic_value()
-                .left()
-                .unwrap(),
-            None => value,
+                .map(|v| v.try_as_basic_value().left().unwrap())),
+            None => Ok(value),
         }
     }
 
@@ -1016,7 +1063,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             self.intrinsics,
             self.module,
             self.memory_styles,
-        ) {
+        )? {
             // The best we've got is `volatile`.
             // TODO: convert unwrap fail to CompileError
             memaccess.set_volatile(true).unwrap();
@@ -1062,14 +1109,14 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
 
         // Compute the offset into the storage.
         let imm_offset = intrinsics.i64_ty.const_int(memarg.offset, false);
-        let var_offset = builder.build_int_z_extend(var_offset, intrinsics.i64_ty, "");
-        let offset = builder.build_int_add(var_offset, imm_offset, "");
+        let var_offset = err!(builder.build_int_z_extend(var_offset, intrinsics.i64_ty, ""));
+        let offset = err!(builder.build_int_add(var_offset, imm_offset, ""));
 
         // Look up the memory base (as pointer) and bounds (as unsigned integer).
         let base_ptr =
             match self
                 .ctx
-                .memory(memory_index, intrinsics, self.module, self.memory_styles)
+                .memory(memory_index, intrinsics, self.module, self.memory_styles)?
             {
                 MemoryCache::Dynamic {
                     ptr_to_base_ptr,
@@ -1093,29 +1140,41 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         }
                     } else {
                         None
-                    }
-                    .unwrap_or_else(|| {
-                        let load_offset_end = builder.build_int_add(offset, value_size_v, "");
-
-                        let current_length = builder
-                            .build_load(self.intrinsics.i32_ty, ptr_to_current_length, "")
+                    };
+
+                    let ptr_in_bounds = match ptr_in_bounds {
+                        Some(ptr) => ptr,
+                        None => {
+                            let load_offset_end =
+                                err!(builder.build_int_add(offset, value_size_v, ""));
+
+                            let current_length = err!(builder.build_load(
+                                self.intrinsics.i32_ty,
+                                ptr_to_current_length,
+                                ""
+                            ))
                             .into_int_value();
-                        tbaa_label(
-                            self.module,
-                            self.intrinsics,
-                            format!("memory {} length", memory_index.as_u32()),
-                            current_length.as_instruction_value().unwrap(),
-                        );
-                        let current_length =
-                            builder.build_int_z_extend(current_length, intrinsics.i64_ty, "");
+                            tbaa_label(
+                                self.module,
+                                self.intrinsics,
+                                format!("memory {} length", memory_index.as_u32()),
+                                current_length.as_instruction_value().unwrap(),
+                            );
+                            let current_length = err!(builder.build_int_z_extend(
+                                current_length,
+                                intrinsics.i64_ty,
+                                ""
+                            ));
+
+                            err!(builder.build_int_compare(
+                                IntPredicate::ULE,
+                                load_offset_end,
+                                current_length,
+                                "",
+                            ))
+                        }
+                    };
 
-                        builder.build_int_compare(
-                            IntPredicate::ULE,
-                            load_offset_end,
-                            current_length,
-                            "",
-                        )
-                    });
                     if !ptr_in_bounds.is_constant_int()
                         || ptr_in_bounds.get_zero_extended_constant().unwrap() != 1
                     {
@@ -1124,41 +1183,40 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         // constant expression, not known to be either true or false yet.
                         // If it's false, unknown-but-constant, or not-a-constant, emit a
                         // runtime bounds check. LLVM may yet succeed at optimizing it away.
-                        let ptr_in_bounds = builder
-                            .build_call(
-                                intrinsics.expect_i1,
-                                &[
-                                    ptr_in_bounds.into(),
-                                    intrinsics.i1_ty.const_int(1, true).into(),
-                                ],
-                                "ptr_in_bounds_expect",
-                            )
-                            .try_as_basic_value()
-                            .left()
-                            .unwrap()
-                            .into_int_value();
+                        let ptr_in_bounds = err!(builder.build_call(
+                            intrinsics.expect_i1,
+                            &[
+                                ptr_in_bounds.into(),
+                                intrinsics.i1_ty.const_int(1, true).into(),
+                            ],
+                            "ptr_in_bounds_expect",
+                        ))
+                        .try_as_basic_value()
+                        .left()
+                        .unwrap()
+                        .into_int_value();
 
                         let in_bounds_continue_block =
                             context.append_basic_block(*function, "in_bounds_continue_block");
                         let not_in_bounds_block =
                             context.append_basic_block(*function, "not_in_bounds_block");
-                        builder.build_conditional_branch(
+                        err!(builder.build_conditional_branch(
                             ptr_in_bounds,
                             in_bounds_continue_block,
                             not_in_bounds_block,
-                        );
+                        ));
                         builder.position_at_end(not_in_bounds_block);
-                        builder.build_call(
+                        err!(builder.build_call(
                             intrinsics.throw_trap,
                             &[intrinsics.trap_memory_oob.into()],
                             "throw",
-                        );
-                        builder.build_unreachable();
+                        ));
+                        err!(builder.build_unreachable());
                         builder.position_at_end(in_bounds_continue_block);
                     }
-                    let ptr_to_base = builder
-                        .build_load(intrinsics.i8_ptr_ty, ptr_to_base_ptr, "")
-                        .into_pointer_value();
+                    let ptr_to_base =
+                        err!(builder.build_load(intrinsics.ptr_ty, ptr_to_base_ptr, ""))
+                            .into_pointer_value();
                     tbaa_label(
                         self.module,
                         self.intrinsics,
@@ -1170,41 +1228,47 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 MemoryCache::Static { base_ptr } => base_ptr,
             };
         let value_ptr =
-            unsafe { builder.build_gep(self.intrinsics.i8_ty, base_ptr, &[offset], "") };
-        Ok(builder
-            .build_bitcast(value_ptr, ptr_ty, "")
-            .into_pointer_value())
+            unsafe { err!(builder.build_gep(self.intrinsics.i8_ty, base_ptr, &[offset], "")) };
+        err_nt!(builder
+            .build_bit_cast(value_ptr, ptr_ty, "")
+            .map(|v| v.into_pointer_value()))
     }
 
-    fn trap_if_misaligned(&self, _memarg: &MemArg, ptr: PointerValue<'ctx>, align: u8) {
+    fn trap_if_misaligned(
+        &self,
+        _memarg: &MemArg,
+        ptr: PointerValue<'ctx>,
+        align: u8,
+    ) -> Result<(), CompileError> {
         if align <= 1 {
-            return;
+            return Ok(());
         }
-        let value = self
+        let value = err!(self
             .builder
-            .build_ptr_to_int(ptr, self.intrinsics.i64_ty, "");
-        let and = self.builder.build_and(
+            .build_ptr_to_int(ptr, self.intrinsics.i64_ty, ""));
+        let and = err!(self.builder.build_and(
             value,
             self.intrinsics.i64_ty.const_int((align - 1).into(), false),
             "misaligncheck",
-        );
-        let aligned =
-            self.builder
-                .build_int_compare(IntPredicate::EQ, and, self.intrinsics.i64_zero, "");
-        let aligned = self
-            .builder
-            .build_call(
-                self.intrinsics.expect_i1,
-                &[
-                    aligned.into(),
-                    self.intrinsics.i1_ty.const_int(1, false).into(),
-                ],
-                "",
-            )
-            .try_as_basic_value()
-            .left()
-            .unwrap()
-            .into_int_value();
+        ));
+        let aligned = err!(self.builder.build_int_compare(
+            IntPredicate::EQ,
+            and,
+            self.intrinsics.i64_zero,
+            ""
+        ));
+        let aligned = err!(self.builder.build_call(
+            self.intrinsics.expect_i1,
+            &[
+                aligned.into(),
+                self.intrinsics.i1_ty.const_int(1, false).into(),
+            ],
+            "",
+        ))
+        .try_as_basic_value()
+        .left()
+        .unwrap()
+        .into_int_value();
 
         let continue_block = self
             .context
@@ -1212,29 +1276,33 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
         let not_aligned_block = self
             .context
             .append_basic_block(self.function, "misaligned_trap_block");
-        self.builder
-            .build_conditional_branch(aligned, continue_block, not_aligned_block);
+        err!(self
+            .builder
+            .build_conditional_branch(aligned, continue_block, not_aligned_block));
 
         self.builder.position_at_end(not_aligned_block);
-        self.builder.build_call(
+        err!(self.builder.build_call(
             self.intrinsics.throw_trap,
             &[self.intrinsics.trap_unaligned_atomic.into()],
             "throw",
-        );
-        self.builder.build_unreachable();
+        ));
+        err!(self.builder.build_unreachable());
 
         self.builder.position_at_end(continue_block);
+        Ok(())
     }
 
     fn finalize(&mut self, wasm_fn_type: &FunctionType) -> Result<(), CompileError> {
         let func_type = self.function.get_type();
 
         let results = self.state.popn_save_extra(wasm_fn_type.results().len())?;
-        let results = results
+        let results = err!(results
             .into_iter()
-            .map(|(v, i)| self.apply_pending_canonicalization(v, i));
+            .map(|(v, i)| self.apply_pending_canonicalization(v, i))
+            .collect::<Result<Vec<_>, _>>());
+
         if wasm_fn_type.results().is_empty() {
-            self.builder.build_return(None);
+            err!(self.builder.build_return(None));
         } else if self.abi.is_sret(wasm_fn_type)? {
             let sret = self
                 .function
@@ -1250,28 +1318,29 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 .context
                 .struct_type(llvm_params.as_slice(), false)
                 .get_undef();
-            for (idx, value) in results.enumerate() {
-                let value = self.builder.build_bitcast(
+            for (idx, value) in results.into_iter().enumerate() {
+                let value = err!(self.builder.build_bit_cast(
                     value,
                     type_to_llvm(self.intrinsics, wasm_fn_type.results()[idx])?,
                     "",
-                );
-                struct_value = self
-                    .builder
-                    .build_insert_value(struct_value, value, idx as u32, "")
-                    .unwrap()
+                ));
+                struct_value =
+                    err!(self
+                        .builder
+                        .build_insert_value(struct_value, value, idx as u32, ""))
                     .into_struct_value();
             }
-            self.builder.build_store(sret, struct_value);
-            self.builder.build_return(None);
+            err!(self.builder.build_store(sret, struct_value));
+            err!(self.builder.build_return(None));
         } else {
-            self.builder
+            err!(self
+                .builder
                 .build_return(Some(&self.abi.pack_values_for_register_return(
                     self.intrinsics,
                     &self.builder,
-                    &results.collect::<Vec<_>>(),
+                    &results,
                     &func_type,
-                )?));
+                )?)));
         }
         Ok(())
     }
@@ -1443,12 +1512,10 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     .1
                     .iter()
                     .map(|&wp_ty| {
-                        wptype_to_type(wp_ty)
-                            .map_err(to_compile_error)
-                            .and_then(|wasm_ty| {
-                                type_to_llvm(self.intrinsics, wasm_ty)
-                                    .map(|ty| self.builder.build_phi(ty, ""))
-                            })
+                        err_nt!(wptype_to_type(wp_ty)).and_then(|wasm_ty| {
+                            type_to_llvm(self.intrinsics, wasm_ty)
+                                .and_then(|ty| err_nt!(self.builder.build_phi(ty, "")))
+                        })
                     })
                     .collect::<Result<_, _>>()?;
 
@@ -1460,7 +1527,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let loop_next = self.context.append_basic_block(self.function, "loop_outer");
                 let pre_loop_block = self.builder.get_insert_block().unwrap();
 
-                self.builder.build_unconditional_branch(loop_body);
+                err!(self.builder.build_unconditional_branch(loop_body));
 
                 self.builder.position_at_end(loop_next);
                 let blocktypes = self.module_translation.blocktype_params_results(&blockty)?;
@@ -1468,12 +1535,10 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     .1
                     .iter()
                     .map(|&wp_ty| {
-                        wptype_to_type(wp_ty)
-                            .map_err(to_compile_error)
-                            .and_then(|wasm_ty| {
-                                type_to_llvm(self.intrinsics, wasm_ty)
-                                    .map(|ty| self.builder.build_phi(ty, ""))
-                            })
+                        err_nt!(wptype_to_type(wp_ty)).and_then(|wasm_ty| {
+                            type_to_llvm(self.intrinsics, wasm_ty)
+                                .and_then(|ty| err_nt!(self.builder.build_phi(ty, "")))
+                        })
                     })
                     .collect::<Result<_, _>>()?;
                 self.builder.position_at_end(loop_body);
@@ -1481,17 +1546,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     .0
                     .iter()
                     .map(|&wp_ty| {
-                        wptype_to_type(wp_ty)
-                            .map_err(to_compile_error)
-                            .and_then(|wasm_ty| {
-                                type_to_llvm(self.intrinsics, wasm_ty)
-                                    .map(|ty| self.builder.build_phi(ty, ""))
-                            })
+                        err_nt!(wptype_to_type(wp_ty)).and_then(|wasm_ty| {
+                            type_to_llvm(self.intrinsics, wasm_ty)
+                                .and_then(|ty| err_nt!(self.builder.build_phi(ty, "")))
+                        })
                     })
                     .collect::<Result<_, _>>()?;
                 for phi in loop_phis.iter().rev() {
                     let (value, info) = self.state.pop1_extra()?;
-                    let value = self.apply_pending_canonicalization(value, info);
+                    let value = self.apply_pending_canonicalization(value, info)?;
                     phi.add_incoming(&[(&value, pre_loop_block)]);
                 }
                 for phi in &loop_phis {
@@ -1550,16 +1613,17 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let values = self.state.peekn_extra(len)?;
                 let values = values
                     .iter()
-                    .map(|(v, info)| self.apply_pending_canonicalization(*v, *info));
+                    .map(|(v, info)| self.apply_pending_canonicalization(*v, *info))
+                    .collect::<Result<Vec<_>, _>>()?;
 
                 // For each result of the block we're branching to,
                 // pop a value off the value stack and load it into
                 // the corresponding phi.
-                for (phi, value) in phis.iter().zip(values) {
+                for (phi, value) in phis.iter().zip(values.into_iter()) {
                     phi.add_incoming(&[(&value, current_block)]);
                 }
 
-                self.builder.build_unconditional_branch(*frame.br_dest());
+                err!(self.builder.build_unconditional_branch(*frame.br_dest()));
 
                 self.state.popn(len)?;
                 self.state.reachable = false;
@@ -1582,7 +1646,8 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let param_stack = self.state.peekn_extra(phis.len())?;
                 let param_stack = param_stack
                     .iter()
-                    .map(|(v, info)| self.apply_pending_canonicalization(*v, *info));
+                    .map(|(v, info)| self.apply_pending_canonicalization(*v, *info))
+                    .collect::<Result<Vec<_>, _>>()?;
 
                 for (phi, value) in phis.iter().zip(param_stack) {
                     phi.add_incoming(&[(&value, current_block)]);
@@ -1590,14 +1655,17 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
 
                 let else_block = self.context.append_basic_block(self.function, "else");
 
-                let cond_value = self.builder.build_int_compare(
+                let cond_value = err!(self.builder.build_int_compare(
                     IntPredicate::NE,
                     cond.into_int_value(),
                     self.intrinsics.i32_zero,
                     "",
-                );
-                self.builder
-                    .build_conditional_branch(cond_value, *frame.br_dest(), else_block);
+                ));
+                err!(self.builder.build_conditional_branch(
+                    cond_value,
+                    *frame.br_dest(),
+                    else_block
+                ));
                 self.builder.position_at_end(else_block);
             }
             Operator::BrTable { ref targets } => {
@@ -1647,11 +1715,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     })
                     .collect::<Result<_, _>>()?;
 
-                self.builder.build_switch(
+                err!(self.builder.build_switch(
                     index.into_int_value(),
                     *default_frame.br_dest(),
                     &cases[..],
-                );
+                ));
 
                 let args_len = args.len();
                 self.state.popn(args_len)?;
@@ -1675,12 +1743,10 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         .1
                         .iter()
                         .map(|&wp_ty| {
-                            wptype_to_type(wp_ty)
-                                .map_err(to_compile_error)
-                                .and_then(|wasm_ty| {
-                                    type_to_llvm(self.intrinsics, wasm_ty)
-                                        .map(|ty| self.builder.build_phi(ty, ""))
-                                })
+                            err_nt!(wptype_to_type(wp_ty)).and_then(|wasm_ty| {
+                                type_to_llvm(self.intrinsics, wasm_ty)
+                                    .and_then(|ty| err_nt!(self.builder.build_phi(ty, "")))
+                            })
                         })
                         .collect::<Result<_, _>>()?;
 
@@ -1690,15 +1756,18 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
 
                 let cond = self.state.pop1()?;
 
-                let cond_value = self.builder.build_int_compare(
+                let cond_value = err!(self.builder.build_int_compare(
                     IntPredicate::NE,
                     cond.into_int_value(),
                     self.intrinsics.i32_zero,
                     "",
-                );
+                ));
 
-                self.builder
-                    .build_conditional_branch(cond_value, if_then_block, if_else_block);
+                err!(self.builder.build_conditional_branch(
+                    cond_value,
+                    if_then_block,
+                    if_else_block
+                ));
                 self.builder.position_at_end(if_else_block);
                 let block_param_types = self
                     .module_translation
@@ -1706,23 +1775,22 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     .0
                     .iter()
                     .map(|&wp_ty| {
-                        wptype_to_type(wp_ty)
-                            .map_err(to_compile_error)
+                        err_nt!(wptype_to_type(wp_ty))
                             .and_then(|wasm_ty| type_to_llvm(self.intrinsics, wasm_ty))
                     })
                     .collect::<Result<Vec<_>, _>>()?;
                 let else_phis: SmallVec<[PhiValue<'ctx>; 1]> = block_param_types
                     .iter()
-                    .map(|&ty| self.builder.build_phi(ty, ""))
-                    .collect();
+                    .map(|&ty| err_nt!(self.builder.build_phi(ty, "")))
+                    .collect::<Result<SmallVec<_>, _>>()?;
                 self.builder.position_at_end(if_then_block);
                 let then_phis: SmallVec<[PhiValue<'ctx>; 1]> = block_param_types
                     .iter()
-                    .map(|&ty| self.builder.build_phi(ty, ""))
-                    .collect();
+                    .map(|&ty| err_nt!(self.builder.build_phi(ty, "")))
+                    .collect::<Result<SmallVec<_>, _>>()?;
                 for (else_phi, then_phi) in else_phis.iter().rev().zip(then_phis.iter().rev()) {
                     let (value, info) = self.state.pop1_extra()?;
-                    let value = self.apply_pending_canonicalization(value, info);
+                    let value = self.apply_pending_canonicalization(value, info)?;
                     else_phi.add_incoming(&[(&value, current_block)]);
                     then_phi.add_incoming(&[(&value, current_block)]);
                 }
@@ -1748,12 +1816,12 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
 
                     for phi in frame.phis().to_vec().iter().rev() {
                         let (value, info) = self.state.pop1_extra()?;
-                        let value = self.apply_pending_canonicalization(value, info);
+                        let value = self.apply_pending_canonicalization(value, info)?;
                         phi.add_incoming(&[(&value, current_block)])
                     }
 
                     let frame = self.state.frame_at_depth(0)?;
-                    self.builder.build_unconditional_branch(*frame.code_after());
+                    err!(self.builder.build_unconditional_branch(*frame.code_after()));
                 }
 
                 let (if_else_block, if_else_state) = if let ControlFrame::IfElse {
@@ -1790,11 +1858,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 if self.state.reachable {
                     for phi in frame.phis().iter().rev() {
                         let (value, info) = self.state.pop1_extra()?;
-                        let value = self.apply_pending_canonicalization(value, info);
+                        let value = self.apply_pending_canonicalization(value, info)?;
                         phi.add_incoming(&[(&value, current_block)]);
                     }
 
-                    self.builder.build_unconditional_branch(*frame.code_after());
+                    err!(self.builder.build_unconditional_branch(*frame.code_after()));
                 }
 
                 if let ControlFrame::IfElse {
@@ -1809,7 +1877,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         phi.add_incoming(&[(&else_phi.as_basic_value(), *if_else)]);
                     }
                     self.builder.position_at_end(*if_else);
-                    self.builder.build_unconditional_branch(*next);
+                    err!(self.builder.build_unconditional_branch(*next));
                 }
 
                 self.builder.position_at_end(*frame.code_after());
@@ -1838,11 +1906,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let frame = self.state.outermost_frame()?;
                 for phi in frame.phis().to_vec().iter().rev() {
                     let (arg, info) = self.state.pop1_extra()?;
-                    let arg = self.apply_pending_canonicalization(arg, info);
+                    let arg = self.apply_pending_canonicalization(arg, info)?;
                     phi.add_incoming(&[(&arg, current_block)]);
                 }
                 let frame = self.state.outermost_frame()?;
-                self.builder.build_unconditional_branch(*frame.br_dest());
+                err!(self.builder.build_unconditional_branch(*frame.br_dest()));
 
                 self.state.reachable = false;
             }
@@ -1882,12 +1950,12 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 }
                 */
 
-                self.builder.build_call(
+                err!(self.builder.build_call(
                     self.intrinsics.throw_trap,
                     &[self.intrinsics.trap_unreachable.into()],
                     "throw",
-                );
-                self.builder.build_unreachable();
+                ));
+                err!(self.builder.build_unreachable());
 
                 self.state.reachable = false;
             }
@@ -1929,9 +1997,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 } else {
                     Default::default()
                 };
-                let f = self
+                let f = err!(self
                     .builder
-                    .build_bitcast(bits, self.intrinsics.f32_ty, "f");
+                    .build_bit_cast(bits, self.intrinsics.f32_ty, "f"));
                 self.state.push1_extra(f, info);
             }
             Operator::F64Const { value } => {
@@ -1941,9 +2009,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 } else {
                     Default::default()
                 };
-                let f = self
+                let f = err!(self
                     .builder
-                    .build_bitcast(bits, self.intrinsics.f64_ty, "f");
+                    .build_bit_cast(bits, self.intrinsics.f64_ty, "f"));
                 self.state.push1_extra(f, info);
             }
             Operator::V128Const { value } => {
@@ -1981,47 +2049,59 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             Operator::I8x16Splat => {
                 let (v, i) = self.state.pop1_extra()?;
                 let v = v.into_int_value();
-                let v = self
+                let v = err!(self
+                    .builder
+                    .build_int_truncate(v, self.intrinsics.i8_ty, ""));
+                let res = self.splat_vector(v.as_basic_value_enum(), self.intrinsics.i8x16_ty)?;
+                let res = err!(self
                     .builder
-                    .build_int_truncate(v, self.intrinsics.i8_ty, "");
-                let res = self.splat_vector(v.as_basic_value_enum(), self.intrinsics.i8x16_ty);
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1_extra(res, i);
             }
             Operator::I16x8Splat => {
                 let (v, i) = self.state.pop1_extra()?;
                 let v = v.into_int_value();
-                let v = self
+                let v = err!(self
+                    .builder
+                    .build_int_truncate(v, self.intrinsics.i16_ty, ""));
+                let res = self.splat_vector(v.as_basic_value_enum(), self.intrinsics.i16x8_ty)?;
+                let res = err!(self
                     .builder
-                    .build_int_truncate(v, self.intrinsics.i16_ty, "");
-                let res = self.splat_vector(v.as_basic_value_enum(), self.intrinsics.i16x8_ty);
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1_extra(res, i);
             }
             Operator::I32x4Splat => {
                 let (v, i) = self.state.pop1_extra()?;
-                let res = self.splat_vector(v, self.intrinsics.i32x4_ty);
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = self.splat_vector(v, self.intrinsics.i32x4_ty)?;
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1_extra(res, i);
             }
             Operator::I64x2Splat => {
                 let (v, i) = self.state.pop1_extra()?;
-                let res = self.splat_vector(v, self.intrinsics.i64x2_ty);
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = self.splat_vector(v, self.intrinsics.i64x2_ty)?;
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1_extra(res, i);
             }
             Operator::F32x4Splat => {
                 let (v, i) = self.state.pop1_extra()?;
-                let res = self.splat_vector(v, self.intrinsics.f32x4_ty);
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = self.splat_vector(v, self.intrinsics.f32x4_ty)?;
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 // The spec is unclear, we interpret splat as preserving NaN
                 // payload bits.
                 self.state.push1_extra(res, i);
             }
             Operator::F64x2Splat => {
                 let (v, i) = self.state.pop1_extra()?;
-                let res = self.splat_vector(v, self.intrinsics.f64x2_ty);
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = self.splat_vector(v, self.intrinsics.f64x2_ty)?;
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 // The spec is unclear, we interpret splat as preserving NaN
                 // payload bits.
                 self.state.push1_extra(res, i);
@@ -2030,7 +2110,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             // Operate on self.locals.
             Operator::LocalGet { local_index } => {
                 let (type_value, pointer_value) = self.locals[local_index as usize];
-                let v = self.builder.build_load(type_value, pointer_value, "");
+                let v = err!(self.builder.build_load(type_value, pointer_value, ""));
                 tbaa_label(
                     self.module,
                     self.intrinsics,
@@ -2042,8 +2122,8 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             Operator::LocalSet { local_index } => {
                 let pointer_value = self.locals[local_index as usize].1;
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
-                let store = self.builder.build_store(pointer_value, v);
+                let v = self.apply_pending_canonicalization(v, i)?;
+                let store = err!(self.builder.build_store(pointer_value, v));
                 tbaa_label(
                     self.module,
                     self.intrinsics,
@@ -2054,8 +2134,8 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             Operator::LocalTee { local_index } => {
                 let pointer_value = self.locals[local_index as usize].1;
                 let (v, i) = self.state.peek1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
-                let store = self.builder.build_store(pointer_value, v);
+                let v = self.apply_pending_canonicalization(v, i)?;
+                let store = err!(self.builder.build_store(pointer_value, v));
                 tbaa_label(
                     self.module,
                     self.intrinsics,
@@ -2077,7 +2157,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         ptr_to_value,
                         value_type,
                     } => {
-                        let value = self.builder.build_load(*value_type, *ptr_to_value, "");
+                        let value = err!(self.builder.build_load(*value_type, *ptr_to_value, ""));
                         tbaa_label(
                             self.module,
                             self.intrinsics,
@@ -2103,8 +2183,8 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     GlobalCache::Mut { ptr_to_value, .. } => {
                         let ptr_to_value = *ptr_to_value;
                         let (value, info) = self.state.pop1_extra()?;
-                        let value = self.apply_pending_canonicalization(value, info);
-                        let store = self.builder.build_store(ptr_to_value, value);
+                        let value = self.apply_pending_canonicalization(value, info)?;
+                        let store = err!(self.builder.build_store(ptr_to_value, value));
                         tbaa_label(
                             self.module,
                             self.intrinsics,
@@ -2130,21 +2210,21 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     || i1.has_pending_f64_nan() != i2.has_pending_f64_nan()
                 {
                     (
-                        self.apply_pending_canonicalization(v1, i1),
+                        self.apply_pending_canonicalization(v1, i1)?,
                         i1.strip_pending(),
-                        self.apply_pending_canonicalization(v2, i2),
+                        self.apply_pending_canonicalization(v2, i2)?,
                         i2.strip_pending(),
                     )
                 } else {
                     (v1, i1, v2, i2)
                 };
-                let cond_value = self.builder.build_int_compare(
+                let cond_value = err!(self.builder.build_int_compare(
                     IntPredicate::NE,
                     cond.into_int_value(),
                     self.intrinsics.i32_zero,
                     "",
-                );
-                let res = self.builder.build_select(cond_value, v1, v2, "");
+                ));
+                let res = err!(self.builder.build_select(cond_value, v1, v2, ""));
                 let info = {
                     let mut info = i1.strip_pending() & i2.strip_pending();
                     if i1.has_pending_f32_nan() {
@@ -2203,20 +2283,20 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     .iter()
                     .zip(func_type.params().iter())
                     .map(|((v, info), wasm_ty)| match wasm_ty {
-                        Type::F32 => self.builder.build_bitcast(
-                            self.apply_pending_canonicalization(*v, *info),
+                        Type::F32 => err_nt!(self.builder.build_bit_cast(
+                            self.apply_pending_canonicalization(*v, *info)?,
                             self.intrinsics.f32_ty,
                             "",
-                        ),
-                        Type::F64 => self.builder.build_bitcast(
-                            self.apply_pending_canonicalization(*v, *info),
+                        )),
+                        Type::F64 => err_nt!(self.builder.build_bit_cast(
+                            self.apply_pending_canonicalization(*v, *info)?,
                             self.intrinsics.f64_ty,
                             "",
-                        ),
+                        )),
                         Type::V128 => self.apply_pending_canonicalization(*v, *info),
-                        _ => *v,
+                        _ => Ok(*v),
                     })
-                    .collect::<Vec<_>>();
+                    .collect::<Result<Vec<_>, _>>()?;
 
                 let params = self.abi.args_to_call(
                     &self.alloca_builder,
@@ -2225,7 +2305,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     callee_vmctx.into_pointer_value(),
                     params.as_slice(),
                     self.intrinsics,
-                );
+                )?;
 
                 /*
                 if self.track_state {
@@ -2246,7 +2326,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     }
                 }
                 */
-                let call_site = self.builder.build_indirect_call(
+                let call_site = err!(self.builder.build_indirect_call(
                     llvm_func_type,
                     func,
                     params
@@ -2256,7 +2336,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         .collect::<Vec<BasicMetadataValueEnum>>()
                         .as_slice(),
                     "",
-                );
+                ));
                 for (attr, attr_loc) in attrs {
                     call_site.add_attribute(attr_loc, attr);
                 }
@@ -2277,7 +2357,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 */
 
                 self.abi
-                    .rets_from_call(&self.builder, self.intrinsics, call_site, func_type)
+                    .rets_from_call(&self.builder, self.intrinsics, call_site, func_type)?
                     .iter()
                     .for_each(|ret| self.state.push1(*ret));
             }
@@ -2289,42 +2369,40 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let func_type = &self.wasm_module.signatures[sigindex];
                 let expected_dynamic_sigindex =
                     self.ctx
-                        .dynamic_sigindex(sigindex, self.intrinsics, self.module);
+                        .dynamic_sigindex(sigindex, self.intrinsics, self.module)?;
                 let (table_base, table_bound) = self.ctx.table(
                     TableIndex::from_u32(table_index),
                     self.intrinsics,
                     self.module,
-                );
+                )?;
                 let func_index = self.state.pop1()?.into_int_value();
 
-                let truncated_table_bounds = self.builder.build_int_truncate(
+                let truncated_table_bounds = err!(self.builder.build_int_truncate(
                     table_bound,
                     self.intrinsics.i32_ty,
                     "truncated_table_bounds",
-                );
+                ));
 
                 // First, check if the index is outside of the table bounds.
-                let index_in_bounds = self.builder.build_int_compare(
+                let index_in_bounds = err!(self.builder.build_int_compare(
                     IntPredicate::ULT,
                     func_index,
                     truncated_table_bounds,
                     "index_in_bounds",
-                );
+                ));
 
-                let index_in_bounds = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.expect_i1,
-                        &[
-                            index_in_bounds.into(),
-                            self.intrinsics.i1_ty.const_int(1, false).into(),
-                        ],
-                        "index_in_bounds_expect",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_int_value();
+                let index_in_bounds = err!(self.builder.build_call(
+                    self.intrinsics.expect_i1,
+                    &[
+                        index_in_bounds.into(),
+                        self.intrinsics.i1_ty.const_int(1, false).into(),
+                    ],
+                    "index_in_bounds_expect",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_int_value();
 
                 let in_bounds_continue_block = self
                     .context
@@ -2332,52 +2410,50 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let not_in_bounds_block = self
                     .context
                     .append_basic_block(self.function, "not_in_bounds_block");
-                self.builder.build_conditional_branch(
+                err!(self.builder.build_conditional_branch(
                     index_in_bounds,
                     in_bounds_continue_block,
                     not_in_bounds_block,
-                );
+                ));
                 self.builder.position_at_end(not_in_bounds_block);
-                self.builder.build_call(
+                err!(self.builder.build_call(
                     self.intrinsics.throw_trap,
                     &[self.intrinsics.trap_table_access_oob.into()],
                     "throw",
-                );
-                self.builder.build_unreachable();
+                ));
+                err!(self.builder.build_unreachable());
                 self.builder.position_at_end(in_bounds_continue_block);
 
                 // We assume the table has the `funcref` (pointer to `anyfunc`)
                 // element type.
-                let casted_table_base = self.builder.build_pointer_cast(
+                let casted_table_base = err!(self.builder.build_pointer_cast(
                     table_base,
-                    self.intrinsics.funcref_ty.ptr_type(AddressSpace::default()),
+                    self.context.ptr_type(AddressSpace::default()),
                     "casted_table_base",
-                );
+                ));
 
                 let funcref_ptr = unsafe {
-                    self.builder.build_in_bounds_gep(
-                        self.intrinsics.funcref_ty,
+                    err!(self.builder.build_in_bounds_gep(
+                        self.intrinsics.ptr_ty,
                         casted_table_base,
                         &[func_index],
                         "funcref_ptr",
-                    )
+                    ))
                 };
 
                 // a funcref (pointer to `anyfunc`)
-                let anyfunc_struct_ptr = self
-                    .builder
-                    .build_load(
-                        self.intrinsics.funcref_ty,
-                        funcref_ptr,
-                        "anyfunc_struct_ptr",
-                    )
-                    .into_pointer_value();
+                let anyfunc_struct_ptr = err!(self.builder.build_load(
+                    self.intrinsics.ptr_ty,
+                    funcref_ptr,
+                    "anyfunc_struct_ptr",
+                ))
+                .into_pointer_value();
 
                 // trap if we're trying to call a null funcref
                 {
-                    let funcref_not_null = self
+                    let funcref_not_null = err!(self
                         .builder
-                        .build_is_not_null(anyfunc_struct_ptr, "null funcref check");
+                        .build_is_not_null(anyfunc_struct_ptr, "null funcref check"));
 
                     let funcref_continue_deref_block = self
                         .context
@@ -2386,18 +2462,18 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     let funcref_is_null_block = self
                         .context
                         .append_basic_block(self.function, "funcref_is_null_block");
-                    self.builder.build_conditional_branch(
+                    err!(self.builder.build_conditional_branch(
                         funcref_not_null,
                         funcref_continue_deref_block,
                         funcref_is_null_block,
-                    );
+                    ));
                     self.builder.position_at_end(funcref_is_null_block);
-                    self.builder.build_call(
+                    err!(self.builder.build_call(
                         self.intrinsics.throw_trap,
                         &[self.intrinsics.trap_call_indirect_null.into()],
                         "throw",
-                    );
-                    self.builder.build_unreachable();
+                    ));
+                    err!(self.builder.build_unreachable());
                     self.builder.position_at_end(funcref_continue_deref_block);
                 }
 
@@ -2430,49 +2506,51 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     )
                     .unwrap();
                 let (func_ptr, found_dynamic_sigindex, ctx_ptr) = (
-                    self.builder
-                        .build_load(self.intrinsics.i8_ptr_ty, func_ptr_ptr, "func_ptr")
-                        .into_pointer_value(),
-                    self.builder
-                        .build_load(self.intrinsics.i32_ty, sigindex_ptr, "sigindex")
-                        .into_int_value(),
-                    self.builder
-                        .build_load(self.intrinsics.ctx_ptr_ty, ctx_ptr_ptr, "ctx_ptr"),
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.ptr_ty, func_ptr_ptr, "func_ptr"))
+                    .into_pointer_value(),
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i32_ty, sigindex_ptr, "sigindex"))
+                    .into_int_value(),
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.ptr_ty, ctx_ptr_ptr, "ctx_ptr")),
                 );
 
                 // Next, check if the table element is initialized.
 
                 // TODO: we may not need this check anymore
-                let elem_initialized = self.builder.build_is_not_null(func_ptr, "");
+                let elem_initialized = err!(self.builder.build_is_not_null(func_ptr, ""));
 
                 // Next, check if the signature id is correct.
 
-                let sigindices_equal = self.builder.build_int_compare(
+                let sigindices_equal = err!(self.builder.build_int_compare(
                     IntPredicate::EQ,
                     expected_dynamic_sigindex,
                     found_dynamic_sigindex,
                     "sigindices_equal",
-                );
+                ));
 
                 let initialized_and_sigindices_match =
-                    self.builder
-                        .build_and(elem_initialized, sigindices_equal, "");
+                    err!(self
+                        .builder
+                        .build_and(elem_initialized, sigindices_equal, ""));
 
                 // Tell llvm that `expected_dynamic_sigindex` should equal `found_dynamic_sigindex`.
-                let initialized_and_sigindices_match = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.expect_i1,
-                        &[
-                            initialized_and_sigindices_match.into(),
-                            self.intrinsics.i1_ty.const_int(1, false).into(),
-                        ],
-                        "initialized_and_sigindices_match_expect",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_int_value();
+                let initialized_and_sigindices_match = err!(self.builder.build_call(
+                    self.intrinsics.expect_i1,
+                    &[
+                        initialized_and_sigindices_match.into(),
+                        self.intrinsics.i1_ty.const_int(1, false).into(),
+                    ],
+                    "initialized_and_sigindices_match_expect",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_int_value();
 
                 let continue_block = self
                     .context
@@ -2480,22 +2558,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let sigindices_notequal_block = self
                     .context
                     .append_basic_block(self.function, "sigindices_notequal_block");
-                self.builder.build_conditional_branch(
+                err!(self.builder.build_conditional_branch(
                     initialized_and_sigindices_match,
                     continue_block,
                     sigindices_notequal_block,
-                );
+                ));
 
                 self.builder.position_at_end(sigindices_notequal_block);
-                let trap_code = self.builder.build_select(
+                let trap_code = err!(self.builder.build_select(
                     elem_initialized,
                     self.intrinsics.trap_call_indirect_sig,
                     self.intrinsics.trap_call_indirect_null,
                     "",
-                );
-                self.builder
-                    .build_call(self.intrinsics.throw_trap, &[trap_code.into()], "throw");
-                self.builder.build_unreachable();
+                ));
+                err!(self.builder.build_call(
+                    self.intrinsics.throw_trap,
+                    &[trap_code.into()],
+                    "throw"
+                ));
+                err!(self.builder.build_unreachable());
                 self.builder.position_at_end(continue_block);
 
                 let (llvm_func_type, llvm_func_attrs) = self.abi.func_type_to_llvm(
@@ -2508,39 +2589,39 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let params = self.state.popn_save_extra(func_type.params().len())?;
 
                 // Apply pending canonicalizations.
-                let params =
-                    params
-                        .iter()
-                        .zip(func_type.params().iter())
-                        .map(|((v, info), wasm_ty)| match wasm_ty {
-                            Type::F32 => self.builder.build_bitcast(
-                                self.apply_pending_canonicalization(*v, *info),
-                                self.intrinsics.f32_ty,
-                                "",
-                            ),
-                            Type::F64 => self.builder.build_bitcast(
-                                self.apply_pending_canonicalization(*v, *info),
-                                self.intrinsics.f64_ty,
-                                "",
-                            ),
-                            Type::V128 => self.apply_pending_canonicalization(*v, *info),
-                            _ => *v,
-                        });
+                let params = params
+                    .iter()
+                    .zip(func_type.params().iter())
+                    .map(|((v, info), wasm_ty)| match wasm_ty {
+                        Type::F32 => err_nt!(self.builder.build_bit_cast(
+                            self.apply_pending_canonicalization(*v, *info)?,
+                            self.intrinsics.f32_ty,
+                            "",
+                        )),
+                        Type::F64 => err_nt!(self.builder.build_bit_cast(
+                            self.apply_pending_canonicalization(*v, *info)?,
+                            self.intrinsics.f64_ty,
+                            "",
+                        )),
+                        Type::V128 => self.apply_pending_canonicalization(*v, *info),
+                        _ => Ok(*v),
+                    })
+                    .collect::<Result<Vec<_>, _>>()?;
 
                 let params = self.abi.args_to_call(
                     &self.alloca_builder,
                     func_type,
                     &llvm_func_type,
                     ctx_ptr.into_pointer_value(),
-                    params.collect::<Vec<_>>().as_slice(),
+                    params.as_slice(),
                     self.intrinsics,
-                );
+                )?;
 
-                let typed_func_ptr = self.builder.build_pointer_cast(
+                let typed_func_ptr = err!(self.builder.build_pointer_cast(
                     func_ptr,
-                    llvm_func_type.ptr_type(AddressSpace::default()),
+                    self.context.ptr_type(AddressSpace::default()),
                     "typed_func_ptr",
-                );
+                ));
 
                 /*
                 if self.track_state {
@@ -2561,7 +2642,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     }
                 }
                 */
-                let call_site = self.builder.build_indirect_call(
+                let call_site = err!(self.builder.build_indirect_call(
                     llvm_func_type,
                     typed_func_ptr,
                     params
@@ -2571,7 +2652,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         .collect::<Vec<BasicMetadataValueEnum>>()
                         .as_slice(),
                     "indirect_call",
-                );
+                ));
                 for (attr, attr_loc) in llvm_func_attrs {
                     call_site.add_attribute(attr_loc, attr);
                 }
@@ -2592,7 +2673,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 */
 
                 self.abi
-                    .rets_from_call(&self.builder, self.intrinsics, call_site, func_type)
+                    .rets_from_call(&self.builder, self.intrinsics, call_site, func_type)?
                     .iter()
                     .for_each(|ret| self.state.push1(*ret));
             }
@@ -2603,26 +2684,30 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
              ***************************/
             Operator::I32Add | Operator::I64Add => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
-                let res = self.builder.build_int_add(v1, v2, "");
+                let res = err!(self.builder.build_int_add(v1, v2, ""));
                 self.state.push1(res);
             }
             Operator::I8x16Add => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let res = self.builder.build_int_add(v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let res = err!(self.builder.build_int_add(v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8Add => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let res = self.builder.build_int_add(v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let res = err!(self.builder.build_int_add(v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8ExtAddPairwiseI8x16S | Operator::I16x8ExtAddPairwiseI8x16U => {
@@ -2636,9 +2721,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     _ => unreachable!("Unhandled internal variant"),
                 };
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i8x16(v, i);
+                let (v, _) = self.v128_into_i8x16(v, i)?;
 
-                let left = self.builder.build_shuffle_vector(
+                let left = err!(self.builder.build_shuffle_vector(
                     v,
                     v.get_type().get_undef(),
                     VectorType::const_vector(&[
@@ -2652,9 +2737,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[14],
                     ]),
                     "",
-                );
-                let left = extend_op(self, left);
-                let right = self.builder.build_shuffle_vector(
+                ));
+                let left = err!(extend_op(self, left));
+                let right = err!(self.builder.build_shuffle_vector(
                     v,
                     v.get_type().get_undef(),
                     VectorType::const_vector(&[
@@ -2668,19 +2753,23 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[15],
                     ]),
                     "",
-                );
-                let right = extend_op(self, right);
+                ));
+                let right = err!(extend_op(self, right));
 
-                let res = self.builder.build_int_add(left, right, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self.builder.build_int_add(left, right, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4Add => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
-                let res = self.builder.build_int_add(v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
+                let res = err!(self.builder.build_int_add(v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4ExtAddPairwiseI16x8S | Operator::I32x4ExtAddPairwiseI16x8U => {
@@ -2694,9 +2783,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     _ => unreachable!("Unhandled internal variant"),
                 };
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i16x8(v, i);
+                let (v, _) = self.v128_into_i16x8(v, i)?;
 
-                let left = self.builder.build_shuffle_vector(
+                let left = err!(self.builder.build_shuffle_vector(
                     v,
                     v.get_type().get_undef(),
                     VectorType::const_vector(&[
@@ -2706,9 +2795,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[6],
                     ]),
                     "",
-                );
-                let left = extend_op(self, left);
-                let right = self.builder.build_shuffle_vector(
+                ));
+                let left = err!(extend_op(self, left));
+                let right = err!(self.builder.build_shuffle_vector(
                     v,
                     v.get_type().get_undef(),
                     VectorType::const_vector(&[
@@ -2718,201 +2807,251 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[7],
                     ]),
                     "",
-                );
-                let right = extend_op(self, right);
+                ));
+                let right = err!(extend_op(self, right));
 
-                let res = self.builder.build_int_add(left, right, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self.builder.build_int_add(left, right, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64x2Add => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i64x2(v1, i1);
-                let (v2, _) = self.v128_into_i64x2(v2, i2);
-                let res = self.builder.build_int_add(v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let (v1, _) = self.v128_into_i64x2(v1, i1)?;
+                let (v2, _) = self.v128_into_i64x2(v2, i2)?;
+                let res = err!(self.builder.build_int_add(v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I8x16AddSatS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.sadd_sat_i8x16,
+                    &[v1.into(), v2.into()],
+                    ""
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
+                let res = err!(self
                     .builder
-                    .build_call(self.intrinsics.sadd_sat_i8x16, &[v1.into(), v2.into()], "")
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8AddSatS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.sadd_sat_i16x8, &[v1.into(), v2.into()], "")
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.sadd_sat_i16x8,
+                    &[v1.into(), v2.into()],
+                    ""
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I8x16AddSatU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.uadd_sat_i8x16,
+                    &[v1.into(), v2.into()],
+                    ""
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
+                let res = err!(self
                     .builder
-                    .build_call(self.intrinsics.uadd_sat_i8x16, &[v1.into(), v2.into()], "")
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8AddSatU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.uadd_sat_i16x8,
+                    &[v1.into(), v2.into()],
+                    ""
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
+                let res = err!(self
                     .builder
-                    .build_call(self.intrinsics.uadd_sat_i16x8, &[v1.into(), v2.into()], "")
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32Sub | Operator::I64Sub => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
-                let res = self.builder.build_int_sub(v1, v2, "");
+                let res = err!(self.builder.build_int_sub(v1, v2, ""));
                 self.state.push1(res);
             }
             Operator::I8x16Sub => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let res = self.builder.build_int_sub(v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let res = err!(self.builder.build_int_sub(v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8Sub => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let res = self.builder.build_int_sub(v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let res = err!(self.builder.build_int_sub(v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4Sub => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
-                let res = self.builder.build_int_sub(v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
+                let res = err!(self.builder.build_int_sub(v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64x2Sub => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i64x2(v1, i1);
-                let (v2, _) = self.v128_into_i64x2(v2, i2);
-                let res = self.builder.build_int_sub(v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let (v1, _) = self.v128_into_i64x2(v1, i1)?;
+                let (v2, _) = self.v128_into_i64x2(v2, i2)?;
+                let res = err!(self.builder.build_int_sub(v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I8x16SubSatS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.ssub_sat_i8x16,
+                    &[v1.into(), v2.into()],
+                    ""
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
+                let res = err!(self
                     .builder
-                    .build_call(self.intrinsics.ssub_sat_i8x16, &[v1.into(), v2.into()], "")
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8SubSatS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.ssub_sat_i16x8,
+                    &[v1.into(), v2.into()],
+                    ""
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
+                let res = err!(self
                     .builder
-                    .build_call(self.intrinsics.ssub_sat_i16x8, &[v1.into(), v2.into()], "")
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I8x16SubSatU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.usub_sat_i8x16,
+                    &[v1.into(), v2.into()],
+                    ""
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
+                let res = err!(self
                     .builder
-                    .build_call(self.intrinsics.usub_sat_i8x16, &[v1.into(), v2.into()], "")
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8SubSatU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.usub_sat_i16x8,
+                    &[v1.into(), v2.into()],
+                    ""
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
+                let res = err!(self
                     .builder
-                    .build_call(self.intrinsics.usub_sat_i16x8, &[v1.into(), v2.into()], "")
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32Mul | Operator::I64Mul => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
-                let res = self.builder.build_int_mul(v1, v2, "");
+                let res = err!(self.builder.build_int_mul(v1, v2, ""));
                 self.state.push1(res);
             }
             Operator::I16x8Mul => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let res = self.builder.build_int_mul(v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let res = err!(self.builder.build_int_mul(v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4Mul => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
-                let res = self.builder.build_int_mul(v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
+                let res = err!(self.builder.build_int_mul(v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64x2Mul => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i64x2(v1, i1);
-                let (v2, _) = self.v128_into_i64x2(v2, i2);
-                let res = self.builder.build_int_mul(v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let (v1, _) = self.v128_into_i64x2(v1, i1)?;
+                let (v2, _) = self.v128_into_i64x2(v2, i2)?;
+                let res = err!(self.builder.build_int_mul(v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8Q15MulrSatS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
 
                 let max_value = self
                     .intrinsics
@@ -2920,41 +3059,44 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     .const_int(i16::max_value() as u64, false);
                 let max_values = VectorType::const_vector(&[max_value; 8]);
 
-                let v1 = self
+                let v1 = err!(self
                     .builder
-                    .build_int_s_extend(v1, self.intrinsics.i32x8_ty, "");
-                let v2 = self
+                    .build_int_s_extend(v1, self.intrinsics.i32x8_ty, ""));
+                let v2 = err!(self
                     .builder
-                    .build_int_s_extend(v2, self.intrinsics.i32x8_ty, "");
-                let res = self.builder.build_int_mul(v1, v2, "");
+                    .build_int_s_extend(v2, self.intrinsics.i32x8_ty, ""));
+                let res = err!(self.builder.build_int_mul(v1, v2, ""));
 
                 // magic number specified by the spec
                 let bit = self.intrinsics.i32_ty.const_int(0x4000, false);
                 let bits = VectorType::const_vector(&[bit; 8]);
 
-                let res = self.builder.build_int_add(res, bits, "");
+                let res = err!(self.builder.build_int_add(res, bits, ""));
 
                 let fifteen = self.intrinsics.i32_consts[15];
                 let fifteens = VectorType::const_vector(&[fifteen; 8]);
 
-                let res = self.builder.build_right_shift(res, fifteens, true, "");
+                let res = err!(self.builder.build_right_shift(res, fifteens, true, ""));
                 let saturate_up = {
-                    let max_values =
-                        self.builder
-                            .build_int_s_extend(max_values, self.intrinsics.i32x8_ty, "");
-                    self.builder
-                        .build_int_compare(IntPredicate::SGT, res, max_values, "")
+                    let max_values = err!(self.builder.build_int_s_extend(
+                        max_values,
+                        self.intrinsics.i32x8_ty,
+                        ""
+                    ));
+                    err!(self
+                        .builder
+                        .build_int_compare(IntPredicate::SGT, res, max_values, ""))
                 };
 
-                let res = self
+                let res = err!(self
                     .builder
-                    .build_int_truncate(res, self.intrinsics.i16x8_ty, "");
+                    .build_int_truncate(res, self.intrinsics.i16x8_ty, ""));
 
-                let res = self
-                    .builder
-                    .build_select(saturate_up, max_values, res, "")
+                let res = err!(self.builder.build_select(saturate_up, max_values, res, ""))
                     .into_vector_value();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8ExtMulLowI8x16S
@@ -2963,10 +3105,14 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             | Operator::I16x8ExtMulHighI8x16U => {
                 let extend_op = match op {
                     Operator::I16x8ExtMulLowI8x16S | Operator::I16x8ExtMulHighI8x16S => {
-                        |s: &Self, v| s.builder.build_int_s_extend(v, s.intrinsics.i16x8_ty, "")
+                        |s: &Self, v| -> Result<VectorValue, CompileError> {
+                            err_nt!(s.builder.build_int_s_extend(v, s.intrinsics.i16x8_ty, ""))
+                        }
                     }
                     Operator::I16x8ExtMulLowI8x16U | Operator::I16x8ExtMulHighI8x16U => {
-                        |s: &Self, v| s.builder.build_int_z_extend(v, s.intrinsics.i16x8_ty, "")
+                        |s: &Self, v| -> Result<VectorValue, CompileError> {
+                            err_nt!(s.builder.build_int_z_extend(v, s.intrinsics.i16x8_ty, ""))
+                        }
                     }
                     _ => unreachable!("Unhandled internal variant"),
                 };
@@ -2994,24 +3140,26 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     _ => unreachable!("Unhandled internal variant"),
                 };
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let val1 = self.builder.build_shuffle_vector(
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let val1 = err!(self.builder.build_shuffle_vector(
                     v1,
                     v1.get_type().get_undef(),
                     VectorType::const_vector(&shuffle_array),
                     "",
-                );
-                let val1 = extend_op(self, val1);
-                let val2 = self.builder.build_shuffle_vector(
+                ));
+                let val1 = err!(extend_op(self, val1));
+                let val2 = err!(self.builder.build_shuffle_vector(
                     v2,
                     v2.get_type().get_undef(),
                     VectorType::const_vector(&shuffle_array),
                     "",
-                );
-                let val2 = extend_op(self, val2);
-                let res = self.builder.build_int_mul(val1, val2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                ));
+                let val2 = err!(extend_op(self, val2));
+                let res = err!(self.builder.build_int_mul(val1, val2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4ExtMulLowI16x8S
@@ -3043,24 +3191,26 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     _ => unreachable!("Unhandled internal variant"),
                 };
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let val1 = self.builder.build_shuffle_vector(
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let val1 = err!(self.builder.build_shuffle_vector(
                     v1,
                     v1.get_type().get_undef(),
                     VectorType::const_vector(&shuffle_array),
                     "",
-                );
-                let val1 = extend_op(self, val1);
-                let val2 = self.builder.build_shuffle_vector(
+                ));
+                let val1 = err!(extend_op(self, val1));
+                let val2 = err!(self.builder.build_shuffle_vector(
                     v2,
                     v2.get_type().get_undef(),
                     VectorType::const_vector(&shuffle_array),
                     "",
-                );
-                let val2 = extend_op(self, val2);
-                let res = self.builder.build_int_mul(val1, val2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                ));
+                let val2 = err!(extend_op(self, val2));
+                let res = err!(self.builder.build_int_mul(val1, val2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64x2ExtMulLowI32x4S
@@ -3086,30 +3236,32 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     _ => unreachable!("Unhandled internal variant"),
                 };
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
-                let val1 = self.builder.build_shuffle_vector(
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
+                let val1 = err!(self.builder.build_shuffle_vector(
                     v1,
                     v1.get_type().get_undef(),
                     VectorType::const_vector(&shuffle_array),
                     "",
-                );
-                let val1 = extend_op(self, val1);
-                let val2 = self.builder.build_shuffle_vector(
+                ));
+                let val1 = err!(extend_op(self, val1));
+                let val2 = err!(self.builder.build_shuffle_vector(
                     v2,
                     v2.get_type().get_undef(),
                     VectorType::const_vector(&shuffle_array),
                     "",
-                );
-                let val2 = extend_op(self, val2);
-                let res = self.builder.build_int_mul(val1, val2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                ));
+                let val2 = err!(extend_op(self, val2));
+                let res = err!(self.builder.build_int_mul(val1, val2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4DotI16x8S => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
                 let low_i16 = [
                     self.intrinsics.i32_consts[0],
                     self.intrinsics.i32_consts[2],
@@ -3122,75 +3274,81 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     self.intrinsics.i32_consts[5],
                     self.intrinsics.i32_consts[7],
                 ];
-                let v1_low = self.builder.build_shuffle_vector(
+                let v1_low = err!(self.builder.build_shuffle_vector(
                     v1,
                     v1.get_type().get_undef(),
                     VectorType::const_vector(&low_i16),
                     "",
-                );
-                let v1_low = self
-                    .builder
-                    .build_int_s_extend(v1_low, self.intrinsics.i32x4_ty, "");
-                let v1_high = self.builder.build_shuffle_vector(
+                ));
+                let v1_low =
+                    err!(self
+                        .builder
+                        .build_int_s_extend(v1_low, self.intrinsics.i32x4_ty, ""));
+                let v1_high = err!(self.builder.build_shuffle_vector(
                     v1,
                     v1.get_type().get_undef(),
                     VectorType::const_vector(&high_i16),
                     "",
-                );
+                ));
                 let v1_high =
-                    self.builder
-                        .build_int_s_extend(v1_high, self.intrinsics.i32x4_ty, "");
-                let v2_low = self.builder.build_shuffle_vector(
+                    err!(self
+                        .builder
+                        .build_int_s_extend(v1_high, self.intrinsics.i32x4_ty, ""));
+                let v2_low = err!(self.builder.build_shuffle_vector(
                     v2,
                     v2.get_type().get_undef(),
                     VectorType::const_vector(&low_i16),
                     "",
-                );
-                let v2_low = self
-                    .builder
-                    .build_int_s_extend(v2_low, self.intrinsics.i32x4_ty, "");
-                let v2_high = self.builder.build_shuffle_vector(
+                ));
+                let v2_low =
+                    err!(self
+                        .builder
+                        .build_int_s_extend(v2_low, self.intrinsics.i32x4_ty, ""));
+                let v2_high = err!(self.builder.build_shuffle_vector(
                     v2,
                     v2.get_type().get_undef(),
                     VectorType::const_vector(&high_i16),
                     "",
-                );
+                ));
                 let v2_high =
-                    self.builder
-                        .build_int_s_extend(v2_high, self.intrinsics.i32x4_ty, "");
-                let low_product = self.builder.build_int_mul(v1_low, v2_low, "");
-                let high_product = self.builder.build_int_mul(v1_high, v2_high, "");
+                    err!(self
+                        .builder
+                        .build_int_s_extend(v2_high, self.intrinsics.i32x4_ty, ""));
+                let low_product = err!(self.builder.build_int_mul(v1_low, v2_low, ""));
+                let high_product = err!(self.builder.build_int_mul(v1_high, v2_high, ""));
 
-                let res = self.builder.build_int_add(low_product, high_product, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self.builder.build_int_add(low_product, high_product, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32DivS | Operator::I64DivS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
 
-                self.trap_if_zero_or_overflow(v1, v2);
+                self.trap_if_zero_or_overflow(v1, v2)?;
 
-                let res = self.builder.build_int_signed_div(v1, v2, "");
+                let res = err!(self.builder.build_int_signed_div(v1, v2, ""));
                 self.state.push1(res);
             }
             Operator::I32DivU | Operator::I64DivU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
 
-                self.trap_if_zero(v2);
+                self.trap_if_zero(v2)?;
 
-                let res = self.builder.build_int_unsigned_div(v1, v2, "");
+                let res = err!(self.builder.build_int_unsigned_div(v1, v2, ""));
                 self.state.push1(res);
             }
             Operator::I32RemS | Operator::I64RemS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
                 let int_type = v1.get_type();
                 let (min_value, neg_one_value) = if int_type == self.intrinsics.i32_ty {
@@ -3205,7 +3363,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     unreachable!()
                 };
 
-                self.trap_if_zero(v2);
+                self.trap_if_zero(v2)?;
 
                 // "Overflow also leads to undefined behavior; this is a rare
                 // case, but can occur, for example, by taking the remainder of
@@ -3218,546 +3376,577 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 // In Wasm, the i32.rem_s i32.const -2147483648 i32.const -1 is
                 // i32.const 0. We implement this by swapping out the left value
                 // for 0 in this case.
-                let will_overflow = self.builder.build_and(
-                    self.builder
-                        .build_int_compare(IntPredicate::EQ, v1, min_value, "left_is_min"),
-                    self.builder.build_int_compare(
+                let will_overflow = err!(self.builder.build_and(
+                    err!(self.builder.build_int_compare(
+                        IntPredicate::EQ,
+                        v1,
+                        min_value,
+                        "left_is_min"
+                    )),
+                    err!(self.builder.build_int_compare(
                         IntPredicate::EQ,
                         v2,
                         neg_one_value,
                         "right_is_neg_one",
-                    ),
+                    )),
                     "srem_will_overflow",
-                );
-                let v1 = self
-                    .builder
-                    .build_select(will_overflow, int_type.const_zero(), v1, "")
+                ));
+                let v1 =
+                    err!(self
+                        .builder
+                        .build_select(will_overflow, int_type.const_zero(), v1, ""))
                     .into_int_value();
-                let res = self.builder.build_int_signed_rem(v1, v2, "");
+                let res = err!(self.builder.build_int_signed_rem(v1, v2, ""));
                 self.state.push1(res);
             }
             Operator::I32RemU | Operator::I64RemU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
 
-                self.trap_if_zero(v2);
+                self.trap_if_zero(v2)?;
 
-                let res = self.builder.build_int_unsigned_rem(v1, v2, "");
+                let res = err!(self.builder.build_int_unsigned_rem(v1, v2, ""));
                 self.state.push1(res);
             }
             Operator::I32And | Operator::I64And | Operator::V128And => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
-                let res = self.builder.build_and(v1, v2, "");
+                let res = err!(self.builder.build_and(v1, v2, ""));
                 self.state.push1(res);
             }
             Operator::I32Or | Operator::I64Or | Operator::V128Or => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
-                let res = self.builder.build_or(v1, v2, "");
+                let res = err!(self.builder.build_or(v1, v2, ""));
                 self.state.push1(res);
             }
             Operator::I32Xor | Operator::I64Xor | Operator::V128Xor => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
-                let res = self.builder.build_xor(v1, v2, "");
+                let res = err!(self.builder.build_xor(v1, v2, ""));
                 self.state.push1(res);
             }
             Operator::V128AndNot => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
-                let v2 = self.builder.build_not(v2, "");
-                let res = self.builder.build_and(v1, v2, "");
+                let v2 = err!(self.builder.build_not(v2, ""));
+                let res = err!(self.builder.build_and(v1, v2, ""));
                 self.state.push1(res);
             }
             Operator::V128Bitselect => {
                 let ((v1, i1), (v2, i2), (cond, cond_info)) = self.state.pop3_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
-                let cond = self.apply_pending_canonicalization(cond, cond_info);
-                let v1 = self
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
+                let cond = self.apply_pending_canonicalization(cond, cond_info)?;
+                let v1 = err!(self
                     .builder
-                    .build_bitcast(v1, self.intrinsics.i1x128_ty, "")
-                    .into_vector_value();
-                let v2 = self
+                    .build_bit_cast(v1, self.intrinsics.i1x128_ty, ""))
+                .into_vector_value();
+                let v2 = err!(self
                     .builder
-                    .build_bitcast(v2, self.intrinsics.i1x128_ty, "")
-                    .into_vector_value();
-                let cond = self
+                    .build_bit_cast(v2, self.intrinsics.i1x128_ty, ""))
+                .into_vector_value();
+                let cond = err!(self
                     .builder
-                    .build_bitcast(cond, self.intrinsics.i1x128_ty, "")
-                    .into_vector_value();
-                let res = self.builder.build_select(cond, v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(cond, self.intrinsics.i1x128_ty, ""))
+                .into_vector_value();
+                let res = err!(self.builder.build_select(cond, v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I8x16Bitmask => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i8x16(v, i);
+                let (v, _) = self.v128_into_i8x16(v, i)?;
 
                 let zeros = self.intrinsics.i8x16_ty.const_zero();
-                let res = self
-                    .builder
-                    .build_int_compare(IntPredicate::SLT, v, zeros, "");
-                let res = self
+                let res = err!(self
                     .builder
-                    .build_bitcast(res, self.intrinsics.i16_ty, "")
+                    .build_int_compare(IntPredicate::SLT, v, zeros, ""));
+                let res = err!(self.builder.build_bit_cast(res, self.intrinsics.i16_ty, ""))
                     .into_int_value();
-                let res = self
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(res, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(res, self.intrinsics.i32_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8Bitmask => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i16x8(v, i);
+                let (v, _) = self.v128_into_i16x8(v, i)?;
 
                 let zeros = self.intrinsics.i16x8_ty.const_zero();
-                let res = self
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SLT, v, zeros, "");
-                let res = self
-                    .builder
-                    .build_bitcast(res, self.intrinsics.i8_ty, "")
+                    .build_int_compare(IntPredicate::SLT, v, zeros, ""));
+                let res = err!(self.builder.build_bit_cast(res, self.intrinsics.i8_ty, ""))
                     .into_int_value();
-                let res = self
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(res, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(res, self.intrinsics.i32_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4Bitmask => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i32x4(v, i);
+                let (v, _) = self.v128_into_i32x4(v, i)?;
 
                 let zeros = self.intrinsics.i32x4_ty.const_zero();
-                let res = self
-                    .builder
-                    .build_int_compare(IntPredicate::SLT, v, zeros, "");
-                let res = self
+                let res = err!(self
                     .builder
-                    .build_bitcast(res, self.intrinsics.i4_ty, "")
+                    .build_int_compare(IntPredicate::SLT, v, zeros, ""));
+                let res = err!(self.builder.build_bit_cast(res, self.intrinsics.i4_ty, ""))
                     .into_int_value();
-                let res = self
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(res, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(res, self.intrinsics.i32_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64x2Bitmask => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i64x2(v, i);
+                let (v, _) = self.v128_into_i64x2(v, i)?;
 
                 let zeros = self.intrinsics.i64x2_ty.const_zero();
-                let res = self
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SLT, v, zeros, "");
-                let res = self
-                    .builder
-                    .build_bitcast(res, self.intrinsics.i2_ty, "")
+                    .build_int_compare(IntPredicate::SLT, v, zeros, ""));
+                let res = err!(self.builder.build_bit_cast(res, self.intrinsics.i2_ty, ""))
                     .into_int_value();
-                let res = self
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(res, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(res, self.intrinsics.i32_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32Shl => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
                 let mask = self.intrinsics.i32_ty.const_int(31u64, false);
-                let v2 = self.builder.build_and(v2, mask, "");
-                let res = self.builder.build_left_shift(v1, v2, "");
+                let v2 = err!(self.builder.build_and(v2, mask, ""));
+                let res = err!(self.builder.build_left_shift(v1, v2, ""));
                 self.state.push1(res);
             }
             Operator::I64Shl => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
                 let mask = self.intrinsics.i64_ty.const_int(63u64, false);
-                let v2 = self.builder.build_and(v2, mask, "");
-                let res = self.builder.build_left_shift(v1, v2, "");
+                let v2 = err!(self.builder.build_and(v2, mask, ""));
+                let res = err!(self.builder.build_left_shift(v1, v2, ""));
                 self.state.push1(res);
             }
             Operator::I8x16Shl => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let v2 = v2.into_int_value();
-                let v2 = self
+                let v2 = err!(self
+                    .builder
+                    .build_and(v2, self.intrinsics.i32_consts[7], ""));
+                let v2 = err!(self
                     .builder
-                    .build_and(v2, self.intrinsics.i32_consts[7], "");
-                let v2 = self
+                    .build_int_truncate(v2, self.intrinsics.i8_ty, ""));
+                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i8x16_ty)?;
+                let res = err!(self.builder.build_left_shift(v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_truncate(v2, self.intrinsics.i8_ty, "");
-                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i8x16_ty);
-                let res = self.builder.build_left_shift(v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8Shl => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let v2 = v2.into_int_value();
-                let v2 = self
+                let v2 = err!(self
                     .builder
-                    .build_and(v2, self.intrinsics.i32_consts[15], "");
-                let v2 = self
+                    .build_and(v2, self.intrinsics.i32_consts[15], ""));
+                let v2 = err!(self
                     .builder
-                    .build_int_truncate(v2, self.intrinsics.i16_ty, "");
-                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i16x8_ty);
-                let res = self.builder.build_left_shift(v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_truncate(v2, self.intrinsics.i16_ty, ""));
+                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i16x8_ty)?;
+                let res = err!(self.builder.build_left_shift(v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4Shl => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let v2 = v2.into_int_value();
-                let v2 =
-                    self.builder
-                        .build_and(v2, self.intrinsics.i32_ty.const_int(31, false), "");
-                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i32x4_ty);
-                let res = self.builder.build_left_shift(v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let v2 = err!(self.builder.build_and(
+                    v2,
+                    self.intrinsics.i32_ty.const_int(31, false),
+                    ""
+                ));
+                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i32x4_ty)?;
+                let res = err!(self.builder.build_left_shift(v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64x2Shl => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i64x2(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let (v1, _) = self.v128_into_i64x2(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let v2 = v2.into_int_value();
-                let v2 =
-                    self.builder
-                        .build_and(v2, self.intrinsics.i32_ty.const_int(63, false), "");
-                let v2 = self
+                let v2 = err!(self.builder.build_and(
+                    v2,
+                    self.intrinsics.i32_ty.const_int(63, false),
+                    ""
+                ));
+                let v2 = err!(self
                     .builder
-                    .build_int_z_extend(v2, self.intrinsics.i64_ty, "");
-                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i64x2_ty);
-                let res = self.builder.build_left_shift(v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_z_extend(v2, self.intrinsics.i64_ty, ""));
+                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i64x2_ty)?;
+                let res = err!(self.builder.build_left_shift(v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32ShrS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
                 let mask = self.intrinsics.i32_ty.const_int(31u64, false);
-                let v2 = self.builder.build_and(v2, mask, "");
-                let res = self.builder.build_right_shift(v1, v2, true, "");
+                let v2 = err!(self.builder.build_and(v2, mask, ""));
+                let res = err!(self.builder.build_right_shift(v1, v2, true, ""));
                 self.state.push1(res);
             }
             Operator::I64ShrS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
                 let mask = self.intrinsics.i64_ty.const_int(63u64, false);
-                let v2 = self.builder.build_and(v2, mask, "");
-                let res = self.builder.build_right_shift(v1, v2, true, "");
+                let v2 = err!(self.builder.build_and(v2, mask, ""));
+                let res = err!(self.builder.build_right_shift(v1, v2, true, ""));
                 self.state.push1(res);
             }
             Operator::I8x16ShrS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let v2 = v2.into_int_value();
-                let v2 = self
+                let v2 = err!(self
+                    .builder
+                    .build_and(v2, self.intrinsics.i32_consts[7], ""));
+                let v2 = err!(self
                     .builder
-                    .build_and(v2, self.intrinsics.i32_consts[7], "");
-                let v2 = self
+                    .build_int_truncate(v2, self.intrinsics.i8_ty, ""));
+                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i8x16_ty)?;
+                let res = err!(self.builder.build_right_shift(v1, v2, true, ""));
+                let res = err!(self
                     .builder
-                    .build_int_truncate(v2, self.intrinsics.i8_ty, "");
-                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i8x16_ty);
-                let res = self.builder.build_right_shift(v1, v2, true, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8ShrS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let v2 = v2.into_int_value();
-                let v2 = self
+                let v2 = err!(self
                     .builder
-                    .build_and(v2, self.intrinsics.i32_consts[15], "");
-                let v2 = self
+                    .build_and(v2, self.intrinsics.i32_consts[15], ""));
+                let v2 = err!(self
                     .builder
-                    .build_int_truncate(v2, self.intrinsics.i16_ty, "");
-                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i16x8_ty);
-                let res = self.builder.build_right_shift(v1, v2, true, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_truncate(v2, self.intrinsics.i16_ty, ""));
+                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i16x8_ty)?;
+                let res = err!(self.builder.build_right_shift(v1, v2, true, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4ShrS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let v2 = v2.into_int_value();
-                let v2 =
-                    self.builder
-                        .build_and(v2, self.intrinsics.i32_ty.const_int(31, false), "");
-                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i32x4_ty);
-                let res = self.builder.build_right_shift(v1, v2, true, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let v2 = err!(self.builder.build_and(
+                    v2,
+                    self.intrinsics.i32_ty.const_int(31, false),
+                    ""
+                ));
+                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i32x4_ty)?;
+                let res = err!(self.builder.build_right_shift(v1, v2, true, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64x2ShrS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i64x2(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let (v1, _) = self.v128_into_i64x2(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let v2 = v2.into_int_value();
-                let v2 =
-                    self.builder
-                        .build_and(v2, self.intrinsics.i32_ty.const_int(63, false), "");
-                let v2 = self
+                let v2 = err!(self.builder.build_and(
+                    v2,
+                    self.intrinsics.i32_ty.const_int(63, false),
+                    ""
+                ));
+                let v2 = err!(self
                     .builder
-                    .build_int_z_extend(v2, self.intrinsics.i64_ty, "");
-                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i64x2_ty);
-                let res = self.builder.build_right_shift(v1, v2, true, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_z_extend(v2, self.intrinsics.i64_ty, ""));
+                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i64x2_ty)?;
+                let res = err!(self.builder.build_right_shift(v1, v2, true, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32ShrU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
                 let mask = self.intrinsics.i32_ty.const_int(31u64, false);
-                let v2 = self.builder.build_and(v2, mask, "");
-                let res = self.builder.build_right_shift(v1, v2, false, "");
+                let v2 = err!(self.builder.build_and(v2, mask, ""));
+                let res = err!(self.builder.build_right_shift(v1, v2, false, ""));
                 self.state.push1(res);
             }
             Operator::I64ShrU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
                 let mask = self.intrinsics.i64_ty.const_int(63u64, false);
-                let v2 = self.builder.build_and(v2, mask, "");
-                let res = self.builder.build_right_shift(v1, v2, false, "");
+                let v2 = err!(self.builder.build_and(v2, mask, ""));
+                let res = err!(self.builder.build_right_shift(v1, v2, false, ""));
                 self.state.push1(res);
             }
             Operator::I8x16ShrU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let v2 = v2.into_int_value();
-                let v2 = self
+                let v2 = err!(self
+                    .builder
+                    .build_and(v2, self.intrinsics.i32_consts[7], ""));
+                let v2 = err!(self
                     .builder
-                    .build_and(v2, self.intrinsics.i32_consts[7], "");
-                let v2 = self
+                    .build_int_truncate(v2, self.intrinsics.i8_ty, ""));
+                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i8x16_ty)?;
+                let res = err!(self.builder.build_right_shift(v1, v2, false, ""));
+                let res = err!(self
                     .builder
-                    .build_int_truncate(v2, self.intrinsics.i8_ty, "");
-                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i8x16_ty);
-                let res = self.builder.build_right_shift(v1, v2, false, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8ShrU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let v2 = v2.into_int_value();
-                let v2 = self
+                let v2 = err!(self
                     .builder
-                    .build_and(v2, self.intrinsics.i32_consts[15], "");
-                let v2 = self
+                    .build_and(v2, self.intrinsics.i32_consts[15], ""));
+                let v2 = err!(self
                     .builder
-                    .build_int_truncate(v2, self.intrinsics.i16_ty, "");
-                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i16x8_ty);
-                let res = self.builder.build_right_shift(v1, v2, false, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_truncate(v2, self.intrinsics.i16_ty, ""));
+                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i16x8_ty)?;
+                let res = err!(self.builder.build_right_shift(v1, v2, false, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4ShrU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let v2 = v2.into_int_value();
-                let v2 =
-                    self.builder
-                        .build_and(v2, self.intrinsics.i32_ty.const_int(31, false), "");
-                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i32x4_ty);
-                let res = self.builder.build_right_shift(v1, v2, false, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let v2 = err!(self.builder.build_and(
+                    v2,
+                    self.intrinsics.i32_ty.const_int(31, false),
+                    ""
+                ));
+                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i32x4_ty)?;
+                let res = err!(self.builder.build_right_shift(v1, v2, false, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64x2ShrU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i64x2(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let (v1, _) = self.v128_into_i64x2(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let v2 = v2.into_int_value();
-                let v2 =
-                    self.builder
-                        .build_and(v2, self.intrinsics.i32_ty.const_int(63, false), "");
-                let v2 = self
+                let v2 = err!(self.builder.build_and(
+                    v2,
+                    self.intrinsics.i32_ty.const_int(63, false),
+                    ""
+                ));
+                let v2 = err!(self
                     .builder
-                    .build_int_z_extend(v2, self.intrinsics.i64_ty, "");
-                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i64x2_ty);
-                let res = self.builder.build_right_shift(v1, v2, false, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_z_extend(v2, self.intrinsics.i64_ty, ""));
+                let v2 = self.splat_vector(v2.as_basic_value_enum(), self.intrinsics.i64x2_ty)?;
+                let res = err!(self.builder.build_right_shift(v1, v2, false, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32Rotl => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
                 let mask = self.intrinsics.i32_ty.const_int(31u64, false);
-                let v2 = self.builder.build_and(v2, mask, "");
-                let lhs = self.builder.build_left_shift(v1, v2, "");
+                let v2 = err!(self.builder.build_and(v2, mask, ""));
+                let lhs = err!(self.builder.build_left_shift(v1, v2, ""));
                 let rhs = {
-                    let negv2 = self.builder.build_int_neg(v2, "");
-                    let rhs = self.builder.build_and(negv2, mask, "");
-                    self.builder.build_right_shift(v1, rhs, false, "")
+                    let negv2 = err!(self.builder.build_int_neg(v2, ""));
+                    let rhs = err!(self.builder.build_and(negv2, mask, ""));
+                    err!(self.builder.build_right_shift(v1, rhs, false, ""))
                 };
-                let res = self.builder.build_or(lhs, rhs, "");
+                let res = err!(self.builder.build_or(lhs, rhs, ""));
                 self.state.push1(res);
             }
             Operator::I64Rotl => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
                 let mask = self.intrinsics.i64_ty.const_int(63u64, false);
-                let v2 = self.builder.build_and(v2, mask, "");
-                let lhs = self.builder.build_left_shift(v1, v2, "");
+                let v2 = err!(self.builder.build_and(v2, mask, ""));
+                let lhs = err!(self.builder.build_left_shift(v1, v2, ""));
                 let rhs = {
-                    let negv2 = self.builder.build_int_neg(v2, "");
-                    let rhs = self.builder.build_and(negv2, mask, "");
-                    self.builder.build_right_shift(v1, rhs, false, "")
+                    let negv2 = err!(self.builder.build_int_neg(v2, ""));
+                    let rhs = err!(self.builder.build_and(negv2, mask, ""));
+                    err!(self.builder.build_right_shift(v1, rhs, false, ""))
                 };
-                let res = self.builder.build_or(lhs, rhs, "");
+                let res = err!(self.builder.build_or(lhs, rhs, ""));
                 self.state.push1(res);
             }
             Operator::I32Rotr => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
                 let mask = self.intrinsics.i32_ty.const_int(31u64, false);
-                let v2 = self.builder.build_and(v2, mask, "");
-                let lhs = self.builder.build_right_shift(v1, v2, false, "");
+                let v2 = err!(self.builder.build_and(v2, mask, ""));
+                let lhs = err!(self.builder.build_right_shift(v1, v2, false, ""));
                 let rhs = {
-                    let negv2 = self.builder.build_int_neg(v2, "");
-                    let rhs = self.builder.build_and(negv2, mask, "");
-                    self.builder.build_left_shift(v1, rhs, "")
+                    let negv2 = err!(self.builder.build_int_neg(v2, ""));
+                    let rhs = err!(self.builder.build_and(negv2, mask, ""));
+                    err!(self.builder.build_left_shift(v1, rhs, ""))
                 };
-                let res = self.builder.build_or(lhs, rhs, "");
+                let res = err!(self.builder.build_or(lhs, rhs, ""));
                 self.state.push1(res);
             }
             Operator::I64Rotr => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
                 let mask = self.intrinsics.i64_ty.const_int(63u64, false);
-                let v2 = self.builder.build_and(v2, mask, "");
-                let lhs = self.builder.build_right_shift(v1, v2, false, "");
+                let v2 = err!(self.builder.build_and(v2, mask, ""));
+                let lhs = err!(self.builder.build_right_shift(v1, v2, false, ""));
                 let rhs = {
-                    let negv2 = self.builder.build_int_neg(v2, "");
-                    let rhs = self.builder.build_and(negv2, mask, "");
-                    self.builder.build_left_shift(v1, rhs, "")
+                    let negv2 = err!(self.builder.build_int_neg(v2, ""));
+                    let rhs = err!(self.builder.build_and(negv2, mask, ""));
+                    err!(self.builder.build_left_shift(v1, rhs, ""))
                 };
-                let res = self.builder.build_or(lhs, rhs, "");
+                let res = err!(self.builder.build_or(lhs, rhs, ""));
                 self.state.push1(res);
             }
             Operator::I32Clz => {
                 let (input, info) = self.state.pop1_extra()?;
-                let input = self.apply_pending_canonicalization(input, info);
+                let input = self.apply_pending_canonicalization(input, info)?;
                 let is_zero_undef = self.intrinsics.i1_zero;
-                let res = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.ctlz_i32,
-                        &[input.into(), is_zero_undef.into()],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.ctlz_i32,
+                    &[input.into(), is_zero_undef.into()],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 self.state.push1_extra(res, ExtraInfo::arithmetic_f32());
             }
             Operator::I64Clz => {
                 let (input, info) = self.state.pop1_extra()?;
-                let input = self.apply_pending_canonicalization(input, info);
+                let input = self.apply_pending_canonicalization(input, info)?;
                 let is_zero_undef = self.intrinsics.i1_zero;
-                let res = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.ctlz_i64,
-                        &[input.into(), is_zero_undef.into()],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.ctlz_i64,
+                    &[input.into(), is_zero_undef.into()],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 self.state.push1_extra(res, ExtraInfo::arithmetic_f64());
             }
             Operator::I32Ctz => {
                 let (input, info) = self.state.pop1_extra()?;
-                let input = self.apply_pending_canonicalization(input, info);
+                let input = self.apply_pending_canonicalization(input, info)?;
                 let is_zero_undef = self.intrinsics.i1_zero;
-                let res = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cttz_i32,
-                        &[input.into(), is_zero_undef.into()],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.cttz_i32,
+                    &[input.into(), is_zero_undef.into()],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 self.state.push1_extra(res, ExtraInfo::arithmetic_f32());
             }
             Operator::I64Ctz => {
                 let (input, info) = self.state.pop1_extra()?;
-                let input = self.apply_pending_canonicalization(input, info);
+                let input = self.apply_pending_canonicalization(input, info)?;
                 let is_zero_undef = self.intrinsics.i1_zero;
-                let res = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cttz_i64,
-                        &[input.into(), is_zero_undef.into()],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.cttz_i64,
+                    &[input.into(), is_zero_undef.into()],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 self.state.push1_extra(res, ExtraInfo::arithmetic_f64());
             }
             Operator::I8x16Popcnt => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i8x16(v, i);
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.ctpop_i8x16, &[v.into()], "")
+                let (v, _) = self.v128_into_i8x16(v, i)?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.ctpop_i8x16, &[v.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32Popcnt => {
                 let (input, info) = self.state.pop1_extra()?;
-                let input = self.apply_pending_canonicalization(input, info);
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.ctpop_i32, &[input.into()], "")
+                let input = self.apply_pending_canonicalization(input, info)?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.ctpop_i32, &[input.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
@@ -3765,10 +3954,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::I64Popcnt => {
                 let (input, info) = self.state.pop1_extra()?;
-                let input = self.apply_pending_canonicalization(input, info);
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.ctpop_i64, &[input.into()], "")
+                let input = self.apply_pending_canonicalization(input, info)?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.ctpop_i64, &[input.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
@@ -3776,214 +3966,246 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::I32Eqz => {
                 let input = self.state.pop1()?.into_int_value();
-                let cond = self.builder.build_int_compare(
+                let cond = err!(self.builder.build_int_compare(
                     IntPredicate::EQ,
                     input,
                     self.intrinsics.i32_zero,
                     "",
-                );
-                let res = self
+                ));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(cond, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(cond, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(res, ExtraInfo::arithmetic_f32());
             }
             Operator::I64Eqz => {
                 let input = self.state.pop1()?.into_int_value();
-                let cond = self.builder.build_int_compare(
+                let cond = err!(self.builder.build_int_compare(
                     IntPredicate::EQ,
                     input,
                     self.intrinsics.i64_zero,
                     "",
-                );
-                let res = self
+                ));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(cond, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(cond, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(res, ExtraInfo::arithmetic_f64());
             }
             Operator::I8x16Abs => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i8x16(v, i);
+                let (v, _) = self.v128_into_i8x16(v, i)?;
 
                 let seven = self.intrinsics.i8_ty.const_int(7, false);
                 let seven = VectorType::const_vector(&[seven; 16]);
-                let all_sign_bits = self.builder.build_right_shift(v, seven, true, "");
-                let xor = self.builder.build_xor(v, all_sign_bits, "");
-                let res = self.builder.build_int_sub(xor, all_sign_bits, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let all_sign_bits = err!(self.builder.build_right_shift(v, seven, true, ""));
+                let xor = err!(self.builder.build_xor(v, all_sign_bits, ""));
+                let res = err!(self.builder.build_int_sub(xor, all_sign_bits, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8Abs => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i16x8(v, i);
+                let (v, _) = self.v128_into_i16x8(v, i)?;
 
                 let fifteen = self.intrinsics.i16_ty.const_int(15, false);
                 let fifteen = VectorType::const_vector(&[fifteen; 8]);
-                let all_sign_bits = self.builder.build_right_shift(v, fifteen, true, "");
-                let xor = self.builder.build_xor(v, all_sign_bits, "");
-                let res = self.builder.build_int_sub(xor, all_sign_bits, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let all_sign_bits = err!(self.builder.build_right_shift(v, fifteen, true, ""));
+                let xor = err!(self.builder.build_xor(v, all_sign_bits, ""));
+                let res = err!(self.builder.build_int_sub(xor, all_sign_bits, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4Abs => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i32x4(v, i);
+                let (v, _) = self.v128_into_i32x4(v, i)?;
 
                 let thirtyone = self.intrinsics.i32_ty.const_int(31, false);
                 let thirtyone = VectorType::const_vector(&[thirtyone; 4]);
-                let all_sign_bits = self.builder.build_right_shift(v, thirtyone, true, "");
-                let xor = self.builder.build_xor(v, all_sign_bits, "");
-                let res = self.builder.build_int_sub(xor, all_sign_bits, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let all_sign_bits = err!(self.builder.build_right_shift(v, thirtyone, true, ""));
+                let xor = err!(self.builder.build_xor(v, all_sign_bits, ""));
+                let res = err!(self.builder.build_int_sub(xor, all_sign_bits, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64x2Abs => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i64x2(v, i);
+                let (v, _) = self.v128_into_i64x2(v, i)?;
 
                 let sixtythree = self.intrinsics.i64_ty.const_int(63, false);
                 let sixtythree = VectorType::const_vector(&[sixtythree; 2]);
-                let all_sign_bits = self.builder.build_right_shift(v, sixtythree, true, "");
-                let xor = self.builder.build_xor(v, all_sign_bits, "");
-                let res = self.builder.build_int_sub(xor, all_sign_bits, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let all_sign_bits = err!(self.builder.build_right_shift(v, sixtythree, true, ""));
+                let xor = err!(self.builder.build_xor(v, all_sign_bits, ""));
+                let res = err!(self.builder.build_int_sub(xor, all_sign_bits, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I8x16MinS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let cmp = self
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let cmp = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::SLT, v1, v2, ""));
+                let res = err!(self.builder.build_select(cmp, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SLT, v1, v2, "");
-                let res = self.builder.build_select(cmp, v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I8x16MinU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let cmp = self
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let cmp = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::ULT, v1, v2, "");
-                let res = self.builder.build_select(cmp, v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_compare(IntPredicate::ULT, v1, v2, ""));
+                let res = err!(self.builder.build_select(cmp, v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I8x16MaxS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let cmp = self
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let cmp = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::SGT, v1, v2, ""));
+                let res = err!(self.builder.build_select(cmp, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SGT, v1, v2, "");
-                let res = self.builder.build_select(cmp, v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I8x16MaxU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let cmp = self
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let cmp = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::UGT, v1, v2, "");
-                let res = self.builder.build_select(cmp, v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_compare(IntPredicate::UGT, v1, v2, ""));
+                let res = err!(self.builder.build_select(cmp, v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8MinS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let cmp = self
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let cmp = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::SLT, v1, v2, ""));
+                let res = err!(self.builder.build_select(cmp, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SLT, v1, v2, "");
-                let res = self.builder.build_select(cmp, v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8MinU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let cmp = self
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let cmp = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::ULT, v1, v2, "");
-                let res = self.builder.build_select(cmp, v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_compare(IntPredicate::ULT, v1, v2, ""));
+                let res = err!(self.builder.build_select(cmp, v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8MaxS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let cmp = self
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let cmp = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::SGT, v1, v2, ""));
+                let res = err!(self.builder.build_select(cmp, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SGT, v1, v2, "");
-                let res = self.builder.build_select(cmp, v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8MaxU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let cmp = self
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let cmp = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::UGT, v1, v2, "");
-                let res = self.builder.build_select(cmp, v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_compare(IntPredicate::UGT, v1, v2, ""));
+                let res = err!(self.builder.build_select(cmp, v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4MinS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
-                let cmp = self
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
+                let cmp = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::SLT, v1, v2, ""));
+                let res = err!(self.builder.build_select(cmp, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SLT, v1, v2, "");
-                let res = self.builder.build_select(cmp, v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4MinU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
-                let cmp = self
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
+                let cmp = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::ULT, v1, v2, "");
-                let res = self.builder.build_select(cmp, v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_compare(IntPredicate::ULT, v1, v2, ""));
+                let res = err!(self.builder.build_select(cmp, v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4MaxS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
-                let cmp = self
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
+                let cmp = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::SGT, v1, v2, ""));
+                let res = err!(self.builder.build_select(cmp, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SGT, v1, v2, "");
-                let res = self.builder.build_select(cmp, v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4MaxU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
-                let cmp = self
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
+                let cmp = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::UGT, v1, v2, "");
-                let res = self.builder.build_select(cmp, v1, v2, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_compare(IntPredicate::UGT, v1, v2, ""));
+                let res = err!(self.builder.build_select(cmp, v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I8x16AvgrU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
 
                 // This approach is faster on x86-64 when the PAVG[BW]
                 // instructions are available. On other platforms, an alternative
@@ -3999,22 +4221,26 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let one = self.intrinsics.i16_ty.const_int(1, false);
                 let one = VectorType::const_vector(&[one; 16]);
 
-                let v1 = self.builder.build_int_z_extend(v1, ext_ty, "");
-                let v2 = self.builder.build_int_z_extend(v2, ext_ty, "");
-                let res =
-                    self.builder
-                        .build_int_add(self.builder.build_int_add(one, v1, ""), v2, "");
-                let res = self.builder.build_right_shift(res, one, false, "");
-                let res = self
+                let v1 = err!(self.builder.build_int_z_extend(v1, ext_ty, ""));
+                let v2 = err!(self.builder.build_int_z_extend(v2, ext_ty, ""));
+                let res = err!(self.builder.build_int_add(
+                    err!(self.builder.build_int_add(one, v1, "")),
+                    v2,
+                    ""
+                ));
+                let res = err!(self.builder.build_right_shift(res, one, false, ""));
+                let res = err!(self
+                    .builder
+                    .build_int_truncate(res, self.intrinsics.i8x16_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_truncate(res, self.intrinsics.i8x16_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8AvgrU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
 
                 // This approach is faster on x86-64 when the PAVG[BW]
                 // instructions are available. On other platforms, an alternative
@@ -4030,16 +4256,20 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let one = self.intrinsics.i32_consts[1];
                 let one = VectorType::const_vector(&[one; 8]);
 
-                let v1 = self.builder.build_int_z_extend(v1, ext_ty, "");
-                let v2 = self.builder.build_int_z_extend(v2, ext_ty, "");
-                let res =
-                    self.builder
-                        .build_int_add(self.builder.build_int_add(one, v1, ""), v2, "");
-                let res = self.builder.build_right_shift(res, one, false, "");
-                let res = self
+                let v1 = err!(self.builder.build_int_z_extend(v1, ext_ty, ""));
+                let v2 = err!(self.builder.build_int_z_extend(v2, ext_ty, ""));
+                let res = err!(self.builder.build_int_add(
+                    err!(self.builder.build_int_add(one, v1, "")),
+                    v2,
+                    ""
+                ));
+                let res = err!(self.builder.build_right_shift(res, one, false, ""));
+                let res = err!(self
                     .builder
-                    .build_int_truncate(res, self.intrinsics.i16x8_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_truncate(res, self.intrinsics.i16x8_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
 
@@ -4049,21 +4279,19 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
              ***************************/
             Operator::F32Add => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let res = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.add_f32,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_rounding_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.add_f32,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_rounding_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 self.state.push1_extra(
                     res,
                     (i1.strip_pending() & i2.strip_pending()) | ExtraInfo::pending_f32_nan(),
@@ -4072,21 +4300,19 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             Operator::F64Add => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
                 let (v1, v2) = (v1.into_float_value(), v2.into_float_value());
-                let res = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.add_f64,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_rounding_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.add_f64,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_rounding_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 self.state.push1_extra(
                     res,
                     (i1.strip_pending() & i2.strip_pending()) | ExtraInfo::pending_f64_nan(),
@@ -4094,24 +4320,24 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F32x4Add => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, i1) = self.v128_into_f32x4(v1, i1);
-                let (v2, i2) = self.v128_into_f32x4(v2, i2);
-                let res = self
+                let (v1, i1) = self.v128_into_f32x4(v1, i1)?;
+                let (v2, i2) = self.v128_into_f32x4(v2, i2)?;
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.add_f32x4,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_rounding_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
+                let res = err!(self
                     .builder
-                    .build_call(
-                        self.intrinsics.add_f32x4,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_rounding_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1_extra(
                     res,
                     (i1.strip_pending() & i2.strip_pending()) | ExtraInfo::pending_f32_nan(),
@@ -4119,24 +4345,24 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F64x2Add => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, i1) = self.v128_into_f64x2(v1, i1);
-                let (v2, i2) = self.v128_into_f64x2(v2, i2);
-                let res = self
+                let (v1, i1) = self.v128_into_f64x2(v1, i1)?;
+                let (v2, i2) = self.v128_into_f64x2(v2, i2)?;
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.add_f64x2,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_rounding_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
+                let res = err!(self
                     .builder
-                    .build_call(
-                        self.intrinsics.add_f64x2,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_rounding_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1_extra(
                     res,
                     (i1.strip_pending() & i2.strip_pending()) | ExtraInfo::pending_f64_nan(),
@@ -4145,44 +4371,40 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             Operator::F32Sub => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
                 let (v1, v2) = (v1.into_float_value(), v2.into_float_value());
-                let res = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.sub_f32,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_rounding_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
-                self.state.push1_extra(
-                    res,
-                    (i1.strip_pending() & i2.strip_pending()) | ExtraInfo::pending_f32_nan(),
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.sub_f32,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_rounding_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
+                self.state.push1_extra(
+                    res,
+                    (i1.strip_pending() & i2.strip_pending()) | ExtraInfo::pending_f32_nan(),
                 );
             }
             Operator::F64Sub => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
                 let (v1, v2) = (v1.into_float_value(), v2.into_float_value());
-                let res = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.sub_f64,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_rounding_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.sub_f64,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_rounding_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 self.state.push1_extra(
                     res,
                     (i1.strip_pending() & i2.strip_pending()) | ExtraInfo::pending_f64_nan(),
@@ -4190,24 +4412,24 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F32x4Sub => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, i1) = self.v128_into_f32x4(v1, i1);
-                let (v2, i2) = self.v128_into_f32x4(v2, i2);
-                let res = self
+                let (v1, i1) = self.v128_into_f32x4(v1, i1)?;
+                let (v2, i2) = self.v128_into_f32x4(v2, i2)?;
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.sub_f32x4,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_rounding_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
+                let res = err!(self
                     .builder
-                    .build_call(
-                        self.intrinsics.sub_f32x4,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_rounding_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1_extra(
                     res,
                     (i1.strip_pending() & i2.strip_pending()) | ExtraInfo::pending_f32_nan(),
@@ -4215,24 +4437,24 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F64x2Sub => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, i1) = self.v128_into_f64x2(v1, i1);
-                let (v2, i2) = self.v128_into_f64x2(v2, i2);
-                let res = self
+                let (v1, i1) = self.v128_into_f64x2(v1, i1)?;
+                let (v2, i2) = self.v128_into_f64x2(v2, i2)?;
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.sub_f64x2,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_rounding_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
+                let res = err!(self
                     .builder
-                    .build_call(
-                        self.intrinsics.sub_f64x2,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_rounding_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1_extra(
                     res,
                     (i1.strip_pending() & i2.strip_pending()) | ExtraInfo::pending_f64_nan(),
@@ -4241,21 +4463,19 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             Operator::F32Mul => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
                 let (v1, v2) = (v1.into_float_value(), v2.into_float_value());
-                let res = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.mul_f32,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_rounding_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.mul_f32,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_rounding_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 self.state.push1_extra(
                     res,
                     (i1.strip_pending() & i2.strip_pending()) | ExtraInfo::pending_f32_nan(),
@@ -4264,21 +4484,19 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             Operator::F64Mul => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
                 let (v1, v2) = (v1.into_float_value(), v2.into_float_value());
-                let res = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.mul_f64,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_rounding_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.mul_f64,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_rounding_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 self.state.push1_extra(
                     res,
                     (i1.strip_pending() & i2.strip_pending()) | ExtraInfo::pending_f64_nan(),
@@ -4286,24 +4504,24 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F32x4Mul => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, i1) = self.v128_into_f32x4(v1, i1);
-                let (v2, i2) = self.v128_into_f32x4(v2, i2);
-                let res = self
+                let (v1, i1) = self.v128_into_f32x4(v1, i1)?;
+                let (v2, i2) = self.v128_into_f32x4(v2, i2)?;
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.mul_f32x4,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_rounding_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
+                let res = err!(self
                     .builder
-                    .build_call(
-                        self.intrinsics.mul_f32x4,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_rounding_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1_extra(
                     res,
                     (i1.strip_pending() & i2.strip_pending()) | ExtraInfo::pending_f32_nan(),
@@ -4311,24 +4529,24 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F64x2Mul => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, i1) = self.v128_into_f64x2(v1, i1);
-                let (v2, i2) = self.v128_into_f64x2(v2, i2);
-                let res = self
+                let (v1, i1) = self.v128_into_f64x2(v1, i1)?;
+                let (v2, i2) = self.v128_into_f64x2(v2, i2)?;
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.mul_f64x2,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_rounding_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
+                let res = err!(self
                     .builder
-                    .build_call(
-                        self.intrinsics.mul_f64x2,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_rounding_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1_extra(
                     res,
                     (i1.strip_pending() & i2.strip_pending()) | ExtraInfo::pending_f64_nan(),
@@ -4337,92 +4555,89 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             Operator::F32Div => {
                 let (v1, v2) = self.state.pop2()?;
                 let (v1, v2) = (v1.into_float_value(), v2.into_float_value());
-                let res = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.div_f32,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_rounding_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.div_f32,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_rounding_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 self.state.push1_extra(res, ExtraInfo::pending_f32_nan());
             }
             Operator::F64Div => {
                 let (v1, v2) = self.state.pop2()?;
                 let (v1, v2) = (v1.into_float_value(), v2.into_float_value());
-                let res = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.div_f64,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_rounding_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.div_f64,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_rounding_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 self.state.push1_extra(res, ExtraInfo::pending_f64_nan());
             }
             Operator::F32x4Div => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_f32x4(v1, i1);
-                let (v2, _) = self.v128_into_f32x4(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_f32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_f32x4(v2, i2)?;
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.div_f32x4,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_rounding_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
+                let res = err!(self
                     .builder
-                    .build_call(
-                        self.intrinsics.div_f32x4,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_rounding_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1_extra(res, ExtraInfo::pending_f32_nan());
             }
             Operator::F64x2Div => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_f64x2(v1, i1);
-                let (v2, _) = self.v128_into_f64x2(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_f64x2(v1, i1)?;
+                let (v2, _) = self.v128_into_f64x2(v2, i2)?;
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.div_f64x2,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_rounding_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
+                let res = err!(self
                     .builder
-                    .build_call(
-                        self.intrinsics.div_f64x2,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_rounding_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1_extra(res, ExtraInfo::pending_f64_nan());
             }
             Operator::F32Sqrt => {
                 let input = self.state.pop1()?;
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.sqrt_f32, &[input.into()], "")
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.sqrt_f32, &[input.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
@@ -4430,9 +4645,10 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F64Sqrt => {
                 let input = self.state.pop1()?;
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.sqrt_f64, &[input.into()], "")
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.sqrt_f64, &[input.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
@@ -4440,30 +4656,32 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F32x4Sqrt => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_f32x4(v, i);
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.sqrt_f32x4, &[v.into()], "")
+                let (v, _) = self.v128_into_f32x4(v, i)?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.sqrt_f32x4, &[v.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
-                let bits = self
+                let bits = err!(self
                     .builder
-                    .build_bitcast(res, self.intrinsics.i128_ty, "bits");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, "bits"));
                 self.state.push1_extra(bits, ExtraInfo::pending_f32_nan());
             }
             Operator::F64x2Sqrt => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_f64x2(v, i);
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.sqrt_f64x2, &[v.into()], "")
+                let (v, _) = self.v128_into_f64x2(v, i)?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.sqrt_f64x2, &[v.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
-                let bits = self
+                let bits = err!(self
                     .builder
-                    .build_bitcast(res, self.intrinsics.i128_ty, "bits");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, "bits"));
                 self.state.push1(bits);
             }
             Operator::F32Min => {
@@ -4471,107 +4689,105 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 // intrinsic would, but x86 lowering of that intrinsic
                 // encounters a fatal error in LLVM 11.
                 let (v1, v2) = self.state.pop2()?;
-                let v1 = self.canonicalize_nans(v1);
-                let v2 = self.canonicalize_nans(v2);
+                let v1 = self.canonicalize_nans(v1)?;
+                let v2 = self.canonicalize_nans(v2)?;
 
-                let v1_is_nan = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f32,
-                        &[
-                            v1.into(),
-                            self.intrinsics.f32_zero.into(),
-                            self.intrinsics.fp_uno_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_int_value();
-                let v2_is_nan = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f32,
-                        &[
-                            v2.into(),
-                            self.intrinsics.f32_zero.into(),
-                            self.intrinsics.fp_uno_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_int_value();
-                let v1_lt_v2 = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f32,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_olt_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_int_value();
-                let v1_gt_v2 = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f32,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_ogt_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_int_value();
+                let v1_is_nan = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f32,
+                    &[
+                        v1.into(),
+                        self.intrinsics.f32_zero.into(),
+                        self.intrinsics.fp_uno_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_int_value();
+                let v2_is_nan = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f32,
+                    &[
+                        v2.into(),
+                        self.intrinsics.f32_zero.into(),
+                        self.intrinsics.fp_uno_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_int_value();
+                let v1_lt_v2 = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f32,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_olt_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_int_value();
+                let v1_gt_v2 = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f32,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_ogt_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_int_value();
 
-                let res = self.builder.build_select(
+                let res = err!(self.builder.build_select(
                     v1_is_nan,
-                    self.quiet_nan(v1),
-                    self.builder.build_select(
+                    self.quiet_nan(v1)?,
+                    err!(self.builder.build_select(
                         v2_is_nan,
-                        self.quiet_nan(v2),
-                        self.builder.build_select(
+                        self.quiet_nan(v2)?,
+                        err!(self.builder.build_select(
                             v1_lt_v2,
                             v1,
-                            self.builder.build_select(
+                            err!(self.builder.build_select(
                                 v1_gt_v2,
                                 v2,
-                                self.builder.build_bitcast(
-                                    self.builder.build_or(
-                                        self.builder
-                                            .build_bitcast(v1, self.intrinsics.i32_ty, "")
-                                            .into_int_value(),
-                                        self.builder
-                                            .build_bitcast(v2, self.intrinsics.i32_ty, "")
-                                            .into_int_value(),
+                                err!(self.builder.build_bit_cast(
+                                    err!(self.builder.build_or(
+                                        err!(self.builder.build_bit_cast(
+                                            v1,
+                                            self.intrinsics.i32_ty,
+                                            ""
+                                        ))
+                                        .into_int_value(),
+                                        err!(self.builder.build_bit_cast(
+                                            v2,
+                                            self.intrinsics.i32_ty,
+                                            ""
+                                        ))
+                                        .into_int_value(),
                                         "",
-                                    ),
+                                    )),
                                     self.intrinsics.f32_ty,
                                     "",
-                                ),
+                                )),
                                 "",
-                            ),
+                            )),
                             "",
-                        ),
+                        )),
                         "",
-                    ),
+                    )),
                     "",
-                );
+                ));
 
                 self.state.push1(res);
             }
@@ -4580,107 +4796,105 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 // intrinsic would, but x86 lowering of that intrinsic
                 // encounters a fatal error in LLVM 11.
                 let (v1, v2) = self.state.pop2()?;
-                let v1 = self.canonicalize_nans(v1);
-                let v2 = self.canonicalize_nans(v2);
+                let v1 = self.canonicalize_nans(v1)?;
+                let v2 = self.canonicalize_nans(v2)?;
 
-                let v1_is_nan = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f64,
-                        &[
-                            v1.into(),
-                            self.intrinsics.f64_zero.into(),
-                            self.intrinsics.fp_uno_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_int_value();
-                let v2_is_nan = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f64,
-                        &[
-                            v2.into(),
-                            self.intrinsics.f64_zero.into(),
-                            self.intrinsics.fp_uno_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_int_value();
-                let v1_lt_v2 = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f64,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_olt_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_int_value();
-                let v1_gt_v2 = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f64,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_ogt_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_int_value();
+                let v1_is_nan = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f64,
+                    &[
+                        v1.into(),
+                        self.intrinsics.f64_zero.into(),
+                        self.intrinsics.fp_uno_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_int_value();
+                let v2_is_nan = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f64,
+                    &[
+                        v2.into(),
+                        self.intrinsics.f64_zero.into(),
+                        self.intrinsics.fp_uno_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_int_value();
+                let v1_lt_v2 = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f64,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_olt_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_int_value();
+                let v1_gt_v2 = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f64,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_ogt_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_int_value();
 
-                let res = self.builder.build_select(
+                let res = err!(self.builder.build_select(
                     v1_is_nan,
-                    self.quiet_nan(v1),
-                    self.builder.build_select(
+                    self.quiet_nan(v1)?,
+                    err!(self.builder.build_select(
                         v2_is_nan,
-                        self.quiet_nan(v2),
-                        self.builder.build_select(
+                        self.quiet_nan(v2)?,
+                        err!(self.builder.build_select(
                             v1_lt_v2,
                             v1,
-                            self.builder.build_select(
+                            err!(self.builder.build_select(
                                 v1_gt_v2,
                                 v2,
-                                self.builder.build_bitcast(
-                                    self.builder.build_or(
-                                        self.builder
-                                            .build_bitcast(v1, self.intrinsics.i64_ty, "")
-                                            .into_int_value(),
-                                        self.builder
-                                            .build_bitcast(v2, self.intrinsics.i64_ty, "")
-                                            .into_int_value(),
+                                err!(self.builder.build_bit_cast(
+                                    err!(self.builder.build_or(
+                                        err!(self.builder.build_bit_cast(
+                                            v1,
+                                            self.intrinsics.i64_ty,
+                                            ""
+                                        ))
+                                        .into_int_value(),
+                                        err!(self.builder.build_bit_cast(
+                                            v2,
+                                            self.intrinsics.i64_ty,
+                                            ""
+                                        ))
+                                        .into_int_value(),
                                         "",
-                                    ),
+                                    )),
                                     self.intrinsics.f64_ty,
                                     "",
-                                ),
+                                )),
                                 "",
-                            ),
+                            )),
                             "",
-                        ),
+                        )),
                         "",
-                    ),
+                    )),
                     "",
-                );
+                ));
 
                 self.state.push1(res);
             }
@@ -4689,125 +4903,125 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 // intrinsic would, but x86 lowering of that intrinsic
                 // encounters a fatal error in LLVM 11.
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_f32x4(v1, i1);
-                let (v2, _) = self.v128_into_f32x4(v2, i2);
+                let (v1, _) = self.v128_into_f32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_f32x4(v2, i2)?;
 
-                let v1_is_nan = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f32x4,
-                        &[
-                            v1.into(),
-                            self.intrinsics.f32x4_zero.into(),
-                            self.intrinsics.fp_uno_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_vector_value();
-                let v2_is_nan = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f32x4,
-                        &[
-                            v2.into(),
-                            self.intrinsics.f32x4_zero.into(),
-                            self.intrinsics.fp_uno_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_vector_value();
-                let v1_lt_v2 = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f32x4,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_olt_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_vector_value();
-                let v1_gt_v2 = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f32x4,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_ogt_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_vector_value();
+                let v1_is_nan = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f32x4,
+                    &[
+                        v1.into(),
+                        self.intrinsics.f32x4_zero.into(),
+                        self.intrinsics.fp_uno_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_vector_value();
+                let v2_is_nan = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f32x4,
+                    &[
+                        v2.into(),
+                        self.intrinsics.f32x4_zero.into(),
+                        self.intrinsics.fp_uno_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_vector_value();
+                let v1_lt_v2 = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f32x4,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_olt_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_vector_value();
+                let v1_gt_v2 = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f32x4,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_ogt_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_vector_value();
 
-                let res = self.builder.build_select(
+                let res = err!(self.builder.build_select(
                     v1_is_nan,
-                    self.quiet_nan(v1.into()).into_vector_value(),
-                    self.builder
-                        .build_select(
-                            v2_is_nan,
-                            self.quiet_nan(v2.into()).into_vector_value(),
-                            self.builder
-                                .build_select(
-                                    v1_lt_v2,
-                                    v1.into(),
-                                    self.builder.build_select(
-                                        v1_gt_v2,
-                                        v2.into(),
-                                        self.builder.build_bitcast(
-                                            self.builder.build_or(
-                                                self.builder
-                                                    .build_bitcast(v1, self.intrinsics.i32x4_ty, "")
-                                                    .into_vector_value(),
-                                                self.builder
-                                                    .build_bitcast(v2, self.intrinsics.i32x4_ty, "")
-                                                    .into_vector_value(),
-                                                "",
-                                            ),
-                                            self.intrinsics.f32x4_ty,
+                    self.quiet_nan(v1.into())?.into_vector_value(),
+                    err!(self.builder.build_select(
+                        v2_is_nan,
+                        self.quiet_nan(v2.into())?.into_vector_value(),
+                        err!(self.builder.build_select(
+                            v1_lt_v2,
+                            v1.into(),
+                            err!(self.builder.build_select(
+                                v1_gt_v2,
+                                v2.into(),
+                                err!(self.builder.build_bit_cast(
+                                    err!(self.builder.build_or(
+                                        err!(self.builder.build_bit_cast(
+                                            v1,
+                                            self.intrinsics.i32x4_ty,
+                                            "",
+                                        ))
+                                        .into_vector_value(),
+                                        err!(self.builder.build_bit_cast(
+                                            v2,
+                                            self.intrinsics.i32x4_ty,
                                             "",
-                                        ),
+                                        ))
+                                        .into_vector_value(),
                                         "",
-                                    ),
+                                    )),
+                                    self.intrinsics.f32x4_ty,
                                     "",
-                                )
-                                .into_vector_value(),
+                                )),
+                                "",
+                            )),
                             "",
-                        )
+                        ))
                         .into_vector_value(),
+                        "",
+                    ))
+                    .into_vector_value(),
                     "",
-                );
+                ));
 
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F32x4PMin => {
                 // Pseudo-min: b < a ? b : a
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _i1) = self.v128_into_f32x4(v1, i1);
-                let (v2, _i2) = self.v128_into_f32x4(v2, i2);
-                let cmp = self
+                let (v1, _i1) = self.v128_into_f32x4(v1, i1)?;
+                let (v2, _i2) = self.v128_into_f32x4(v2, i2)?;
+                let cmp = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OLT, v2, v1, "");
-                let res = self.builder.build_select(cmp, v2, v1, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_float_compare(FloatPredicate::OLT, v2, v1, ""));
+                let res = err!(self.builder.build_select(cmp, v2, v1, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F64x2Min => {
@@ -4815,125 +5029,125 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 // intrinsic would, but x86 lowering of that intrinsic
                 // encounters a fatal error in LLVM 11.
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_f64x2(v1, i1);
-                let (v2, _) = self.v128_into_f64x2(v2, i2);
+                let (v1, _) = self.v128_into_f64x2(v1, i1)?;
+                let (v2, _) = self.v128_into_f64x2(v2, i2)?;
 
-                let v1_is_nan = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f64x2,
-                        &[
-                            v1.into(),
-                            self.intrinsics.f64x2_zero.into(),
-                            self.intrinsics.fp_uno_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_vector_value();
-                let v2_is_nan = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f64x2,
-                        &[
-                            v2.into(),
-                            self.intrinsics.f64x2_zero.into(),
-                            self.intrinsics.fp_uno_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_vector_value();
-                let v1_lt_v2 = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f64x2,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_olt_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_vector_value();
-                let v1_gt_v2 = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f64x2,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_ogt_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_vector_value();
+                let v1_is_nan = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f64x2,
+                    &[
+                        v1.into(),
+                        self.intrinsics.f64x2_zero.into(),
+                        self.intrinsics.fp_uno_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_vector_value();
+                let v2_is_nan = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f64x2,
+                    &[
+                        v2.into(),
+                        self.intrinsics.f64x2_zero.into(),
+                        self.intrinsics.fp_uno_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_vector_value();
+                let v1_lt_v2 = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f64x2,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_olt_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_vector_value();
+                let v1_gt_v2 = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f64x2,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_ogt_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_vector_value();
 
-                let res = self.builder.build_select(
+                let res = err!(self.builder.build_select(
                     v1_is_nan,
-                    self.quiet_nan(v1.into()).into_vector_value(),
-                    self.builder
-                        .build_select(
-                            v2_is_nan,
-                            self.quiet_nan(v2.into()).into_vector_value(),
-                            self.builder
-                                .build_select(
-                                    v1_lt_v2,
-                                    v1.into(),
-                                    self.builder.build_select(
-                                        v1_gt_v2,
-                                        v2.into(),
-                                        self.builder.build_bitcast(
-                                            self.builder.build_or(
-                                                self.builder
-                                                    .build_bitcast(v1, self.intrinsics.i64x2_ty, "")
-                                                    .into_vector_value(),
-                                                self.builder
-                                                    .build_bitcast(v2, self.intrinsics.i64x2_ty, "")
-                                                    .into_vector_value(),
-                                                "",
-                                            ),
-                                            self.intrinsics.f64x2_ty,
+                    self.quiet_nan(v1.into())?.into_vector_value(),
+                    err!(self.builder.build_select(
+                        v2_is_nan,
+                        self.quiet_nan(v2.into())?.into_vector_value(),
+                        err!(self.builder.build_select(
+                            v1_lt_v2,
+                            v1.into(),
+                            err!(self.builder.build_select(
+                                v1_gt_v2,
+                                v2.into(),
+                                err!(self.builder.build_bit_cast(
+                                    err!(self.builder.build_or(
+                                        err!(self.builder.build_bit_cast(
+                                            v1,
+                                            self.intrinsics.i64x2_ty,
+                                            "",
+                                        ))
+                                        .into_vector_value(),
+                                        err!(self.builder.build_bit_cast(
+                                            v2,
+                                            self.intrinsics.i64x2_ty,
                                             "",
-                                        ),
+                                        ))
+                                        .into_vector_value(),
                                         "",
-                                    ),
+                                    )),
+                                    self.intrinsics.f64x2_ty,
                                     "",
-                                )
-                                .into_vector_value(),
+                                )),
+                                "",
+                            )),
                             "",
-                        )
+                        ))
                         .into_vector_value(),
+                        "",
+                    ))
+                    .into_vector_value(),
                     "",
-                );
+                ));
 
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F64x2PMin => {
                 // Pseudo-min: b < a ? b : a
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _i1) = self.v128_into_f64x2(v1, i1);
-                let (v2, _i2) = self.v128_into_f64x2(v2, i2);
-                let cmp = self
+                let (v1, _i1) = self.v128_into_f64x2(v1, i1)?;
+                let (v2, _i2) = self.v128_into_f64x2(v2, i2)?;
+                let cmp = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OLT, v2, v1, "");
-                let res = self.builder.build_select(cmp, v2, v1, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_float_compare(FloatPredicate::OLT, v2, v1, ""));
+                let res = err!(self.builder.build_select(cmp, v2, v1, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F32Max => {
@@ -4941,107 +5155,105 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 // intrinsic would, but x86 lowering of that intrinsic
                 // encounters a fatal error in LLVM 11.
                 let (v1, v2) = self.state.pop2()?;
-                let v1 = self.canonicalize_nans(v1);
-                let v2 = self.canonicalize_nans(v2);
+                let v1 = self.canonicalize_nans(v1)?;
+                let v2 = self.canonicalize_nans(v2)?;
 
-                let v1_is_nan = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f32,
-                        &[
-                            v1.into(),
-                            self.intrinsics.f32_zero.into(),
-                            self.intrinsics.fp_uno_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_int_value();
-                let v2_is_nan = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f32,
-                        &[
-                            v2.into(),
-                            self.intrinsics.f32_zero.into(),
-                            self.intrinsics.fp_uno_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_int_value();
-                let v1_lt_v2 = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f32,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_olt_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_int_value();
-                let v1_gt_v2 = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f32,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_ogt_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_int_value();
+                let v1_is_nan = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f32,
+                    &[
+                        v1.into(),
+                        self.intrinsics.f32_zero.into(),
+                        self.intrinsics.fp_uno_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_int_value();
+                let v2_is_nan = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f32,
+                    &[
+                        v2.into(),
+                        self.intrinsics.f32_zero.into(),
+                        self.intrinsics.fp_uno_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_int_value();
+                let v1_lt_v2 = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f32,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_olt_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_int_value();
+                let v1_gt_v2 = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f32,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_ogt_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_int_value();
 
-                let res = self.builder.build_select(
+                let res = err!(self.builder.build_select(
                     v1_is_nan,
-                    self.quiet_nan(v1),
-                    self.builder.build_select(
+                    self.quiet_nan(v1)?,
+                    err!(self.builder.build_select(
                         v2_is_nan,
-                        self.quiet_nan(v2),
-                        self.builder.build_select(
+                        self.quiet_nan(v2)?,
+                        err!(self.builder.build_select(
                             v1_lt_v2,
                             v2,
-                            self.builder.build_select(
+                            err!(self.builder.build_select(
                                 v1_gt_v2,
                                 v1,
-                                self.builder.build_bitcast(
-                                    self.builder.build_and(
-                                        self.builder
-                                            .build_bitcast(v1, self.intrinsics.i32_ty, "")
-                                            .into_int_value(),
-                                        self.builder
-                                            .build_bitcast(v2, self.intrinsics.i32_ty, "")
-                                            .into_int_value(),
+                                err!(self.builder.build_bit_cast(
+                                    err!(self.builder.build_and(
+                                        err!(self.builder.build_bit_cast(
+                                            v1,
+                                            self.intrinsics.i32_ty,
+                                            ""
+                                        ))
+                                        .into_int_value(),
+                                        err!(self.builder.build_bit_cast(
+                                            v2,
+                                            self.intrinsics.i32_ty,
+                                            ""
+                                        ))
+                                        .into_int_value(),
                                         "",
-                                    ),
+                                    )),
                                     self.intrinsics.f32_ty,
                                     "",
-                                ),
+                                )),
                                 "",
-                            ),
+                            )),
                             "",
-                        ),
+                        )),
                         "",
-                    ),
+                    )),
                     "",
-                );
+                ));
 
                 self.state.push1(res);
             }
@@ -5050,107 +5262,105 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 // intrinsic would, but x86 lowering of that intrinsic
                 // encounters a fatal error in LLVM 11.
                 let (v1, v2) = self.state.pop2()?;
-                let v1 = self.canonicalize_nans(v1);
-                let v2 = self.canonicalize_nans(v2);
+                let v1 = self.canonicalize_nans(v1)?;
+                let v2 = self.canonicalize_nans(v2)?;
 
-                let v1_is_nan = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f64,
-                        &[
-                            v1.into(),
-                            self.intrinsics.f64_zero.into(),
-                            self.intrinsics.fp_uno_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_int_value();
-                let v2_is_nan = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f64,
-                        &[
-                            v2.into(),
-                            self.intrinsics.f64_zero.into(),
-                            self.intrinsics.fp_uno_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_int_value();
-                let v1_lt_v2 = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f64,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_olt_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_int_value();
-                let v1_gt_v2 = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f64,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_ogt_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_int_value();
+                let v1_is_nan = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f64,
+                    &[
+                        v1.into(),
+                        self.intrinsics.f64_zero.into(),
+                        self.intrinsics.fp_uno_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_int_value();
+                let v2_is_nan = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f64,
+                    &[
+                        v2.into(),
+                        self.intrinsics.f64_zero.into(),
+                        self.intrinsics.fp_uno_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_int_value();
+                let v1_lt_v2 = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f64,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_olt_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_int_value();
+                let v1_gt_v2 = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f64,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_ogt_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_int_value();
 
-                let res = self.builder.build_select(
+                let res = err!(self.builder.build_select(
                     v1_is_nan,
-                    self.quiet_nan(v1),
-                    self.builder.build_select(
+                    self.quiet_nan(v1)?,
+                    err!(self.builder.build_select(
                         v2_is_nan,
-                        self.quiet_nan(v2),
-                        self.builder.build_select(
+                        self.quiet_nan(v2)?,
+                        err!(self.builder.build_select(
                             v1_lt_v2,
                             v2,
-                            self.builder.build_select(
+                            err!(self.builder.build_select(
                                 v1_gt_v2,
                                 v1,
-                                self.builder.build_bitcast(
-                                    self.builder.build_and(
-                                        self.builder
-                                            .build_bitcast(v1, self.intrinsics.i64_ty, "")
-                                            .into_int_value(),
-                                        self.builder
-                                            .build_bitcast(v2, self.intrinsics.i64_ty, "")
-                                            .into_int_value(),
+                                err!(self.builder.build_bit_cast(
+                                    err!(self.builder.build_and(
+                                        err!(self.builder.build_bit_cast(
+                                            v1,
+                                            self.intrinsics.i64_ty,
+                                            ""
+                                        ))
+                                        .into_int_value(),
+                                        err!(self.builder.build_bit_cast(
+                                            v2,
+                                            self.intrinsics.i64_ty,
+                                            ""
+                                        ))
+                                        .into_int_value(),
                                         "",
-                                    ),
+                                    )),
                                     self.intrinsics.f64_ty,
                                     "",
-                                ),
+                                )),
                                 "",
-                            ),
+                            )),
                             "",
-                        ),
+                        )),
                         "",
-                    ),
+                    )),
                     "",
-                );
+                ));
 
                 self.state.push1(res);
             }
@@ -5159,259 +5369,260 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 // intrinsic would, but x86 lowering of that intrinsic
                 // encounters a fatal error in LLVM 11.
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_f32x4(v1, i1);
-                let (v2, _) = self.v128_into_f32x4(v2, i2);
+                let (v1, _) = self.v128_into_f32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_f32x4(v2, i2)?;
 
-                let v1_is_nan = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f32x4,
-                        &[
-                            v1.into(),
-                            self.intrinsics.f32x4_zero.into(),
-                            self.intrinsics.fp_uno_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_vector_value();
-                let v2_is_nan = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f32x4,
-                        &[
-                            v2.into(),
-                            self.intrinsics.f32x4_zero.into(),
-                            self.intrinsics.fp_uno_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_vector_value();
-                let v1_lt_v2 = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f32x4,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_olt_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_vector_value();
-                let v1_gt_v2 = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f32x4,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_ogt_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_vector_value();
+                let v1_is_nan = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f32x4,
+                    &[
+                        v1.into(),
+                        self.intrinsics.f32x4_zero.into(),
+                        self.intrinsics.fp_uno_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_vector_value();
+                let v2_is_nan = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f32x4,
+                    &[
+                        v2.into(),
+                        self.intrinsics.f32x4_zero.into(),
+                        self.intrinsics.fp_uno_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_vector_value();
+                let v1_lt_v2 = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f32x4,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_olt_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_vector_value();
+                let v1_gt_v2 = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f32x4,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_ogt_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_vector_value();
 
-                let res = self.builder.build_select(
+                let res = err!(self.builder.build_select(
                     v1_is_nan,
-                    self.quiet_nan(v1.into()).into_vector_value(),
-                    self.builder
-                        .build_select(
-                            v2_is_nan,
-                            self.quiet_nan(v2.into()).into_vector_value(),
-                            self.builder
-                                .build_select(
-                                    v1_lt_v2,
-                                    v2.into(),
-                                    self.builder.build_select(
-                                        v1_gt_v2,
-                                        v1.into(),
-                                        self.builder.build_bitcast(
-                                            self.builder.build_and(
-                                                self.builder
-                                                    .build_bitcast(v1, self.intrinsics.i32x4_ty, "")
-                                                    .into_vector_value(),
-                                                self.builder
-                                                    .build_bitcast(v2, self.intrinsics.i32x4_ty, "")
-                                                    .into_vector_value(),
-                                                "",
-                                            ),
-                                            self.intrinsics.f32x4_ty,
+                    self.quiet_nan(v1.into())?.into_vector_value(),
+                    err!(self.builder.build_select(
+                        v2_is_nan,
+                        self.quiet_nan(v2.into())?.into_vector_value(),
+                        err!(self.builder.build_select(
+                            v1_lt_v2,
+                            v2.into(),
+                            err!(self.builder.build_select(
+                                v1_gt_v2,
+                                v1.into(),
+                                err!(self.builder.build_bit_cast(
+                                    err!(self.builder.build_and(
+                                        err!(self.builder.build_bit_cast(
+                                            v1,
+                                            self.intrinsics.i32x4_ty,
+                                            "",
+                                        ))
+                                        .into_vector_value(),
+                                        err!(self.builder.build_bit_cast(
+                                            v2,
+                                            self.intrinsics.i32x4_ty,
                                             "",
-                                        ),
+                                        ))
+                                        .into_vector_value(),
                                         "",
-                                    ),
+                                    )),
+                                    self.intrinsics.f32x4_ty,
                                     "",
-                                )
-                                .into_vector_value(),
+                                )),
+                                "",
+                            )),
                             "",
-                        )
+                        ))
                         .into_vector_value(),
+                        "",
+                    ))
+                    .into_vector_value(),
                     "",
-                );
+                ));
 
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
-                self.state.push1(res);
-            }
-            Operator::F32x4PMax => {
-                // Pseudo-max: a < b ? b : a
-                let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _i1) = self.v128_into_f32x4(v1, i1);
-                let (v2, _i2) = self.v128_into_f32x4(v2, i2);
-                let cmp = self
+                let res = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OLT, v1, v2, "");
-                let res = self.builder.build_select(cmp, v2, v1, "");
-
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
-            }
-            Operator::F64x2Max => {
-                // This implements the same logic as LLVM's @llvm.maximum
-                // intrinsic would, but x86 lowering of that intrinsic
-                // encounters a fatal error in LLVM 11.
-                let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_f64x2(v1, i1);
-                let (v2, _) = self.v128_into_f64x2(v2, i2);
-
-                let v1_is_nan = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f64x2,
-                        &[
-                            v1.into(),
-                            self.intrinsics.f64x2_zero.into(),
-                            self.intrinsics.fp_uno_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_vector_value();
-                let v2_is_nan = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f64x2,
-                        &[
-                            v2.into(),
-                            self.intrinsics.f64x2_zero.into(),
-                            self.intrinsics.fp_uno_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_vector_value();
-                let v1_lt_v2 = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f64x2,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_olt_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_vector_value();
-                let v1_gt_v2 = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.cmp_f64x2,
-                        &[
-                            v1.into(),
-                            v2.into(),
-                            self.intrinsics.fp_ogt_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap()
-                    .into_vector_value();
+            }
+            Operator::F32x4PMax => {
+                // Pseudo-max: a < b ? b : a
+                let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
+                let (v1, _i1) = self.v128_into_f32x4(v1, i1)?;
+                let (v2, _i2) = self.v128_into_f32x4(v2, i2)?;
+                let cmp = err!(self
+                    .builder
+                    .build_float_compare(FloatPredicate::OLT, v1, v2, ""));
+                let res = err!(self.builder.build_select(cmp, v2, v1, ""));
+
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
+                self.state.push1(res);
+            }
+            Operator::F64x2Max => {
+                // This implements the same logic as LLVM's @llvm.maximum
+                // intrinsic would, but x86 lowering of that intrinsic
+                // encounters a fatal error in LLVM 11.
+                let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
+                let (v1, _) = self.v128_into_f64x2(v1, i1)?;
+                let (v2, _) = self.v128_into_f64x2(v2, i2)?;
+
+                let v1_is_nan = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f64x2,
+                    &[
+                        v1.into(),
+                        self.intrinsics.f64x2_zero.into(),
+                        self.intrinsics.fp_uno_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_vector_value();
+                let v2_is_nan = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f64x2,
+                    &[
+                        v2.into(),
+                        self.intrinsics.f64x2_zero.into(),
+                        self.intrinsics.fp_uno_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_vector_value();
+                let v1_lt_v2 = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f64x2,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_olt_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_vector_value();
+                let v1_gt_v2 = err!(self.builder.build_call(
+                    self.intrinsics.cmp_f64x2,
+                    &[
+                        v1.into(),
+                        v2.into(),
+                        self.intrinsics.fp_ogt_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap()
+                .into_vector_value();
 
-                let res = self.builder.build_select(
+                let res = err!(self.builder.build_select(
                     v1_is_nan,
-                    self.quiet_nan(v1.into()).into_vector_value(),
-                    self.builder
-                        .build_select(
-                            v2_is_nan,
-                            self.quiet_nan(v2.into()).into_vector_value(),
-                            self.builder
-                                .build_select(
-                                    v1_lt_v2,
-                                    v2.into(),
-                                    self.builder.build_select(
-                                        v1_gt_v2,
-                                        v1.into(),
-                                        self.builder.build_bitcast(
-                                            self.builder.build_and(
-                                                self.builder
-                                                    .build_bitcast(v1, self.intrinsics.i64x2_ty, "")
-                                                    .into_vector_value(),
-                                                self.builder
-                                                    .build_bitcast(v2, self.intrinsics.i64x2_ty, "")
-                                                    .into_vector_value(),
-                                                "",
-                                            ),
-                                            self.intrinsics.f64x2_ty,
+                    self.quiet_nan(v1.into())?.into_vector_value(),
+                    err!(self.builder.build_select(
+                        v2_is_nan,
+                        self.quiet_nan(v2.into())?.into_vector_value(),
+                        err!(self.builder.build_select(
+                            v1_lt_v2,
+                            v2.into(),
+                            err!(self.builder.build_select(
+                                v1_gt_v2,
+                                v1.into(),
+                                err!(self.builder.build_bit_cast(
+                                    err!(self.builder.build_and(
+                                        err!(self.builder.build_bit_cast(
+                                            v1,
+                                            self.intrinsics.i64x2_ty,
+                                            "",
+                                        ))
+                                        .into_vector_value(),
+                                        err!(self.builder.build_bit_cast(
+                                            v2,
+                                            self.intrinsics.i64x2_ty,
                                             "",
-                                        ),
+                                        ))
+                                        .into_vector_value(),
                                         "",
-                                    ),
+                                    )),
+                                    self.intrinsics.f64x2_ty,
                                     "",
-                                )
-                                .into_vector_value(),
+                                )),
+                                "",
+                            )),
                             "",
-                        )
+                        ))
                         .into_vector_value(),
+                        "",
+                    ))
+                    .into_vector_value(),
                     "",
-                );
+                ));
 
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F64x2PMax => {
                 // Pseudo-max: a < b ? b : a
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _i1) = self.v128_into_f64x2(v1, i1);
-                let (v2, _i2) = self.v128_into_f64x2(v2, i2);
-                let cmp = self
+                let (v1, _i1) = self.v128_into_f64x2(v1, i1)?;
+                let (v2, _i2) = self.v128_into_f64x2(v2, i2)?;
+                let cmp = err!(self
+                    .builder
+                    .build_float_compare(FloatPredicate::OLT, v1, v2, ""));
+                let res = err!(self.builder.build_select(cmp, v2, v1, ""));
+                let res = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OLT, v1, v2, "");
-                let res = self.builder.build_select(cmp, v2, v1, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F32Ceil => {
                 let (input, info) = self.state.pop1_extra()?;
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.ceil_f32, &[input.into()], "")
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.ceil_f32, &[input.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
@@ -5420,22 +5631,26 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F32x4Ceil => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_f32x4(v, i);
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.ceil_f32x4, &[v.into()], "")
+                let (v, _) = self.v128_into_f32x4(v, i)?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.ceil_f32x4, &[v.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state
                     .push1_extra(res, i | ExtraInfo::pending_f32_nan());
             }
             Operator::F64Ceil => {
                 let (input, info) = self.state.pop1_extra()?;
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.ceil_f64, &[input.into()], "")
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.ceil_f64, &[input.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
@@ -5444,22 +5659,26 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F64x2Ceil => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_f64x2(v, i);
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.ceil_f64x2, &[v.into()], "")
+                let (v, _) = self.v128_into_f64x2(v, i)?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.ceil_f64x2, &[v.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state
                     .push1_extra(res, i | ExtraInfo::pending_f64_nan());
             }
             Operator::F32Floor => {
                 let (input, info) = self.state.pop1_extra()?;
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.floor_f32, &[input.into()], "")
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.floor_f32, &[input.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
@@ -5468,22 +5687,26 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F32x4Floor => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_f32x4(v, i);
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.floor_f32x4, &[v.into()], "")
+                let (v, _) = self.v128_into_f32x4(v, i)?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.floor_f32x4, &[v.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state
                     .push1_extra(res, i | ExtraInfo::pending_f32_nan());
             }
             Operator::F64Floor => {
                 let (input, info) = self.state.pop1_extra()?;
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.floor_f64, &[input.into()], "")
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.floor_f64, &[input.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
@@ -5492,70 +5715,80 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F64x2Floor => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_f64x2(v, i);
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.floor_f64x2, &[v.into()], "")
+                let (v, _) = self.v128_into_f64x2(v, i)?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.floor_f64x2, &[v.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state
                     .push1_extra(res, i | ExtraInfo::pending_f64_nan());
             }
             Operator::F32Trunc => {
                 let (v, i) = self.state.pop1_extra()?;
-                let res = self
+                let res = err!(self
                     .builder
-                    .build_call(self.intrinsics.trunc_f32, &[v.into()], "")
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                    .build_call(self.intrinsics.trunc_f32, &[v.into()], ""))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 self.state
                     .push1_extra(res, i | ExtraInfo::pending_f32_nan());
             }
             Operator::F32x4Trunc => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_f32x4(v, i);
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.trunc_f32x4, &[v.into()], "")
+                let (v, _) = self.v128_into_f32x4(v, i)?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.trunc_f32x4, &[v.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state
                     .push1_extra(res, i | ExtraInfo::pending_f32_nan());
             }
             Operator::F64Trunc => {
                 let (v, i) = self.state.pop1_extra()?;
-                let res = self
+                let res = err!(self
                     .builder
-                    .build_call(self.intrinsics.trunc_f64, &[v.into()], "")
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                    .build_call(self.intrinsics.trunc_f64, &[v.into()], ""))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 self.state
                     .push1_extra(res, i | ExtraInfo::pending_f64_nan());
             }
             Operator::F64x2Trunc => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_f64x2(v, i);
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.trunc_f64x2, &[v.into()], "")
+                let (v, _) = self.v128_into_f64x2(v, i)?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.trunc_f64x2, &[v.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state
                     .push1_extra(res, i | ExtraInfo::pending_f64_nan());
             }
             Operator::F32Nearest => {
                 let (v, i) = self.state.pop1_extra()?;
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.nearbyint_f32, &[v.into()], "")
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.nearbyint_f32, &[v.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
@@ -5564,22 +5797,26 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F32x4Nearest => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_f32x4(v, i);
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.nearbyint_f32x4, &[v.into()], "")
+                let (v, _) = self.v128_into_f32x4(v, i)?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.nearbyint_f32x4, &[v.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state
                     .push1_extra(res, i | ExtraInfo::pending_f32_nan());
             }
             Operator::F64Nearest => {
                 let (v, i) = self.state.pop1_extra()?;
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.nearbyint_f64, &[v.into()], "")
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.nearbyint_f64, &[v.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
@@ -5588,137 +5825,164 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F64x2Nearest => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_f64x2(v, i);
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.nearbyint_f64x2, &[v.into()], "")
+                let (v, _) = self.v128_into_f64x2(v, i)?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.nearbyint_f64x2, &[v.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state
                     .push1_extra(res, i | ExtraInfo::pending_f64_nan());
             }
             Operator::F32Abs => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
-                let res = self
+                let v = self.apply_pending_canonicalization(v, i)?;
+                let res = err!(self
                     .builder
-                    .build_call(self.intrinsics.fabs_f32, &[v.into()], "")
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                    .build_call(self.intrinsics.fabs_f32, &[v.into()], ""))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 // The exact NaN returned by F32Abs is fully defined. Do not
                 // adjust.
                 self.state.push1_extra(res, i.strip_pending());
             }
             Operator::F64Abs => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
-                let res = self
+                let v = self.apply_pending_canonicalization(v, i)?;
+                let res = err!(self
                     .builder
-                    .build_call(self.intrinsics.fabs_f64, &[v.into()], "")
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                    .build_call(self.intrinsics.fabs_f64, &[v.into()], ""))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 // The exact NaN returned by F64Abs is fully defined. Do not
                 // adjust.
                 self.state.push1_extra(res, i.strip_pending());
             }
             Operator::F32x4Abs => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v =
-                    self.builder
-                        .build_bitcast(v.into_int_value(), self.intrinsics.f32x4_ty, "");
-                let v = self.apply_pending_canonicalization(v, i);
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.fabs_f32x4, &[v.into()], "")
+                let v = err!(self.builder.build_bit_cast(
+                    v.into_int_value(),
+                    self.intrinsics.f32x4_ty,
+                    ""
+                ));
+                let v = self.apply_pending_canonicalization(v, i)?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.fabs_f32x4, &[v.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 // The exact NaN returned by F32x4Abs is fully defined. Do not
                 // adjust.
                 self.state.push1_extra(res, i.strip_pending());
             }
             Operator::F64x2Abs => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v =
-                    self.builder
-                        .build_bitcast(v.into_int_value(), self.intrinsics.f64x2_ty, "");
-                let v = self.apply_pending_canonicalization(v, i);
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.fabs_f64x2, &[v.into()], "")
+                let v = err!(self.builder.build_bit_cast(
+                    v.into_int_value(),
+                    self.intrinsics.f64x2_ty,
+                    ""
+                ));
+                let v = self.apply_pending_canonicalization(v, i)?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_call(self.intrinsics.fabs_f64x2, &[v.into()], ""))
                     .try_as_basic_value()
                     .left()
                     .unwrap();
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 // The exact NaN returned by F32x4Abs is fully defined. Do not
                 // adjust.
                 self.state.push1_extra(res, i.strip_pending());
             }
             Operator::F32x4Neg => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v =
-                    self.builder
-                        .build_bitcast(v.into_int_value(), self.intrinsics.f32x4_ty, "");
+                let v = err!(self.builder.build_bit_cast(
+                    v.into_int_value(),
+                    self.intrinsics.f32x4_ty,
+                    ""
+                ));
                 let v = self
-                    .apply_pending_canonicalization(v, i)
+                    .apply_pending_canonicalization(v, i)?
                     .into_vector_value();
-                let res = self.builder.build_float_neg(v, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self.builder.build_float_neg(v, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 // The exact NaN returned by F32x4Neg is fully defined. Do not
                 // adjust.
                 self.state.push1_extra(res, i.strip_pending());
             }
             Operator::F64x2Neg => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v =
-                    self.builder
-                        .build_bitcast(v.into_int_value(), self.intrinsics.f64x2_ty, "");
+                let v = err!(self.builder.build_bit_cast(
+                    v.into_int_value(),
+                    self.intrinsics.f64x2_ty,
+                    ""
+                ));
                 let v = self
-                    .apply_pending_canonicalization(v, i)
+                    .apply_pending_canonicalization(v, i)?
                     .into_vector_value();
-                let res = self.builder.build_float_neg(v, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self.builder.build_float_neg(v, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 // The exact NaN returned by F64x2Neg is fully defined. Do not
                 // adjust.
                 self.state.push1_extra(res, i.strip_pending());
             }
             Operator::F32Neg | Operator::F64Neg => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i).into_float_value();
-                let res = self.builder.build_float_neg(v, "");
+                let v = self
+                    .apply_pending_canonicalization(v, i)?
+                    .into_float_value();
+                let res = err!(self.builder.build_float_neg(v, ""));
                 // The exact NaN returned by F32Neg and F64Neg are fully defined.
                 // Do not adjust.
                 self.state.push1_extra(res, i.strip_pending());
             }
             Operator::F32Copysign => {
                 let ((mag, mag_info), (sgn, sgn_info)) = self.state.pop2_extra()?;
-                let mag = self.apply_pending_canonicalization(mag, mag_info);
-                let sgn = self.apply_pending_canonicalization(sgn, sgn_info);
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.copysign_f32, &[mag.into(), sgn.into()], "")
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                let mag = self.apply_pending_canonicalization(mag, mag_info)?;
+                let sgn = self.apply_pending_canonicalization(sgn, sgn_info)?;
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.copysign_f32,
+                    &[mag.into(), sgn.into()],
+                    ""
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 // The exact NaN returned by F32Copysign is fully defined.
                 // Do not adjust.
                 self.state.push1_extra(res, mag_info.strip_pending());
             }
             Operator::F64Copysign => {
                 let ((mag, mag_info), (sgn, sgn_info)) = self.state.pop2_extra()?;
-                let mag = self.apply_pending_canonicalization(mag, mag_info);
-                let sgn = self.apply_pending_canonicalization(sgn, sgn_info);
-                let res = self
-                    .builder
-                    .build_call(self.intrinsics.copysign_f64, &[mag.into(), sgn.into()], "")
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                let mag = self.apply_pending_canonicalization(mag, mag_info)?;
+                let sgn = self.apply_pending_canonicalization(sgn, sgn_info)?;
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.copysign_f64,
+                    &[mag.into(), sgn.into()],
+                    ""
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 // The exact NaN returned by F32Copysign is fully defined.
                 // Do not adjust.
                 self.state.push1_extra(res, mag_info.strip_pending());
@@ -5730,13 +5994,13 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
              ***************************/
             Operator::I32Eq | Operator::I64Eq => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
-                let cond = self.builder.build_int_compare(IntPredicate::EQ, v1, v2, "");
-                let res = self
+                let cond = err!(self.builder.build_int_compare(IntPredicate::EQ, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(cond, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(cond, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(
                     res,
                     ExtraInfo::arithmetic_f32() | ExtraInfo::arithmetic_f64(),
@@ -5744,57 +6008,65 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::I8x16Eq => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let res = self.builder.build_int_compare(IntPredicate::EQ, v1, v2, "");
-                let res = self
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let res = err!(self.builder.build_int_compare(IntPredicate::EQ, v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8Eq => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let res = self.builder.build_int_compare(IntPredicate::EQ, v1, v2, "");
-                let res = self
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let res = err!(self.builder.build_int_compare(IntPredicate::EQ, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4Eq => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
-                let res = self.builder.build_int_compare(IntPredicate::EQ, v1, v2, "");
-                let res = self
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
+                let res = err!(self.builder.build_int_compare(IntPredicate::EQ, v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64x2Eq => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i64x2(v1, i1);
-                let (v2, _) = self.v128_into_i64x2(v2, i2);
-                let res = self.builder.build_int_compare(IntPredicate::EQ, v1, v2, "");
-                let res = self
+                let (v1, _) = self.v128_into_i64x2(v1, i1)?;
+                let (v2, _) = self.v128_into_i64x2(v2, i2)?;
+                let res = err!(self.builder.build_int_compare(IntPredicate::EQ, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32Ne | Operator::I64Ne => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
-                let cond = self.builder.build_int_compare(IntPredicate::NE, v1, v2, "");
-                let res = self
+                let cond = err!(self.builder.build_int_compare(IntPredicate::NE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(cond, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(cond, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(
                     res,
                     ExtraInfo::arithmetic_f32() | ExtraInfo::arithmetic_f64(),
@@ -5802,59 +6074,67 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::I8x16Ne => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let res = self.builder.build_int_compare(IntPredicate::NE, v1, v2, "");
-                let res = self
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let res = err!(self.builder.build_int_compare(IntPredicate::NE, v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8Ne => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let res = self.builder.build_int_compare(IntPredicate::NE, v1, v2, "");
-                let res = self
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let res = err!(self.builder.build_int_compare(IntPredicate::NE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4Ne => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
-                let res = self.builder.build_int_compare(IntPredicate::NE, v1, v2, "");
-                let res = self
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
+                let res = err!(self.builder.build_int_compare(IntPredicate::NE, v1, v2, ""));
+                let res = err!(self
+                    .builder
+                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64x2Ne => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i64x2(v1, i1);
-                let (v2, _) = self.v128_into_i64x2(v2, i2);
-                let res = self.builder.build_int_compare(IntPredicate::NE, v1, v2, "");
-                let res = self
+                let (v1, _) = self.v128_into_i64x2(v1, i1)?;
+                let (v2, _) = self.v128_into_i64x2(v2, i2)?;
+                let res = err!(self.builder.build_int_compare(IntPredicate::NE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32LtS | Operator::I64LtS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
-                let cond = self
+                let cond = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SLT, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::SLT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(cond, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(cond, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(
                     res,
                     ExtraInfo::arithmetic_f32() | ExtraInfo::arithmetic_f64(),
@@ -5862,119 +6142,133 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::I8x16LtS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::SLT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SLT, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8LtS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SLT, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::SLT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4LtS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::SLT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SLT, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64x2LtS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i64x2(v1, i1);
-                let (v2, _) = self.v128_into_i64x2(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i64x2(v1, i1)?;
+                let (v2, _) = self.v128_into_i64x2(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SLT, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::SLT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32LtU | Operator::I64LtU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
-                let cond = self
+                let cond = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::ULT, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::ULT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(cond, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(cond, self.intrinsics.i32_ty, ""));
                 self.state.push1(res);
             }
             Operator::I8x16LtU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::ULT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::ULT, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8LtU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::ULT, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::ULT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4LtU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::ULT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::ULT, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32LeS | Operator::I64LeS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
-                let cond = self
+                let cond = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SLE, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::SLE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(cond, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(cond, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(
                     res,
                     ExtraInfo::arithmetic_f32() | ExtraInfo::arithmetic_f64(),
@@ -5982,67 +6276,75 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::I8x16LeS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SLE, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::SLE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8LeS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::SLE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SLE, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4LeS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SLE, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::SLE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64x2LeS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i64x2(v1, i1);
-                let (v2, _) = self.v128_into_i64x2(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i64x2(v1, i1)?;
+                let (v2, _) = self.v128_into_i64x2(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::SLE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SLE, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32LeU | Operator::I64LeU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
-                let cond = self
+                let cond = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::ULE, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::ULE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(cond, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(cond, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(
                     res,
                     ExtraInfo::arithmetic_f32() | ExtraInfo::arithmetic_f64(),
@@ -6050,54 +6352,60 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::I8x16LeU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::ULE, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::ULE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8LeU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::ULE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::ULE, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4LeU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::ULE, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::ULE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32GtS | Operator::I64GtS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
-                let cond = self
+                let cond = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SGT, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::SGT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(cond, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(cond, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(
                     res,
                     ExtraInfo::arithmetic_f32() | ExtraInfo::arithmetic_f64(),
@@ -6105,67 +6413,75 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::I8x16GtS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::SGT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SGT, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8GtS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SGT, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::SGT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4GtS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::SGT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SGT, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64x2GtS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i64x2(v1, i1);
-                let (v2, _) = self.v128_into_i64x2(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i64x2(v1, i1)?;
+                let (v2, _) = self.v128_into_i64x2(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SGT, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::SGT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32GtU | Operator::I64GtU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
-                let cond = self
+                let cond = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::UGT, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::UGT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(cond, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(cond, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(
                     res,
                     ExtraInfo::arithmetic_f32() | ExtraInfo::arithmetic_f64(),
@@ -6173,119 +6489,133 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::I8x16GtU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::UGT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::UGT, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8GtU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::UGT, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::UGT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4GtU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::UGT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::UGT, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32GeS | Operator::I64GeS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
-                let cond = self
+                let cond = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SGE, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::SGE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(cond, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(cond, self.intrinsics.i32_ty, ""));
                 self.state.push1(res);
             }
             Operator::I8x16GeS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SGE, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::SGE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8GeS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::SGE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SGE, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4GeS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SGE, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::SGE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64x2GeS => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i64x2(v1, i1);
-                let (v2, _) = self.v128_into_i64x2(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i64x2(v1, i1)?;
+                let (v2, _) = self.v128_into_i64x2(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::SGE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::SGE, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32GeU | Operator::I64GeU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let (v1, v2) = (v1.into_int_value(), v2.into_int_value());
-                let cond = self
+                let cond = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::UGE, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::UGE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(cond, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(cond, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(
                     res,
                     ExtraInfo::arithmetic_f32() | ExtraInfo::arithmetic_f64(),
@@ -6293,41 +6623,47 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::I8x16GeU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
-                let (v2, _) = self.v128_into_i8x16(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
+                let (v2, _) = self.v128_into_i8x16(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::UGE, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::UGE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i8x16_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8GeU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_int_compare(IntPredicate::UGE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::UGE, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i16x8_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4GeU => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_int_compare(IntPredicate::UGE, v1, v2, "");
-                let res = self
+                    .build_int_compare(IntPredicate::UGE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
 
@@ -6338,12 +6674,12 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             Operator::F32Eq | Operator::F64Eq => {
                 let (v1, v2) = self.state.pop2()?;
                 let (v1, v2) = (v1.into_float_value(), v2.into_float_value());
-                let cond = self
+                let cond = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OEQ, v1, v2, "");
-                let res = self
+                    .build_float_compare(FloatPredicate::OEQ, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(cond, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(cond, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(
                     res,
                     ExtraInfo::arithmetic_f32() | ExtraInfo::arithmetic_f64(),
@@ -6351,39 +6687,43 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F32x4Eq => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_f32x4(v1, i1);
-                let (v2, _) = self.v128_into_f32x4(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_f32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_f32x4(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_float_compare(FloatPredicate::OEQ, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OEQ, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F64x2Eq => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_f64x2(v1, i1);
-                let (v2, _) = self.v128_into_f64x2(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_f64x2(v1, i1)?;
+                let (v2, _) = self.v128_into_f64x2(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OEQ, v1, v2, "");
-                let res = self
+                    .build_float_compare(FloatPredicate::OEQ, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F32Ne | Operator::F64Ne => {
                 let (v1, v2) = self.state.pop2()?;
                 let (v1, v2) = (v1.into_float_value(), v2.into_float_value());
-                let cond = self
+                let cond = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::UNE, v1, v2, "");
-                let res = self
+                    .build_float_compare(FloatPredicate::UNE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(cond, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(cond, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(
                     res,
                     ExtraInfo::arithmetic_f32() | ExtraInfo::arithmetic_f64(),
@@ -6391,39 +6731,43 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F32x4Ne => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_f32x4(v1, i1);
-                let (v2, _) = self.v128_into_f32x4(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_f32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_f32x4(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_float_compare(FloatPredicate::UNE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::UNE, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F64x2Ne => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_f64x2(v1, i1);
-                let (v2, _) = self.v128_into_f64x2(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_f64x2(v1, i1)?;
+                let (v2, _) = self.v128_into_f64x2(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::UNE, v1, v2, "");
-                let res = self
+                    .build_float_compare(FloatPredicate::UNE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F32Lt | Operator::F64Lt => {
                 let (v1, v2) = self.state.pop2()?;
                 let (v1, v2) = (v1.into_float_value(), v2.into_float_value());
-                let cond = self
+                let cond = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OLT, v1, v2, "");
-                let res = self
+                    .build_float_compare(FloatPredicate::OLT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(cond, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(cond, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(
                     res,
                     ExtraInfo::arithmetic_f32() | ExtraInfo::arithmetic_f64(),
@@ -6431,39 +6775,43 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F32x4Lt => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_f32x4(v1, i1);
-                let (v2, _) = self.v128_into_f32x4(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_f32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_f32x4(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_float_compare(FloatPredicate::OLT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OLT, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F64x2Lt => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_f64x2(v1, i1);
-                let (v2, _) = self.v128_into_f64x2(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_f64x2(v1, i1)?;
+                let (v2, _) = self.v128_into_f64x2(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OLT, v1, v2, "");
-                let res = self
+                    .build_float_compare(FloatPredicate::OLT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F32Le | Operator::F64Le => {
                 let (v1, v2) = self.state.pop2()?;
                 let (v1, v2) = (v1.into_float_value(), v2.into_float_value());
-                let cond = self
+                let cond = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OLE, v1, v2, "");
-                let res = self
+                    .build_float_compare(FloatPredicate::OLE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(cond, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(cond, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(
                     res,
                     ExtraInfo::arithmetic_f32() | ExtraInfo::arithmetic_f64(),
@@ -6471,39 +6819,43 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F32x4Le => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_f32x4(v1, i1);
-                let (v2, _) = self.v128_into_f32x4(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_f32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_f32x4(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_float_compare(FloatPredicate::OLE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OLE, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F64x2Le => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_f64x2(v1, i1);
-                let (v2, _) = self.v128_into_f64x2(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_f64x2(v1, i1)?;
+                let (v2, _) = self.v128_into_f64x2(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OLE, v1, v2, "");
-                let res = self
+                    .build_float_compare(FloatPredicate::OLE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F32Gt | Operator::F64Gt => {
                 let (v1, v2) = self.state.pop2()?;
                 let (v1, v2) = (v1.into_float_value(), v2.into_float_value());
-                let cond = self
+                let cond = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OGT, v1, v2, "");
-                let res = self
+                    .build_float_compare(FloatPredicate::OGT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(cond, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(cond, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(
                     res,
                     ExtraInfo::arithmetic_f32() | ExtraInfo::arithmetic_f64(),
@@ -6511,39 +6863,43 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F32x4Gt => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_f32x4(v1, i1);
-                let (v2, _) = self.v128_into_f32x4(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_f32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_f32x4(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_float_compare(FloatPredicate::OGT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OGT, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F64x2Gt => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_f64x2(v1, i1);
-                let (v2, _) = self.v128_into_f64x2(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_f64x2(v1, i1)?;
+                let (v2, _) = self.v128_into_f64x2(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OGT, v1, v2, "");
-                let res = self
+                    .build_float_compare(FloatPredicate::OGT, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F32Ge | Operator::F64Ge => {
                 let (v1, v2) = self.state.pop2()?;
                 let (v1, v2) = (v1.into_float_value(), v2.into_float_value());
-                let cond = self
+                let cond = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OGE, v1, v2, "");
-                let res = self
+                    .build_float_compare(FloatPredicate::OGE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(cond, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(cond, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(
                     res,
                     ExtraInfo::arithmetic_f32() | ExtraInfo::arithmetic_f64(),
@@ -6551,28 +6907,32 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F32x4Ge => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_f32x4(v1, i1);
-                let (v2, _) = self.v128_into_f32x4(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_f32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_f32x4(v2, i2)?;
+                let res = err!(self
+                    .builder
+                    .build_float_compare(FloatPredicate::OGE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OGE, v1, v2, "");
-                let res = self
+                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F64x2Ge => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_f64x2(v1, i1);
-                let (v2, _) = self.v128_into_f64x2(v2, i2);
-                let res = self
+                let (v1, _) = self.v128_into_f64x2(v1, i1)?;
+                let (v2, _) = self.v128_into_f64x2(v2, i2)?;
+                let res = err!(self
                     .builder
-                    .build_float_compare(FloatPredicate::OGE, v1, v2, "");
-                let res = self
+                    .build_float_compare(FloatPredicate::OGE, v1, v2, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i64x2_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
 
@@ -6582,35 +6942,35 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
              ***************************/
             Operator::I32WrapI64 => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let v = v.into_int_value();
-                let res = self
+                let res = err!(self
                     .builder
-                    .build_int_truncate(v, self.intrinsics.i32_ty, "");
+                    .build_int_truncate(v, self.intrinsics.i32_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64ExtendI32S => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let v = v.into_int_value();
-                let res = self
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(v, self.intrinsics.i64_ty, "");
+                    .build_int_s_extend(v, self.intrinsics.i64_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64ExtendI32U => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let v = v.into_int_value();
-                let res = self
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(v, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(v, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(res, ExtraInfo::arithmetic_f64());
             }
             Operator::I16x8ExtendLowI8x16S => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i8x16(v, i);
-                let low = self.builder.build_shuffle_vector(
+                let (v, _) = self.v128_into_i8x16(v, i)?;
+                let low = err!(self.builder.build_shuffle_vector(
                     v,
                     v.get_type().get_undef(),
                     VectorType::const_vector(&[
@@ -6624,17 +6984,19 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[7],
                     ]),
                     "",
-                );
-                let res = self
+                ));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(low, self.intrinsics.i16x8_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(low, self.intrinsics.i16x8_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8ExtendHighI8x16S => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i8x16(v, i);
-                let low = self.builder.build_shuffle_vector(
+                let (v, _) = self.v128_into_i8x16(v, i)?;
+                let low = err!(self.builder.build_shuffle_vector(
                     v,
                     v.get_type().get_undef(),
                     VectorType::const_vector(&[
@@ -6648,17 +7010,19 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[15],
                     ]),
                     "",
-                );
-                let res = self
+                ));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(low, self.intrinsics.i16x8_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(low, self.intrinsics.i16x8_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8ExtendLowI8x16U => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i8x16(v, i);
-                let low = self.builder.build_shuffle_vector(
+                let (v, _) = self.v128_into_i8x16(v, i)?;
+                let low = err!(self.builder.build_shuffle_vector(
                     v,
                     v.get_type().get_undef(),
                     VectorType::const_vector(&[
@@ -6672,17 +7036,19 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[7],
                     ]),
                     "",
-                );
-                let res = self
+                ));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(low, self.intrinsics.i16x8_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_z_extend(low, self.intrinsics.i16x8_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8ExtendHighI8x16U => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i8x16(v, i);
-                let low = self.builder.build_shuffle_vector(
+                let (v, _) = self.v128_into_i8x16(v, i)?;
+                let low = err!(self.builder.build_shuffle_vector(
                     v,
                     v.get_type().get_undef(),
                     VectorType::const_vector(&[
@@ -6696,17 +7062,19 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[15],
                     ]),
                     "",
-                );
-                let res = self
+                ));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(low, self.intrinsics.i16x8_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_z_extend(low, self.intrinsics.i16x8_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4ExtendLowI16x8S => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i16x8(v, i);
-                let low = self.builder.build_shuffle_vector(
+                let (v, _) = self.v128_into_i16x8(v, i)?;
+                let low = err!(self.builder.build_shuffle_vector(
                     v,
                     v.get_type().get_undef(),
                     VectorType::const_vector(&[
@@ -6716,17 +7084,19 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[3],
                     ]),
                     "",
-                );
-                let res = self
+                ));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(low, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(low, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4ExtendHighI16x8S => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i16x8(v, i);
-                let low = self.builder.build_shuffle_vector(
+                let (v, _) = self.v128_into_i16x8(v, i)?;
+                let low = err!(self.builder.build_shuffle_vector(
                     v,
                     v.get_type().get_undef(),
                     VectorType::const_vector(&[
@@ -6736,17 +7106,19 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[7],
                     ]),
                     "",
-                );
-                let res = self
+                ));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(low, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(low, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4ExtendLowI16x8U => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i16x8(v, i);
-                let low = self.builder.build_shuffle_vector(
+                let (v, _) = self.v128_into_i16x8(v, i)?;
+                let low = err!(self.builder.build_shuffle_vector(
                     v,
                     v.get_type().get_undef(),
                     VectorType::const_vector(&[
@@ -6756,17 +7128,19 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[3],
                     ]),
                     "",
-                );
-                let res = self
+                ));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(low, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_z_extend(low, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4ExtendHighI16x8U => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i16x8(v, i);
-                let low = self.builder.build_shuffle_vector(
+                let (v, _) = self.v128_into_i16x8(v, i)?;
+                let low = err!(self.builder.build_shuffle_vector(
                     v,
                     v.get_type().get_undef(),
                     VectorType::const_vector(&[
@@ -6776,11 +7150,13 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[7],
                     ]),
                     "",
-                );
-                let res = self
+                ));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(low, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_z_extend(low, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64x2ExtendLowI32x4U
@@ -6806,60 +7182,62 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     _ => unreachable!("Unhandled inner case"),
                 };
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i32x4(v, i);
-                let low = self.builder.build_shuffle_vector(
+                let (v, _) = self.v128_into_i32x4(v, i)?;
+                let low = err!(self.builder.build_shuffle_vector(
                     v,
                     v.get_type().get_undef(),
                     VectorType::const_vector(&indices),
                     "",
-                );
-                let res = extend(self, low);
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                ));
+                let res = err!(extend(self, low));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I8x16NarrowI16x8S => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
                 let min = self.intrinsics.i16_ty.const_int(0xff80, false);
                 let max = self.intrinsics.i16_ty.const_int(0x007f, false);
                 let min = VectorType::const_vector(&[min; 8]);
                 let max = VectorType::const_vector(&[max; 8]);
                 let apply_min_clamp_v1 =
-                    self.builder
-                        .build_int_compare(IntPredicate::SLT, v1, min, "");
+                    err!(self
+                        .builder
+                        .build_int_compare(IntPredicate::SLT, v1, min, ""));
                 let apply_max_clamp_v1 =
-                    self.builder
-                        .build_int_compare(IntPredicate::SGT, v1, max, "");
+                    err!(self
+                        .builder
+                        .build_int_compare(IntPredicate::SGT, v1, max, ""));
                 let apply_min_clamp_v2 =
-                    self.builder
-                        .build_int_compare(IntPredicate::SLT, v2, min, "");
+                    err!(self
+                        .builder
+                        .build_int_compare(IntPredicate::SLT, v2, min, ""));
                 let apply_max_clamp_v2 =
-                    self.builder
-                        .build_int_compare(IntPredicate::SGT, v2, max, "");
-                let v1 = self
-                    .builder
-                    .build_select(apply_min_clamp_v1, min, v1, "")
+                    err!(self
+                        .builder
+                        .build_int_compare(IntPredicate::SGT, v2, max, ""));
+                let v1 = err!(self.builder.build_select(apply_min_clamp_v1, min, v1, ""))
                     .into_vector_value();
-                let v1 = self
-                    .builder
-                    .build_select(apply_max_clamp_v1, max, v1, "")
+                let v1 = err!(self.builder.build_select(apply_max_clamp_v1, max, v1, ""))
                     .into_vector_value();
-                let v1 = self
-                    .builder
-                    .build_int_truncate(v1, self.intrinsics.i8_ty.vec_type(8), "");
-                let v2 = self
-                    .builder
-                    .build_select(apply_min_clamp_v2, min, v2, "")
+                let v1 = err!(self.builder.build_int_truncate(
+                    v1,
+                    self.intrinsics.i8_ty.vec_type(8),
+                    ""
+                ));
+                let v2 = err!(self.builder.build_select(apply_min_clamp_v2, min, v2, ""))
                     .into_vector_value();
-                let v2 = self
-                    .builder
-                    .build_select(apply_max_clamp_v2, max, v2, "")
+                let v2 = err!(self.builder.build_select(apply_max_clamp_v2, max, v2, ""))
                     .into_vector_value();
-                let v2 = self
-                    .builder
-                    .build_int_truncate(v2, self.intrinsics.i8_ty.vec_type(8), "");
-                let res = self.builder.build_shuffle_vector(
+                let v2 = err!(self.builder.build_int_truncate(
+                    v2,
+                    self.intrinsics.i8_ty.vec_type(8),
+                    ""
+                ));
+                let res = err!(self.builder.build_shuffle_vector(
                     v1,
                     v2,
                     VectorType::const_vector(&[
@@ -6881,52 +7259,54 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[15],
                     ]),
                     "",
-                );
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                ));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I8x16NarrowI16x8U => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
-                let (v2, _) = self.v128_into_i16x8(v2, i2);
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
+                let (v2, _) = self.v128_into_i16x8(v2, i2)?;
                 let min = self.intrinsics.i16x8_ty.const_zero();
                 let max = self.intrinsics.i16_ty.const_int(0x00ff, false);
                 let max = VectorType::const_vector(&[max; 8]);
                 let apply_min_clamp_v1 =
-                    self.builder
-                        .build_int_compare(IntPredicate::SLT, v1, min, "");
+                    err!(self
+                        .builder
+                        .build_int_compare(IntPredicate::SLT, v1, min, ""));
                 let apply_max_clamp_v1 =
-                    self.builder
-                        .build_int_compare(IntPredicate::SGT, v1, max, "");
+                    err!(self
+                        .builder
+                        .build_int_compare(IntPredicate::SGT, v1, max, ""));
                 let apply_min_clamp_v2 =
-                    self.builder
-                        .build_int_compare(IntPredicate::SLT, v2, min, "");
+                    err!(self
+                        .builder
+                        .build_int_compare(IntPredicate::SLT, v2, min, ""));
                 let apply_max_clamp_v2 =
-                    self.builder
-                        .build_int_compare(IntPredicate::SGT, v2, max, "");
-                let v1 = self
-                    .builder
-                    .build_select(apply_min_clamp_v1, min, v1, "")
+                    err!(self
+                        .builder
+                        .build_int_compare(IntPredicate::SGT, v2, max, ""));
+                let v1 = err!(self.builder.build_select(apply_min_clamp_v1, min, v1, ""))
                     .into_vector_value();
-                let v1 = self
-                    .builder
-                    .build_select(apply_max_clamp_v1, max, v1, "")
+                let v1 = err!(self.builder.build_select(apply_max_clamp_v1, max, v1, ""))
                     .into_vector_value();
-                let v1 = self
-                    .builder
-                    .build_int_truncate(v1, self.intrinsics.i8_ty.vec_type(8), "");
-                let v2 = self
-                    .builder
-                    .build_select(apply_min_clamp_v2, min, v2, "")
+                let v1 = err!(self.builder.build_int_truncate(
+                    v1,
+                    self.intrinsics.i8_ty.vec_type(8),
+                    ""
+                ));
+                let v2 = err!(self.builder.build_select(apply_min_clamp_v2, min, v2, ""))
                     .into_vector_value();
-                let v2 = self
-                    .builder
-                    .build_select(apply_max_clamp_v2, max, v2, "")
+                let v2 = err!(self.builder.build_select(apply_max_clamp_v2, max, v2, ""))
                     .into_vector_value();
-                let v2 = self
-                    .builder
-                    .build_int_truncate(v2, self.intrinsics.i8_ty.vec_type(8), "");
-                let res = self.builder.build_shuffle_vector(
+                let v2 = err!(self.builder.build_int_truncate(
+                    v2,
+                    self.intrinsics.i8_ty.vec_type(8),
+                    ""
+                ));
+                let res = err!(self.builder.build_shuffle_vector(
                     v1,
                     v2,
                     VectorType::const_vector(&[
@@ -6948,53 +7328,55 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[15],
                     ]),
                     "",
-                );
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                ));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8NarrowI32x4S => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
                 let min = self.intrinsics.i32_ty.const_int(0xffff8000, false);
                 let max = self.intrinsics.i32_ty.const_int(0x00007fff, false);
                 let min = VectorType::const_vector(&[min; 4]);
                 let max = VectorType::const_vector(&[max; 4]);
                 let apply_min_clamp_v1 =
-                    self.builder
-                        .build_int_compare(IntPredicate::SLT, v1, min, "");
+                    err!(self
+                        .builder
+                        .build_int_compare(IntPredicate::SLT, v1, min, ""));
                 let apply_max_clamp_v1 =
-                    self.builder
-                        .build_int_compare(IntPredicate::SGT, v1, max, "");
+                    err!(self
+                        .builder
+                        .build_int_compare(IntPredicate::SGT, v1, max, ""));
                 let apply_min_clamp_v2 =
-                    self.builder
-                        .build_int_compare(IntPredicate::SLT, v2, min, "");
+                    err!(self
+                        .builder
+                        .build_int_compare(IntPredicate::SLT, v2, min, ""));
                 let apply_max_clamp_v2 =
-                    self.builder
-                        .build_int_compare(IntPredicate::SGT, v2, max, "");
-                let v1 = self
-                    .builder
-                    .build_select(apply_min_clamp_v1, min, v1, "")
+                    err!(self
+                        .builder
+                        .build_int_compare(IntPredicate::SGT, v2, max, ""));
+                let v1 = err!(self.builder.build_select(apply_min_clamp_v1, min, v1, ""))
                     .into_vector_value();
-                let v1 = self
-                    .builder
-                    .build_select(apply_max_clamp_v1, max, v1, "")
+                let v1 = err!(self.builder.build_select(apply_max_clamp_v1, max, v1, ""))
                     .into_vector_value();
-                let v1 =
-                    self.builder
-                        .build_int_truncate(v1, self.intrinsics.i16_ty.vec_type(4), "");
-                let v2 = self
-                    .builder
-                    .build_select(apply_min_clamp_v2, min, v2, "")
+                let v1 = err!(self.builder.build_int_truncate(
+                    v1,
+                    self.intrinsics.i16_ty.vec_type(4),
+                    ""
+                ));
+                let v2 = err!(self.builder.build_select(apply_min_clamp_v2, min, v2, ""))
                     .into_vector_value();
-                let v2 = self
-                    .builder
-                    .build_select(apply_max_clamp_v2, max, v2, "")
+                let v2 = err!(self.builder.build_select(apply_max_clamp_v2, max, v2, ""))
                     .into_vector_value();
-                let v2 =
-                    self.builder
-                        .build_int_truncate(v2, self.intrinsics.i16_ty.vec_type(4), "");
-                let res = self.builder.build_shuffle_vector(
+                let v2 = err!(self.builder.build_int_truncate(
+                    v2,
+                    self.intrinsics.i16_ty.vec_type(4),
+                    ""
+                ));
+                let res = err!(self.builder.build_shuffle_vector(
                     v1,
                     v2,
                     VectorType::const_vector(&[
@@ -7008,52 +7390,54 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[7],
                     ]),
                     "",
-                );
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                ));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8NarrowI32x4U => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i32x4(v1, i1);
-                let (v2, _) = self.v128_into_i32x4(v2, i2);
+                let (v1, _) = self.v128_into_i32x4(v1, i1)?;
+                let (v2, _) = self.v128_into_i32x4(v2, i2)?;
                 let min = self.intrinsics.i32x4_ty.const_zero();
                 let max = self.intrinsics.i32_ty.const_int(0xffff, false);
                 let max = VectorType::const_vector(&[max; 4]);
                 let apply_min_clamp_v1 =
-                    self.builder
-                        .build_int_compare(IntPredicate::SLT, v1, min, "");
+                    err!(self
+                        .builder
+                        .build_int_compare(IntPredicate::SLT, v1, min, ""));
                 let apply_max_clamp_v1 =
-                    self.builder
-                        .build_int_compare(IntPredicate::SGT, v1, max, "");
+                    err!(self
+                        .builder
+                        .build_int_compare(IntPredicate::SGT, v1, max, ""));
                 let apply_min_clamp_v2 =
-                    self.builder
-                        .build_int_compare(IntPredicate::SLT, v2, min, "");
+                    err!(self
+                        .builder
+                        .build_int_compare(IntPredicate::SLT, v2, min, ""));
                 let apply_max_clamp_v2 =
-                    self.builder
-                        .build_int_compare(IntPredicate::SGT, v2, max, "");
-                let v1 = self
-                    .builder
-                    .build_select(apply_min_clamp_v1, min, v1, "")
+                    err!(self
+                        .builder
+                        .build_int_compare(IntPredicate::SGT, v2, max, ""));
+                let v1 = err!(self.builder.build_select(apply_min_clamp_v1, min, v1, ""))
                     .into_vector_value();
-                let v1 = self
-                    .builder
-                    .build_select(apply_max_clamp_v1, max, v1, "")
+                let v1 = err!(self.builder.build_select(apply_max_clamp_v1, max, v1, ""))
                     .into_vector_value();
-                let v1 =
-                    self.builder
-                        .build_int_truncate(v1, self.intrinsics.i16_ty.vec_type(4), "");
-                let v2 = self
-                    .builder
-                    .build_select(apply_min_clamp_v2, min, v2, "")
+                let v1 = err!(self.builder.build_int_truncate(
+                    v1,
+                    self.intrinsics.i16_ty.vec_type(4),
+                    ""
+                ));
+                let v2 = err!(self.builder.build_select(apply_min_clamp_v2, min, v2, ""))
                     .into_vector_value();
-                let v2 = self
-                    .builder
-                    .build_select(apply_max_clamp_v2, max, v2, "")
+                let v2 = err!(self.builder.build_select(apply_max_clamp_v2, max, v2, ""))
                     .into_vector_value();
-                let v2 =
-                    self.builder
-                        .build_int_truncate(v2, self.intrinsics.i16_ty.vec_type(4), "");
-                let res = self.builder.build_shuffle_vector(
+                let v2 = err!(self.builder.build_int_truncate(
+                    v2,
+                    self.intrinsics.i16_ty.vec_type(4),
+                    ""
+                ));
+                let res = err!(self.builder.build_shuffle_vector(
                     v1,
                     v2,
                     VectorType::const_vector(&[
@@ -7067,13 +7451,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[7],
                     ]),
                     "",
-                );
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                ));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4TruncSatF32x4S => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let v = v.into_int_value();
                 let res = self.trunc_sat_into_int(
                     self.intrinsics.f32x4_ty,
@@ -7083,12 +7469,12 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     std::i32::MIN as u64,
                     std::i32::MAX as u64,
                     v,
-                );
+                )?;
                 self.state.push1(res);
             }
             Operator::I32x4TruncSatF32x4U => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let v = v.into_int_value();
                 let res = self.trunc_sat_into_int(
                     self.intrinsics.f32x4_ty,
@@ -7098,7 +7484,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     std::u32::MIN as u64,
                     std::u32::MAX as u64,
                     v,
-                );
+                )?;
                 self.state.push1(res);
             }
             Operator::I32x4TruncSatF64x2SZero | Operator::I32x4TruncSatF64x2UZero => {
@@ -7114,7 +7500,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     _ => unreachable!("Unhandled internal variant"),
                 };
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let v = v.into_int_value();
                 let res = self.trunc_sat(
                     self.intrinsics.f64x2_ty,
@@ -7124,11 +7510,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     min,
                     max,
                     v,
-                );
+                )?;
 
                 let zero = self.intrinsics.i32_consts[0];
                 let zeros = VectorType::const_vector(&[zero; 2]);
-                let res = self.builder.build_shuffle_vector(
+                let res = err!(self.builder.build_shuffle_vector(
                     res,
                     zeros,
                     VectorType::const_vector(&[
@@ -7138,13 +7524,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[3],
                     ]),
                     "",
-                );
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                ));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             // Operator::I64x2TruncSatF64x2S => {
             //     let (v, i) = self.state.pop1_extra()?;
-            //     let v = self.apply_pending_canonicalization(v, i);
+            //     let v = self.apply_pending_canonicalization(v, i)?;
             //     let v = v.into_int_value();
             //     let res = self.trunc_sat_into_int(
             //         self.intrinsics.f64x2_ty,
@@ -7154,12 +7542,12 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             //         std::i64::MIN as u64,
             //         std::i64::MAX as u64,
             //         v,
-            //     );
+            //     )?;
             //     self.state.push1(res);
             // }
             // Operator::I64x2TruncSatF64x2U => {
             //     let (v, i) = self.state.pop1_extra()?;
-            //     let v = self.apply_pending_canonicalization(v, i);
+            //     let v = self.apply_pending_canonicalization(v, i)?;
             //     let v = v.into_int_value();
             //     let res = self.trunc_sat_into_int(
             //         self.intrinsics.f64x2_ty,
@@ -7169,7 +7557,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             //         std::u64::MIN,
             //         std::u64::MAX,
             //         v,
-            //     );
+            //     )?;
             //     self.state.push1(res);
             // }
             Operator::I32TruncF32S => {
@@ -7178,10 +7566,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0xcf000000, // -2147483600.0
                     0x4effffff, // 2147483500.0
                     v1,
-                );
-                let res = self
-                    .builder
-                    .build_float_to_signed_int(v1, self.intrinsics.i32_ty, "");
+                )?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_float_to_signed_int(v1, self.intrinsics.i32_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32TruncF64S => {
@@ -7190,15 +7579,16 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0xc1e00000001fffff, // -2147483648.9999995
                     0x41dfffffffffffff, // 2147483647.9999998
                     v1,
-                );
-                let res = self
-                    .builder
-                    .build_float_to_signed_int(v1, self.intrinsics.i32_ty, "");
+                )?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_float_to_signed_int(v1, self.intrinsics.i32_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32TruncSatF32S => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let v = v.into_float_value();
                 let res = self.trunc_sat_scalar(
                     self.intrinsics.i32_ty,
@@ -7207,12 +7597,12 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     std::i32::MIN as u32 as u64,
                     std::i32::MAX as u32 as u64,
                     v,
-                );
+                )?;
                 self.state.push1(res);
             }
             Operator::I32TruncSatF64S => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let v = v.into_float_value();
                 let res = self.trunc_sat_scalar(
                     self.intrinsics.i32_ty,
@@ -7221,7 +7611,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     std::i32::MIN as u64,
                     std::i32::MAX as u64,
                     v,
-                );
+                )?;
                 self.state.push1(res);
             }
             Operator::I64TruncF32S => {
@@ -7230,10 +7620,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0xdf000000, // -9223372000000000000.0
                     0x5effffff, // 9223371500000000000.0
                     v1,
-                );
-                let res = self
-                    .builder
-                    .build_float_to_signed_int(v1, self.intrinsics.i64_ty, "");
+                )?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_float_to_signed_int(v1, self.intrinsics.i64_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64TruncF64S => {
@@ -7242,15 +7633,16 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0xc3e0000000000000, // -9223372036854776000.0
                     0x43dfffffffffffff, // 9223372036854775000.0
                     v1,
-                );
-                let res = self
-                    .builder
-                    .build_float_to_signed_int(v1, self.intrinsics.i64_ty, "");
+                )?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_float_to_signed_int(v1, self.intrinsics.i64_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64TruncSatF32S => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let v = v.into_float_value();
                 let res = self.trunc_sat_scalar(
                     self.intrinsics.i64_ty,
@@ -7259,12 +7651,12 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     std::i64::MIN as u64,
                     std::i64::MAX as u64,
                     v,
-                );
+                )?;
                 self.state.push1(res);
             }
             Operator::I64TruncSatF64S => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let v = v.into_float_value();
                 let res = self.trunc_sat_scalar(
                     self.intrinsics.i64_ty,
@@ -7273,7 +7665,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     std::i64::MIN as u64,
                     std::i64::MAX as u64,
                     v,
-                );
+                )?;
                 self.state.push1(res);
             }
             Operator::I32TruncF32U => {
@@ -7282,10 +7674,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0xbf7fffff, // -0.99999994
                     0x4f7fffff, // 4294967000.0
                     v1,
-                );
-                let res = self
-                    .builder
-                    .build_float_to_unsigned_int(v1, self.intrinsics.i32_ty, "");
+                )?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_float_to_unsigned_int(v1, self.intrinsics.i32_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32TruncF64U => {
@@ -7294,15 +7687,16 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0xbfefffffffffffff, // -0.9999999999999999
                     0x41efffffffffffff, // 4294967295.9999995
                     v1,
-                );
-                let res = self
-                    .builder
-                    .build_float_to_unsigned_int(v1, self.intrinsics.i32_ty, "");
+                )?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_float_to_unsigned_int(v1, self.intrinsics.i32_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32TruncSatF32U => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let v = v.into_float_value();
                 let res = self.trunc_sat_scalar(
                     self.intrinsics.i32_ty,
@@ -7311,12 +7705,12 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     std::u32::MIN as u64,
                     std::u32::MAX as u64,
                     v,
-                );
+                )?;
                 self.state.push1(res);
             }
             Operator::I32TruncSatF64U => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let v = v.into_float_value();
                 let res = self.trunc_sat_scalar(
                     self.intrinsics.i32_ty,
@@ -7325,7 +7719,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     std::u32::MIN as u64,
                     std::u32::MAX as u64,
                     v,
-                );
+                )?;
                 self.state.push1(res);
             }
             Operator::I64TruncF32U => {
@@ -7334,10 +7728,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0xbf7fffff, // -0.99999994
                     0x5f7fffff, // 18446743000000000000.0
                     v1,
-                );
-                let res = self
-                    .builder
-                    .build_float_to_unsigned_int(v1, self.intrinsics.i64_ty, "");
+                )?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_float_to_unsigned_int(v1, self.intrinsics.i64_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64TruncF64U => {
@@ -7346,15 +7741,16 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0xbfefffffffffffff, // -0.9999999999999999
                     0x43efffffffffffff, // 18446744073709550000.0
                     v1,
-                );
-                let res = self
-                    .builder
-                    .build_float_to_unsigned_int(v1, self.intrinsics.i64_ty, "");
+                )?;
+                let res =
+                    err!(self
+                        .builder
+                        .build_float_to_unsigned_int(v1, self.intrinsics.i64_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64TruncSatF32U => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let v = v.into_float_value();
                 let res = self.trunc_sat_scalar(
                     self.intrinsics.i64_ty,
@@ -7363,12 +7759,12 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     std::u64::MIN,
                     std::u64::MAX,
                     v,
-                );
+                )?;
                 self.state.push1(res);
             }
             Operator::I64TruncSatF64U => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let v = v.into_float_value();
                 let res = self.trunc_sat_scalar(
                     self.intrinsics.i64_ty,
@@ -7377,101 +7773,103 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     std::u64::MIN,
                     std::u64::MAX,
                     v,
-                );
+                )?;
                 self.state.push1(res);
             }
             Operator::F32DemoteF64 => {
                 let v = self.state.pop1()?;
                 let v = v.into_float_value();
-                let res = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.fptrunc_f64,
-                        &[
-                            v.into(),
-                            self.intrinsics.fp_rounding_md,
-                            self.intrinsics.fp_exception_md,
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.fptrunc_f64,
+                    &[
+                        v.into(),
+                        self.intrinsics.fp_rounding_md,
+                        self.intrinsics.fp_exception_md,
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 self.state.push1_extra(res, ExtraInfo::pending_f32_nan());
             }
             Operator::F64PromoteF32 => {
                 let v = self.state.pop1()?;
                 let v = v.into_float_value();
-                let res = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.fpext_f32,
-                        &[v.into(), self.intrinsics.fp_exception_md],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                let res = err!(self.builder.build_call(
+                    self.intrinsics.fpext_f32,
+                    &[v.into(), self.intrinsics.fp_exception_md],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 self.state.push1_extra(res, ExtraInfo::pending_f64_nan());
             }
             Operator::F32ConvertI32S | Operator::F32ConvertI64S => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let v = v.into_int_value();
-                let res = self
-                    .builder
-                    .build_signed_int_to_float(v, self.intrinsics.f32_ty, "");
+                let res =
+                    err!(self
+                        .builder
+                        .build_signed_int_to_float(v, self.intrinsics.f32_ty, ""));
                 self.state.push1(res);
             }
             Operator::F64ConvertI32S | Operator::F64ConvertI64S => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let v = v.into_int_value();
-                let res = self
-                    .builder
-                    .build_signed_int_to_float(v, self.intrinsics.f64_ty, "");
+                let res =
+                    err!(self
+                        .builder
+                        .build_signed_int_to_float(v, self.intrinsics.f64_ty, ""));
                 self.state.push1(res);
             }
             Operator::F32ConvertI32U | Operator::F32ConvertI64U => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let v = v.into_int_value();
-                let res = self
-                    .builder
-                    .build_unsigned_int_to_float(v, self.intrinsics.f32_ty, "");
+                let res =
+                    err!(self
+                        .builder
+                        .build_unsigned_int_to_float(v, self.intrinsics.f32_ty, ""));
                 self.state.push1(res);
             }
             Operator::F64ConvertI32U | Operator::F64ConvertI64U => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let v = v.into_int_value();
-                let res = self
-                    .builder
-                    .build_unsigned_int_to_float(v, self.intrinsics.f64_ty, "");
+                let res =
+                    err!(self
+                        .builder
+                        .build_unsigned_int_to_float(v, self.intrinsics.f64_ty, ""));
                 self.state.push1(res);
             }
             Operator::F32x4ConvertI32x4S => {
                 let v = self.state.pop1()?;
-                let v = self
-                    .builder
-                    .build_bitcast(v, self.intrinsics.i32x4_ty, "")
+                let v = err!(self.builder.build_bit_cast(v, self.intrinsics.i32x4_ty, ""))
                     .into_vector_value();
-                let res = self
+                let res =
+                    err!(self
+                        .builder
+                        .build_signed_int_to_float(v, self.intrinsics.f32x4_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_signed_int_to_float(v, self.intrinsics.f32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F32x4ConvertI32x4U => {
                 let v = self.state.pop1()?;
-                let v = self
-                    .builder
-                    .build_bitcast(v, self.intrinsics.i32x4_ty, "")
+                let v = err!(self.builder.build_bit_cast(v, self.intrinsics.i32x4_ty, ""))
                     .into_vector_value();
-                let res = self
+                let res =
+                    err!(self
+                        .builder
+                        .build_unsigned_int_to_float(v, self.intrinsics.f32x4_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_unsigned_int_to_float(v, self.intrinsics.f32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F64x2ConvertLowI32x4S | Operator::F64x2ConvertLowI32x4U => {
@@ -7485,8 +7883,8 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     _ => unreachable!("Unhandled inner case"),
                 };
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i32x4(v, i);
-                let low = self.builder.build_shuffle_vector(
+                let (v, _) = self.v128_into_i32x4(v, i)?;
+                let low = err!(self.builder.build_shuffle_vector(
                     v,
                     v.get_type().get_undef(),
                     VectorType::const_vector(&[
@@ -7494,18 +7892,21 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[1],
                     ]),
                     "",
-                );
-                let res = extend(self, low);
-                let res = self
+                ));
+                let res = err!(extend(self, low));
+                let res =
+                    err!(self
+                        .builder
+                        .build_signed_int_to_float(res, self.intrinsics.f64x2_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_signed_int_to_float(res, self.intrinsics.f64x2_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::F64x2PromoteLowF32x4 => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_f32x4(v, i);
-                let low = self.builder.build_shuffle_vector(
+                let (v, _) = self.v128_into_f32x4(v, i)?;
+                let low = err!(self.builder.build_shuffle_vector(
                     v,
                     v.get_type().get_undef(),
                     VectorType::const_vector(&[
@@ -7513,20 +7914,22 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[1],
                     ]),
                     "",
-                );
-                let res = self
+                ));
+                let res = err!(self
                     .builder
-                    .build_float_ext(low, self.intrinsics.f64x2_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_float_ext(low, self.intrinsics.f64x2_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1_extra(res, ExtraInfo::pending_f64_nan());
             }
             Operator::F32x4DemoteF64x2Zero => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_f64x2(v, i);
+                let (v, _) = self.v128_into_f64x2(v, i)?;
                 let f32x2_ty = self.intrinsics.f32_ty.vec_type(2);
-                let res = self.builder.build_float_trunc(v, f32x2_ty, "");
+                let res = err!(self.builder.build_float_trunc(v, f32x2_ty, ""));
                 let zeros = f32x2_ty.const_zero();
-                let res = self.builder.build_shuffle_vector(
+                let res = err!(self.builder.build_shuffle_vector(
                     res,
                     zeros,
                     VectorType::const_vector(&[
@@ -7536,54 +7939,56 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_consts[3],
                     ]),
                     "",
-                );
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                ));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1_extra(res, ExtraInfo::pending_f32_nan());
             }
             // Operator::F64x2ConvertI64x2S => {
             //     let v = self.state.pop1()?;
             //     let v = self
             //         .builder
-            //         .build_bitcast(v, self.intrinsics.i64x2_ty, "")
+            //         .build_bit_cast(v, self.intrinsics.i64x2_ty, "")
             //         .into_vector_value();
             //     let res = self
             //         .builder
             //         .build_signed_int_to_float(v, self.intrinsics.f64x2_ty, "");
-            //     let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+            //     let res = err!(self.builder.build_bit_cast(res, self.intrinsics.i128_ty, ""));
             //     self.state.push1(res);
             // }
             // Operator::F64x2ConvertI64x2U => {
             //     let v = self.state.pop1()?;
             //     let v = self
             //         .builder
-            //         .build_bitcast(v, self.intrinsics.i64x2_ty, "")
+            //         .build_bit_cast(v, self.intrinsics.i64x2_ty, "")
             //         .into_vector_value();
             //     let res = self
             //         .builder
             //         .build_unsigned_int_to_float(v, self.intrinsics.f64x2_ty, "");
-            //     let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+            //     let res = err!(self.builder.build_bit_cast(res, self.intrinsics.i128_ty, ""));
             //     self.state.push1(res);
             // }
             Operator::I32ReinterpretF32 => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
-                let ret = self.builder.build_bitcast(v, self.intrinsics.i32_ty, "");
+                let v = self.apply_pending_canonicalization(v, i)?;
+                let ret = err!(self.builder.build_bit_cast(v, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(ret, ExtraInfo::arithmetic_f32());
             }
             Operator::I64ReinterpretF64 => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
-                let ret = self.builder.build_bitcast(v, self.intrinsics.i64_ty, "");
+                let v = self.apply_pending_canonicalization(v, i)?;
+                let ret = err!(self.builder.build_bit_cast(v, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(ret, ExtraInfo::arithmetic_f64());
             }
             Operator::F32ReinterpretI32 => {
                 let (v, i) = self.state.pop1_extra()?;
-                let ret = self.builder.build_bitcast(v, self.intrinsics.f32_ty, "");
+                let ret = err!(self.builder.build_bit_cast(v, self.intrinsics.f32_ty, ""));
                 self.state.push1_extra(ret, i);
             }
             Operator::F64ReinterpretI64 => {
                 let (v, i) = self.state.pop1_extra()?;
-                let ret = self.builder.build_bitcast(v, self.intrinsics.f64_ty, "");
+                let ret = err!(self.builder.build_bit_cast(v, self.intrinsics.f64_ty, ""));
                 self.state.push1_extra(ret, i);
             }
 
@@ -7594,51 +7999,61 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             Operator::I32Extend8S => {
                 let value = self.state.pop1()?.into_int_value();
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i8_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i8_ty, ""));
                 let extended_value =
-                    self.builder
-                        .build_int_s_extend(narrow_value, self.intrinsics.i32_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_s_extend(narrow_value, self.intrinsics.i32_ty, ""));
                 self.state.push1(extended_value);
             }
             Operator::I32Extend16S => {
                 let value = self.state.pop1()?.into_int_value();
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i16_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i16_ty, ""));
                 let extended_value =
-                    self.builder
-                        .build_int_s_extend(narrow_value, self.intrinsics.i32_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_s_extend(narrow_value, self.intrinsics.i32_ty, ""));
                 self.state.push1(extended_value);
             }
             Operator::I64Extend8S => {
                 let value = self.state.pop1()?.into_int_value();
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i8_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i8_ty, ""));
                 let extended_value =
-                    self.builder
-                        .build_int_s_extend(narrow_value, self.intrinsics.i64_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_s_extend(narrow_value, self.intrinsics.i64_ty, ""));
                 self.state.push1(extended_value);
             }
             Operator::I64Extend16S => {
                 let value = self.state.pop1()?.into_int_value();
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i16_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i16_ty, ""));
                 let extended_value =
-                    self.builder
-                        .build_int_s_extend(narrow_value, self.intrinsics.i64_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_s_extend(narrow_value, self.intrinsics.i64_ty, ""));
                 self.state.push1(extended_value);
             }
             Operator::I64Extend32S => {
                 let value = self.state.pop1()?.into_int_value();
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i32_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i32_ty, ""));
                 let extended_value =
-                    self.builder
-                        .build_int_s_extend(narrow_value, self.intrinsics.i64_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_s_extend(narrow_value, self.intrinsics.i64_ty, ""));
                 self.state.push1(extended_value);
             }
 
@@ -7652,13 +8067,14 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                let result = self
-                    .builder
-                    .build_load(self.intrinsics.i32_ty, effective_address, "");
+                let result =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i32_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
@@ -7673,13 +8089,14 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                let result = self
-                    .builder
-                    .build_load(self.intrinsics.i64_ty, effective_address, "");
+                let result =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i64_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
@@ -7694,13 +8111,14 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.f32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                let result = self
-                    .builder
-                    .build_load(self.intrinsics.f32_ty, effective_address, "");
+                let result =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.f32_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
@@ -7715,13 +8133,14 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.f64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                let result = self
-                    .builder
-                    .build_load(self.intrinsics.f64_ty, effective_address, "");
+                let result =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.f64_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
@@ -7736,13 +8155,14 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i128_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     16,
                 )?;
                 let result =
-                    self.builder
-                        .build_load(self.intrinsics.i128_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i128_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
@@ -7753,19 +8173,20 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::V128Load8Lane { ref memarg, lane } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _i) = self.v128_into_i8x16(v, i);
+                let (v, _i) = self.v128_into_i8x16(v, i)?;
                 let offset = self.state.pop1()?.into_int_value();
                 let memory_index = MemoryIndex::from_u32(memarg.memory);
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                let element = self
-                    .builder
-                    .build_load(self.intrinsics.i8_ty, effective_address, "");
+                let element =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i8_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
@@ -7773,25 +8194,28 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     element.as_instruction_value().unwrap(),
                 )?;
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let res = self.builder.build_insert_element(v, element, idx, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self.builder.build_insert_element(v, element, idx, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::V128Load16Lane { ref memarg, lane } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, i) = self.v128_into_i16x8(v, i);
+                let (v, i) = self.v128_into_i16x8(v, i)?;
                 let offset = self.state.pop1()?.into_int_value();
                 let memory_index = MemoryIndex::from_u32(memarg.memory);
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
                 let element =
-                    self.builder
-                        .build_load(self.intrinsics.i16_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i16_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
@@ -7799,25 +8223,28 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     element.as_instruction_value().unwrap(),
                 )?;
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let res = self.builder.build_insert_element(v, element, idx, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self.builder.build_insert_element(v, element, idx, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1_extra(res, i);
             }
             Operator::V128Load32Lane { ref memarg, lane } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, i) = self.v128_into_i32x4(v, i);
+                let (v, i) = self.v128_into_i32x4(v, i)?;
                 let offset = self.state.pop1()?.into_int_value();
                 let memory_index = MemoryIndex::from_u32(memarg.memory);
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
                 let element =
-                    self.builder
-                        .build_load(self.intrinsics.i32_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i32_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
@@ -7825,25 +8252,28 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     element.as_instruction_value().unwrap(),
                 )?;
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let res = self.builder.build_insert_element(v, element, idx, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self.builder.build_insert_element(v, element, idx, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1_extra(res, i);
             }
             Operator::V128Load64Lane { ref memarg, lane } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, i) = self.v128_into_i64x2(v, i);
+                let (v, i) = self.v128_into_i64x2(v, i)?;
                 let offset = self.state.pop1()?.into_int_value();
                 let memory_index = MemoryIndex::from_u32(memarg.memory);
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
                 let element =
-                    self.builder
-                        .build_load(self.intrinsics.i64_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i64_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
@@ -7851,8 +8281,10 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     element.as_instruction_value().unwrap(),
                 )?;
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let res = self.builder.build_insert_element(v, element, idx, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self.builder.build_insert_element(v, element, idx, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1_extra(res, i);
             }
 
@@ -7863,20 +8295,21 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
                 let dead_load =
-                    self.builder
-                        .build_load(self.intrinsics.i32_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i32_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     dead_load.as_instruction_value().unwrap(),
                 )?;
-                let store = self.builder.build_store(effective_address, value);
+                let store = err!(self.builder.build_store(effective_address, value));
                 self.annotate_user_memaccess(memory_index, memarg, 1, store)?;
             }
             Operator::I64Store { ref memarg } => {
@@ -7886,110 +8319,115 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
                 let dead_load =
-                    self.builder
-                        .build_load(self.intrinsics.i64_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i64_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     dead_load.as_instruction_value().unwrap(),
                 )?;
-                let store = self.builder.build_store(effective_address, value);
+                let store = err!(self.builder.build_store(effective_address, value));
                 self.annotate_user_memaccess(memory_index, memarg, 1, store)?;
             }
             Operator::F32Store { ref memarg } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let offset = self.state.pop1()?.into_int_value();
                 let memory_index = MemoryIndex::from_u32(0);
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.f32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
                 let dead_load =
-                    self.builder
-                        .build_load(self.intrinsics.f32_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.f32_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     dead_load.as_instruction_value().unwrap(),
                 )?;
-                let store = self.builder.build_store(effective_address, v);
+                let store = err!(self.builder.build_store(effective_address, v));
                 self.annotate_user_memaccess(memory_index, memarg, 1, store)?;
             }
             Operator::F64Store { ref memarg } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let offset = self.state.pop1()?.into_int_value();
                 let memory_index = MemoryIndex::from_u32(0);
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.f64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
                 let dead_load =
-                    self.builder
-                        .build_load(self.intrinsics.f64_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.f64_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     dead_load.as_instruction_value().unwrap(),
                 )?;
-                let store = self.builder.build_store(effective_address, v);
+                let store = err!(self.builder.build_store(effective_address, v));
                 self.annotate_user_memaccess(memory_index, memarg, 1, store)?;
             }
             Operator::V128Store { ref memarg } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i);
+                let v = self.apply_pending_canonicalization(v, i)?;
                 let offset = self.state.pop1()?.into_int_value();
                 let memory_index = MemoryIndex::from_u32(0);
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i128_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     16,
                 )?;
                 let dead_load =
-                    self.builder
-                        .build_load(self.intrinsics.i128_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i128_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     dead_load.as_instruction_value().unwrap(),
                 )?;
-                let store = self.builder.build_store(effective_address, v);
+                let store = err!(self.builder.build_store(effective_address, v));
                 self.annotate_user_memaccess(memory_index, memarg, 1, store)?;
             }
             Operator::V128Store8Lane { ref memarg, lane } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _i) = self.v128_into_i8x16(v, i);
+                let (v, _i) = self.v128_into_i8x16(v, i)?;
                 let offset = self.state.pop1()?.into_int_value();
                 let memory_index = MemoryIndex::from_u32(memarg.memory);
 
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
                 let dead_load =
-                    self.builder
-                        .build_load(self.intrinsics.i8_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i8_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
@@ -7997,26 +8435,27 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     dead_load.as_instruction_value().unwrap(),
                 )?;
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let val = self.builder.build_extract_element(v, idx, "");
-                let store = self.builder.build_store(effective_address, val);
+                let val = err!(self.builder.build_extract_element(v, idx, ""));
+                let store = err!(self.builder.build_store(effective_address, val));
                 self.annotate_user_memaccess(memory_index, memarg, 1, store)?;
             }
             Operator::V128Store16Lane { ref memarg, lane } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _i) = self.v128_into_i16x8(v, i);
+                let (v, _i) = self.v128_into_i16x8(v, i)?;
                 let offset = self.state.pop1()?.into_int_value();
                 let memory_index = MemoryIndex::from_u32(memarg.memory);
 
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
                 let dead_load =
-                    self.builder
-                        .build_load(self.intrinsics.i16_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i16_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
@@ -8024,26 +8463,27 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     dead_load.as_instruction_value().unwrap(),
                 )?;
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let val = self.builder.build_extract_element(v, idx, "");
-                let store = self.builder.build_store(effective_address, val);
+                let val = err!(self.builder.build_extract_element(v, idx, ""));
+                let store = err!(self.builder.build_store(effective_address, val));
                 self.annotate_user_memaccess(memory_index, memarg, 1, store)?;
             }
             Operator::V128Store32Lane { ref memarg, lane } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _i) = self.v128_into_i32x4(v, i);
+                let (v, _i) = self.v128_into_i32x4(v, i)?;
                 let offset = self.state.pop1()?.into_int_value();
                 let memory_index = MemoryIndex::from_u32(memarg.memory);
 
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
                 let dead_load =
-                    self.builder
-                        .build_load(self.intrinsics.i32_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i32_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
@@ -8051,26 +8491,27 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     dead_load.as_instruction_value().unwrap(),
                 )?;
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let val = self.builder.build_extract_element(v, idx, "");
-                let store = self.builder.build_store(effective_address, val);
+                let val = err!(self.builder.build_extract_element(v, idx, ""));
+                let store = err!(self.builder.build_store(effective_address, val));
                 self.annotate_user_memaccess(memory_index, memarg, 1, store)?;
             }
             Operator::V128Store64Lane { ref memarg, lane } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _i) = self.v128_into_i64x2(v, i);
+                let (v, _i) = self.v128_into_i64x2(v, i)?;
                 let offset = self.state.pop1()?.into_int_value();
                 let memory_index = MemoryIndex::from_u32(memarg.memory);
 
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
                 let dead_load =
-                    self.builder
-                        .build_load(self.intrinsics.i64_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i64_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
@@ -8078,8 +8519,8 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     dead_load.as_instruction_value().unwrap(),
                 )?;
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let val = self.builder.build_extract_element(v, idx, "");
-                let store = self.builder.build_store(effective_address, val);
+                let val = err!(self.builder.build_extract_element(v, idx, ""));
+                let store = err!(self.builder.build_store(effective_address, val));
                 self.annotate_user_memaccess(memory_index, memarg, 1, store)?;
             }
             Operator::I32Load8S { ref memarg } => {
@@ -8088,24 +8529,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
                 let narrow_result =
-                    self.builder
-                        .build_load(self.intrinsics.i8_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i8_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     narrow_result.as_instruction_value().unwrap(),
                 )?;
-                let result = self.builder.build_int_s_extend(
+                let result = err!(self.builder.build_int_s_extend(
                     narrow_result.into_int_value(),
                     self.intrinsics.i32_ty,
                     "",
-                );
+                ));
                 self.state.push1(result);
             }
             Operator::I32Load16S { ref memarg } => {
@@ -8114,24 +8556,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
                 let narrow_result =
-                    self.builder
-                        .build_load(self.intrinsics.i16_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i16_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     narrow_result.as_instruction_value().unwrap(),
                 )?;
-                let result = self.builder.build_int_s_extend(
+                let result = err!(self.builder.build_int_s_extend(
                     narrow_result.into_int_value(),
                     self.intrinsics.i32_ty,
                     "",
-                );
+                ));
                 self.state.push1(result);
             }
             Operator::I64Load8S { ref memarg } => {
@@ -8140,13 +8583,14 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                let narrow_result = self
-                    .builder
-                    .build_load(self.intrinsics.i8_ty, effective_address, "")
+                let narrow_result =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i8_ty, effective_address, ""))
                     .into_int_value();
                 self.annotate_user_memaccess(
                     memory_index,
@@ -8154,9 +8598,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     1,
                     narrow_result.as_instruction_value().unwrap(),
                 )?;
-                let result =
-                    self.builder
-                        .build_int_s_extend(narrow_result, self.intrinsics.i64_ty, "");
+                let result = err!(self.builder.build_int_s_extend(
+                    narrow_result,
+                    self.intrinsics.i64_ty,
+                    ""
+                ));
                 self.state.push1(result);
             }
             Operator::I64Load16S { ref memarg } => {
@@ -8165,13 +8611,14 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                let narrow_result = self
-                    .builder
-                    .build_load(self.intrinsics.i16_ty, effective_address, "")
+                let narrow_result =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i16_ty, effective_address, ""))
                     .into_int_value();
                 self.annotate_user_memaccess(
                     memory_index,
@@ -8179,9 +8626,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     1,
                     narrow_result.as_instruction_value().unwrap(),
                 )?;
-                let result =
-                    self.builder
-                        .build_int_s_extend(narrow_result, self.intrinsics.i64_ty, "");
+                let result = err!(self.builder.build_int_s_extend(
+                    narrow_result,
+                    self.intrinsics.i64_ty,
+                    ""
+                ));
                 self.state.push1(result);
             }
             Operator::I64Load32S { ref memarg } => {
@@ -8190,24 +8639,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
                 let narrow_result =
-                    self.builder
-                        .build_load(self.intrinsics.i32_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i32_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     narrow_result.as_instruction_value().unwrap(),
                 )?;
-                let result = self.builder.build_int_s_extend(
+                let result = err!(self.builder.build_int_s_extend(
                     narrow_result.into_int_value(),
                     self.intrinsics.i64_ty,
                     "",
-                );
+                ));
                 self.state.push1(result);
             }
 
@@ -8217,24 +8667,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
                 let narrow_result =
-                    self.builder
-                        .build_load(self.intrinsics.i8_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i8_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     narrow_result.as_instruction_value().unwrap(),
                 )?;
-                let result = self.builder.build_int_z_extend(
+                let result = err!(self.builder.build_int_z_extend(
                     narrow_result.into_int_value(),
                     self.intrinsics.i32_ty,
                     "",
-                );
+                ));
                 self.state.push1_extra(result, ExtraInfo::arithmetic_f32());
             }
             Operator::I32Load16U { ref memarg } => {
@@ -8243,24 +8694,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
                 let narrow_result =
-                    self.builder
-                        .build_load(self.intrinsics.i16_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i16_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     narrow_result.as_instruction_value().unwrap(),
                 )?;
-                let result = self.builder.build_int_z_extend(
+                let result = err!(self.builder.build_int_z_extend(
                     narrow_result.into_int_value(),
                     self.intrinsics.i32_ty,
                     "",
-                );
+                ));
                 self.state.push1_extra(result, ExtraInfo::arithmetic_f32());
             }
             Operator::I64Load8U { ref memarg } => {
@@ -8269,24 +8721,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
                 let narrow_result =
-                    self.builder
-                        .build_load(self.intrinsics.i8_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i8_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     narrow_result.as_instruction_value().unwrap(),
                 )?;
-                let result = self.builder.build_int_z_extend(
+                let result = err!(self.builder.build_int_z_extend(
                     narrow_result.into_int_value(),
                     self.intrinsics.i64_ty,
                     "",
-                );
+                ));
                 self.state.push1_extra(result, ExtraInfo::arithmetic_f64());
             }
             Operator::I64Load16U { ref memarg } => {
@@ -8295,24 +8748,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
                 let narrow_result =
-                    self.builder
-                        .build_load(self.intrinsics.i16_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i16_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     narrow_result.as_instruction_value().unwrap(),
                 )?;
-                let result = self.builder.build_int_z_extend(
+                let result = err!(self.builder.build_int_z_extend(
                     narrow_result.into_int_value(),
                     self.intrinsics.i64_ty,
                     "",
-                );
+                ));
                 self.state.push1_extra(result, ExtraInfo::arithmetic_f64());
             }
             Operator::I64Load32U { ref memarg } => {
@@ -8321,24 +8775,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
                 let narrow_result =
-                    self.builder
-                        .build_load(self.intrinsics.i32_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i32_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     narrow_result.as_instruction_value().unwrap(),
                 )?;
-                let result = self.builder.build_int_z_extend(
+                let result = err!(self.builder.build_int_z_extend(
                     narrow_result.into_int_value(),
                     self.intrinsics.i64_ty,
                     "",
-                );
+                ));
                 self.state.push1_extra(result, ExtraInfo::arithmetic_f64());
             }
 
@@ -8349,13 +8804,14 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
                 let dead_load =
-                    self.builder
-                        .build_load(self.intrinsics.i8_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i8_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
@@ -8363,9 +8819,10 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     dead_load.as_instruction_value().unwrap(),
                 )?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i8_ty, "");
-                let store = self.builder.build_store(effective_address, narrow_value);
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i8_ty, ""));
+                let store = err!(self.builder.build_store(effective_address, narrow_value));
                 self.annotate_user_memaccess(memory_index, memarg, 1, store)?;
             }
             Operator::I32Store16 { ref memarg } | Operator::I64Store16 { ref memarg } => {
@@ -8375,13 +8832,14 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
                 let dead_load =
-                    self.builder
-                        .build_load(self.intrinsics.i16_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i16_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
@@ -8389,9 +8847,10 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     dead_load.as_instruction_value().unwrap(),
                 )?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i16_ty, "");
-                let store = self.builder.build_store(effective_address, narrow_value);
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i16_ty, ""));
+                let store = err!(self.builder.build_store(effective_address, narrow_value));
                 self.annotate_user_memaccess(memory_index, memarg, 1, store)?;
             }
             Operator::I64Store32 { ref memarg } => {
@@ -8401,13 +8860,14 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
                 let dead_load =
-                    self.builder
-                        .build_load(self.intrinsics.i32_ty, effective_address, "");
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i32_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
@@ -8415,58 +8875,67 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     dead_load.as_instruction_value().unwrap(),
                 )?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i32_ty, "");
-                let store = self.builder.build_store(effective_address, narrow_value);
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i32_ty, ""));
+                let store = err!(self.builder.build_store(effective_address, narrow_value));
                 self.annotate_user_memaccess(memory_index, memarg, 1, store)?;
             }
             Operator::I8x16Neg => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i8x16(v, i);
-                let res = self.builder.build_int_sub(v.get_type().const_zero(), v, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let (v, _) = self.v128_into_i8x16(v, i)?;
+                let res = err!(self.builder.build_int_sub(v.get_type().const_zero(), v, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8Neg => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i16x8(v, i);
-                let res = self.builder.build_int_sub(v.get_type().const_zero(), v, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let (v, _) = self.v128_into_i16x8(v, i)?;
+                let res = err!(self.builder.build_int_sub(v.get_type().const_zero(), v, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4Neg => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i32x4(v, i);
-                let res = self.builder.build_int_sub(v.get_type().const_zero(), v, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let (v, _) = self.v128_into_i32x4(v, i)?;
+                let res = err!(self.builder.build_int_sub(v.get_type().const_zero(), v, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I64x2Neg => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i64x2(v, i);
-                let res = self.builder.build_int_sub(v.get_type().const_zero(), v, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let (v, _) = self.v128_into_i64x2(v, i)?;
+                let res = err!(self.builder.build_int_sub(v.get_type().const_zero(), v, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::V128Not => {
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i).into_int_value();
-                let res = self.builder.build_not(v, "");
+                let v = self.apply_pending_canonicalization(v, i)?.into_int_value();
+                let res = err!(self.builder.build_not(v, ""));
                 self.state.push1(res);
             }
             Operator::V128AnyTrue => {
                 // | Operator::I64x2AnyTrue
                 // Skip canonicalization, it never changes non-zero values to zero or vice versa.
                 let v = self.state.pop1()?.into_int_value();
-                let res = self.builder.build_int_compare(
+                let res = err!(self.builder.build_int_compare(
                     IntPredicate::NE,
                     v,
                     v.get_type().const_zero(),
                     "",
-                );
-                let res = self
+                ));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(res, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(res, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(
                     res,
                     ExtraInfo::arithmetic_f32() | ExtraInfo::arithmetic_f64(),
@@ -8484,31 +8953,26 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     _ => unreachable!(),
                 };
                 let (v, i) = self.state.pop1_extra()?;
-                let v = self.apply_pending_canonicalization(v, i).into_int_value();
+                let v = self.apply_pending_canonicalization(v, i)?.into_int_value();
                 let lane_int_ty = self.context.custom_width_int_type(vec_ty.get_size());
-                let vec = self
-                    .builder
-                    .build_bitcast(v, vec_ty, "vec")
-                    .into_vector_value();
-                let mask = self.builder.build_int_compare(
+                let vec = err!(self.builder.build_bit_cast(v, vec_ty, "vec")).into_vector_value();
+                let mask = err!(self.builder.build_int_compare(
                     IntPredicate::NE,
                     vec,
                     vec_ty.const_zero(),
                     "mask",
-                );
-                let cmask = self
-                    .builder
-                    .build_bitcast(mask, lane_int_ty, "cmask")
-                    .into_int_value();
-                let res = self.builder.build_int_compare(
+                ));
+                let cmask =
+                    err!(self.builder.build_bit_cast(mask, lane_int_ty, "cmask")).into_int_value();
+                let res = err!(self.builder.build_int_compare(
                     IntPredicate::EQ,
                     cmask,
                     lane_int_ty.const_int(std::u64::MAX, true),
                     "",
-                );
-                let res = self
+                ));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(res, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(res, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(
                     res,
                     ExtraInfo::arithmetic_f32() | ExtraInfo::arithmetic_f64(),
@@ -8516,146 +8980,144 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::I8x16ExtractLaneS { lane } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i8x16(v, i);
+                let (v, _) = self.v128_into_i8x16(v, i)?;
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let res = self
+                let res = err!(self.builder.build_extract_element(v, idx, "")).into_int_value();
+                let res = err!(self
                     .builder
-                    .build_extract_element(v, idx, "")
-                    .into_int_value();
-                let res = self
-                    .builder
-                    .build_int_s_extend(res, self.intrinsics.i32_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i32_ty, ""));
                 self.state.push1(res);
             }
             Operator::I8x16ExtractLaneU { lane } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i8x16(v, i);
+                let (v, _) = self.v128_into_i8x16(v, i)?;
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let res = self
-                    .builder
-                    .build_extract_element(v, idx, "")
-                    .into_int_value();
-                let res = self
+                let res = err!(self.builder.build_extract_element(v, idx, "")).into_int_value();
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(res, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(res, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(res, ExtraInfo::arithmetic_f32());
             }
             Operator::I16x8ExtractLaneS { lane } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i16x8(v, i);
+                let (v, _) = self.v128_into_i16x8(v, i)?;
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let res = self
+                let res = err!(self.builder.build_extract_element(v, idx, "")).into_int_value();
+                let res = err!(self
                     .builder
-                    .build_extract_element(v, idx, "")
-                    .into_int_value();
-                let res = self
-                    .builder
-                    .build_int_s_extend(res, self.intrinsics.i32_ty, "");
+                    .build_int_s_extend(res, self.intrinsics.i32_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8ExtractLaneU { lane } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, _) = self.v128_into_i16x8(v, i);
+                let (v, _) = self.v128_into_i16x8(v, i)?;
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let res = self
-                    .builder
-                    .build_extract_element(v, idx, "")
-                    .into_int_value();
-                let res = self
+                let res = err!(self.builder.build_extract_element(v, idx, "")).into_int_value();
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(res, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(res, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(res, ExtraInfo::arithmetic_f32());
             }
             Operator::I32x4ExtractLane { lane } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, i) = self.v128_into_i32x4(v, i);
+                let (v, i) = self.v128_into_i32x4(v, i)?;
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let res = self.builder.build_extract_element(v, idx, "");
+                let res = err!(self.builder.build_extract_element(v, idx, ""));
                 self.state.push1_extra(res, i);
             }
             Operator::I64x2ExtractLane { lane } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, i) = self.v128_into_i64x2(v, i);
+                let (v, i) = self.v128_into_i64x2(v, i)?;
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let res = self.builder.build_extract_element(v, idx, "");
+                let res = err!(self.builder.build_extract_element(v, idx, ""));
                 self.state.push1_extra(res, i);
             }
             Operator::F32x4ExtractLane { lane } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, i) = self.v128_into_f32x4(v, i);
+                let (v, i) = self.v128_into_f32x4(v, i)?;
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let res = self.builder.build_extract_element(v, idx, "");
+                let res = err!(self.builder.build_extract_element(v, idx, ""));
                 self.state.push1_extra(res, i);
             }
             Operator::F64x2ExtractLane { lane } => {
                 let (v, i) = self.state.pop1_extra()?;
-                let (v, i) = self.v128_into_f64x2(v, i);
+                let (v, i) = self.v128_into_f64x2(v, i)?;
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let res = self.builder.build_extract_element(v, idx, "");
+                let res = err!(self.builder.build_extract_element(v, idx, ""));
                 self.state.push1_extra(res, i);
             }
             Operator::I8x16ReplaceLane { lane } => {
                 let ((v1, i1), (v2, _)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i8x16(v1, i1);
+                let (v1, _) = self.v128_into_i8x16(v1, i1)?;
                 let v2 = v2.into_int_value();
-                let v2 = self.builder.build_int_cast(v2, self.intrinsics.i8_ty, "");
+                let v2 = err!(self.builder.build_int_cast(v2, self.intrinsics.i8_ty, ""));
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let res = self.builder.build_insert_element(v1, v2, idx, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self.builder.build_insert_element(v1, v2, idx, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I16x8ReplaceLane { lane } => {
                 let ((v1, i1), (v2, _)) = self.state.pop2_extra()?;
-                let (v1, _) = self.v128_into_i16x8(v1, i1);
+                let (v1, _) = self.v128_into_i16x8(v1, i1)?;
                 let v2 = v2.into_int_value();
-                let v2 = self.builder.build_int_cast(v2, self.intrinsics.i16_ty, "");
+                let v2 = err!(self.builder.build_int_cast(v2, self.intrinsics.i16_ty, ""));
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let res = self.builder.build_insert_element(v1, v2, idx, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self.builder.build_insert_element(v1, v2, idx, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I32x4ReplaceLane { lane } => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, i1) = self.v128_into_i32x4(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let (v1, i1) = self.v128_into_i32x4(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let v2 = v2.into_int_value();
                 let i2 = i2.strip_pending();
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let res = self.builder.build_insert_element(v1, v2, idx, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self.builder.build_insert_element(v1, v2, idx, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state
                     .push1_extra(res, i1 & i2 & ExtraInfo::arithmetic_f32());
             }
             Operator::I64x2ReplaceLane { lane } => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, i1) = self.v128_into_i64x2(v1, i1);
-                let v2 = self.apply_pending_canonicalization(v2, i2);
+                let (v1, i1) = self.v128_into_i64x2(v1, i1)?;
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
                 let v2 = v2.into_int_value();
                 let i2 = i2.strip_pending();
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let res = self.builder.build_insert_element(v1, v2, idx, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self.builder.build_insert_element(v1, v2, idx, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state
                     .push1_extra(res, i1 & i2 & ExtraInfo::arithmetic_f64());
             }
             Operator::F32x4ReplaceLane { lane } => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, i1) = self.v128_into_f32x4(v1, i1);
+                let (v1, i1) = self.v128_into_f32x4(v1, i1)?;
                 let push_pending_f32_nan_to_result =
                     i1.has_pending_f32_nan() && i2.has_pending_f32_nan();
                 let (v1, v2) = if !push_pending_f32_nan_to_result {
                     (
-                        self.apply_pending_canonicalization(v1.as_basic_value_enum(), i1)
+                        self.apply_pending_canonicalization(v1.as_basic_value_enum(), i1)?
                             .into_vector_value(),
-                        self.apply_pending_canonicalization(v2.as_basic_value_enum(), i2)
+                        self.apply_pending_canonicalization(v2.as_basic_value_enum(), i2)?
                             .into_float_value(),
                     )
                 } else {
                     (v1, v2.into_float_value())
                 };
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let res = self.builder.build_insert_element(v1, v2, idx, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self.builder.build_insert_element(v1, v2, idx, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 let info = if push_pending_f32_nan_to_result {
                     ExtraInfo::pending_f32_nan()
                 } else {
@@ -8665,22 +9127,24 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::F64x2ReplaceLane { lane } => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let (v1, i1) = self.v128_into_f64x2(v1, i1);
+                let (v1, i1) = self.v128_into_f64x2(v1, i1)?;
                 let push_pending_f64_nan_to_result =
                     i1.has_pending_f64_nan() && i2.has_pending_f64_nan();
                 let (v1, v2) = if !push_pending_f64_nan_to_result {
                     (
-                        self.apply_pending_canonicalization(v1.as_basic_value_enum(), i1)
+                        self.apply_pending_canonicalization(v1.as_basic_value_enum(), i1)?
                             .into_vector_value(),
-                        self.apply_pending_canonicalization(v2.as_basic_value_enum(), i2)
+                        self.apply_pending_canonicalization(v2.as_basic_value_enum(), i2)?
                             .into_float_value(),
                     )
                 } else {
                     (v1, v2.into_float_value())
                 };
                 let idx = self.intrinsics.i32_ty.const_int(lane.into(), false);
-                let res = self.builder.build_insert_element(v1, v2, idx, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self.builder.build_insert_element(v1, v2, idx, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 let info = if push_pending_f64_nan_to_result {
                     ExtraInfo::pending_f64_nan()
                 } else {
@@ -8690,84 +9154,78 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::I8x16Swizzle => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v1 = self
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v1 = err!(self
                     .builder
-                    .build_bitcast(v1, self.intrinsics.i8x16_ty, "")
-                    .into_vector_value();
-                let v2 = self.apply_pending_canonicalization(v2, i2);
-                let v2 = self
+                    .build_bit_cast(v1, self.intrinsics.i8x16_ty, ""))
+                .into_vector_value();
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
+                let v2 = err!(self
                     .builder
-                    .build_bitcast(v2, self.intrinsics.i8x16_ty, "")
-                    .into_vector_value();
+                    .build_bit_cast(v2, self.intrinsics.i8x16_ty, ""))
+                .into_vector_value();
                 let lanes = self.intrinsics.i8_ty.const_int(16, false);
                 let lanes =
-                    self.splat_vector(lanes.as_basic_value_enum(), self.intrinsics.i8x16_ty);
+                    self.splat_vector(lanes.as_basic_value_enum(), self.intrinsics.i8x16_ty)?;
                 let mut res = self.intrinsics.i8x16_ty.get_undef();
-                let idx_out_of_range = self.builder.build_int_compare(
+                let idx_out_of_range = err!(self.builder.build_int_compare(
                     IntPredicate::UGE,
                     v2,
                     lanes,
                     "idx_out_of_range",
-                );
-                let idx_clamped = self
-                    .builder
-                    .build_select(
-                        idx_out_of_range,
-                        self.intrinsics.i8x16_ty.const_zero(),
-                        v2,
-                        "idx_clamped",
-                    )
-                    .into_vector_value();
+                ));
+                let idx_clamped = err!(self.builder.build_select(
+                    idx_out_of_range,
+                    self.intrinsics.i8x16_ty.const_zero(),
+                    v2,
+                    "idx_clamped",
+                ))
+                .into_vector_value();
                 for i in 0..16 {
-                    let idx = self
-                        .builder
-                        .build_extract_element(
-                            idx_clamped,
-                            self.intrinsics.i32_ty.const_int(i, false),
-                            "idx",
-                        )
-                        .into_int_value();
-                    let replace_with_zero = self
-                        .builder
-                        .build_extract_element(
-                            idx_out_of_range,
-                            self.intrinsics.i32_ty.const_int(i, false),
-                            "replace_with_zero",
-                        )
-                        .into_int_value();
-                    let elem = self
-                        .builder
-                        .build_extract_element(v1, idx, "elem")
-                        .into_int_value();
-                    let elem_or_zero = self.builder.build_select(
+                    let idx = err!(self.builder.build_extract_element(
+                        idx_clamped,
+                        self.intrinsics.i32_ty.const_int(i, false),
+                        "idx",
+                    ))
+                    .into_int_value();
+                    let replace_with_zero = err!(self.builder.build_extract_element(
+                        idx_out_of_range,
+                        self.intrinsics.i32_ty.const_int(i, false),
+                        "replace_with_zero",
+                    ))
+                    .into_int_value();
+                    let elem =
+                        err!(self.builder.build_extract_element(v1, idx, "elem")).into_int_value();
+                    let elem_or_zero = err!(self.builder.build_select(
                         replace_with_zero,
                         self.intrinsics.i8_zero,
                         elem,
                         "elem_or_zero",
-                    );
-                    res = self.builder.build_insert_element(
+                    ));
+                    res = err!(self.builder.build_insert_element(
                         res,
                         elem_or_zero,
                         self.intrinsics.i32_ty.const_int(i, false),
                         "",
-                    );
+                    ));
                 }
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::I8x16Shuffle { lanes } => {
                 let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
-                let v1 = self.apply_pending_canonicalization(v1, i1);
-                let v1 = self
+                let v1 = self.apply_pending_canonicalization(v1, i1)?;
+                let v1 = err!(self
                     .builder
-                    .build_bitcast(v1, self.intrinsics.i8x16_ty, "")
-                    .into_vector_value();
-                let v2 = self.apply_pending_canonicalization(v2, i2);
-                let v2 = self
+                    .build_bit_cast(v1, self.intrinsics.i8x16_ty, ""))
+                .into_vector_value();
+                let v2 = self.apply_pending_canonicalization(v2, i2)?;
+                let v2 = err!(self
                     .builder
-                    .build_bitcast(v2, self.intrinsics.i8x16_ty, "")
-                    .into_vector_value();
+                    .build_bit_cast(v2, self.intrinsics.i8x16_ty, ""))
+                .into_vector_value();
                 let mask = VectorType::const_vector(
                     lanes
                         .iter()
@@ -8775,8 +9233,10 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         .collect::<Vec<IntValue>>()
                         .as_slice(),
                 );
-                let res = self.builder.build_shuffle_vector(v1, v2, mask, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = err!(self.builder.build_shuffle_vector(v1, v2, mask, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::V128Load8x8S { ref memarg } => {
@@ -8785,21 +9245,24 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                let v = self
+                let v =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i64_ty, effective_address, ""));
+                let v = err!(self
                     .builder
-                    .build_load(self.intrinsics.i64_ty, effective_address, "");
-                let v = self
+                    .build_bit_cast(v, self.intrinsics.i8_ty.vec_type(8), ""))
+                .into_vector_value();
+                let res = err!(self
                     .builder
-                    .build_bitcast(v, self.intrinsics.i8_ty.vec_type(8), "")
-                    .into_vector_value();
-                let res = self
+                    .build_int_s_extend(v, self.intrinsics.i16x8_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(v, self.intrinsics.i16x8_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::V128Load8x8U { ref memarg } => {
@@ -8808,21 +9271,24 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                let v = self
+                let v =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i64_ty, effective_address, ""));
+                let v = err!(self
                     .builder
-                    .build_load(self.intrinsics.i64_ty, effective_address, "");
-                let v = self
+                    .build_bit_cast(v, self.intrinsics.i8_ty.vec_type(8), ""))
+                .into_vector_value();
+                let res = err!(self
                     .builder
-                    .build_bitcast(v, self.intrinsics.i8_ty.vec_type(8), "")
-                    .into_vector_value();
-                let res = self
+                    .build_int_z_extend(v, self.intrinsics.i16x8_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(v, self.intrinsics.i16x8_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::V128Load16x4S { ref memarg } => {
@@ -8831,21 +9297,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                let v = self
-                    .builder
-                    .build_load(self.intrinsics.i64_ty, effective_address, "");
-                let v = self
-                    .builder
-                    .build_bitcast(v, self.intrinsics.i16_ty.vec_type(4), "")
+                let v =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i64_ty, effective_address, ""));
+                let v =
+                    err!(self
+                        .builder
+                        .build_bit_cast(v, self.intrinsics.i16_ty.vec_type(4), ""))
                     .into_vector_value();
-                let res = self
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(v, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(v, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::V128Load16x4U { ref memarg } => {
@@ -8854,21 +9324,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                let v = self
-                    .builder
-                    .build_load(self.intrinsics.i64_ty, effective_address, "");
-                let v = self
-                    .builder
-                    .build_bitcast(v, self.intrinsics.i16_ty.vec_type(4), "")
+                let v =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i64_ty, effective_address, ""));
+                let v =
+                    err!(self
+                        .builder
+                        .build_bit_cast(v, self.intrinsics.i16_ty.vec_type(4), ""))
                     .into_vector_value();
-                let res = self
+                let res = err!(self
+                    .builder
+                    .build_int_z_extend(v, self.intrinsics.i32x4_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(v, self.intrinsics.i32x4_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::V128Load32x2S { ref memarg } => {
@@ -8877,21 +9351,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                let v = self
-                    .builder
-                    .build_load(self.intrinsics.i64_ty, effective_address, "");
-                let v = self
-                    .builder
-                    .build_bitcast(v, self.intrinsics.i32_ty.vec_type(2), "")
+                let v =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i64_ty, effective_address, ""));
+                let v =
+                    err!(self
+                        .builder
+                        .build_bit_cast(v, self.intrinsics.i32_ty.vec_type(2), ""))
                     .into_vector_value();
-                let res = self
+                let res = err!(self
                     .builder
-                    .build_int_s_extend(v, self.intrinsics.i64x2_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_int_s_extend(v, self.intrinsics.i64x2_ty, ""));
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::V128Load32x2U { ref memarg } => {
@@ -8900,21 +9378,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                let v = self
-                    .builder
-                    .build_load(self.intrinsics.i64_ty, effective_address, "");
-                let v = self
-                    .builder
-                    .build_bitcast(v, self.intrinsics.i32_ty.vec_type(2), "")
+                let v =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i64_ty, effective_address, ""));
+                let v =
+                    err!(self
+                        .builder
+                        .build_bit_cast(v, self.intrinsics.i32_ty.vec_type(2), ""))
                     .into_vector_value();
-                let res = self
+                let res = err!(self
+                    .builder
+                    .build_int_z_extend(v, self.intrinsics.i64x2_ty, ""));
+                let res = err!(self
                     .builder
-                    .build_int_z_extend(v, self.intrinsics.i64x2_ty, "");
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::V128Load32Zero { ref memarg } => {
@@ -8923,24 +9405,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                let elem = self
-                    .builder
-                    .build_load(self.intrinsics.i32_ty, effective_address, "");
+                let elem =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i32_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     elem.as_instruction_value().unwrap(),
                 )?;
-                let res = self.builder.build_int_z_extend(
+                let res = err!(self.builder.build_int_z_extend(
                     elem.into_int_value(),
                     self.intrinsics.i128_ty,
                     "",
-                );
+                ));
                 self.state.push1(res);
             }
             Operator::V128Load64Zero { ref memarg } => {
@@ -8949,24 +9432,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                let elem = self
-                    .builder
-                    .build_load(self.intrinsics.i64_ty, effective_address, "");
+                let elem =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i64_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     elem.as_instruction_value().unwrap(),
                 )?;
-                let res = self.builder.build_int_z_extend(
+                let res = err!(self.builder.build_int_z_extend(
                     elem.into_int_value(),
                     self.intrinsics.i128_ty,
                     "",
-                );
+                ));
                 self.state.push1(res);
             }
             Operator::V128Load8Splat { ref memarg } => {
@@ -8975,21 +9459,24 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                let elem = self
-                    .builder
-                    .build_load(self.intrinsics.i8_ty, effective_address, "");
+                let elem =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i8_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     elem.as_instruction_value().unwrap(),
                 )?;
-                let res = self.splat_vector(elem, self.intrinsics.i8x16_ty);
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = self.splat_vector(elem, self.intrinsics.i8x16_ty)?;
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::V128Load16Splat { ref memarg } => {
@@ -8998,21 +9485,24 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                let elem = self
-                    .builder
-                    .build_load(self.intrinsics.i16_ty, effective_address, "");
+                let elem =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i16_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     elem.as_instruction_value().unwrap(),
                 )?;
-                let res = self.splat_vector(elem, self.intrinsics.i16x8_ty);
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = self.splat_vector(elem, self.intrinsics.i16x8_ty)?;
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::V128Load32Splat { ref memarg } => {
@@ -9021,21 +9511,24 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                let elem = self
-                    .builder
-                    .build_load(self.intrinsics.i32_ty, effective_address, "");
+                let elem =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i32_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     elem.as_instruction_value().unwrap(),
                 )?;
-                let res = self.splat_vector(elem, self.intrinsics.i32x4_ty);
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = self.splat_vector(elem, self.intrinsics.i32x4_ty)?;
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::V128Load64Splat { ref memarg } => {
@@ -9044,21 +9537,24 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                let elem = self
-                    .builder
-                    .build_load(self.intrinsics.i64_ty, effective_address, "");
+                let elem =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i64_ty, effective_address, ""));
                 self.annotate_user_memaccess(
                     memory_index,
                     memarg,
                     1,
                     elem.as_instruction_value().unwrap(),
                 )?;
-                let res = self.splat_vector(elem, self.intrinsics.i64x2_ty);
-                let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
+                let res = self.splat_vector(elem, self.intrinsics.i64x2_ty)?;
+                let res = err!(self
+                    .builder
+                    .build_bit_cast(res, self.intrinsics.i128_ty, ""));
                 self.state.push1(res);
             }
             Operator::AtomicFence => {
@@ -9076,14 +9572,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 4);
-                let result = self
-                    .builder
-                    .build_load(self.intrinsics.i32_ty, effective_address, "");
+                self.trap_if_misaligned(memarg, effective_address, 4)?;
+                let result =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i32_ty, effective_address, ""));
                 let load = result.as_instruction_value().unwrap();
                 self.annotate_user_memaccess(memory_index, memarg, 4, load)?;
                 load.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
@@ -9096,14 +9593,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 8);
-                let result = self
-                    .builder
-                    .build_load(self.intrinsics.i64_ty, effective_address, "");
+                self.trap_if_misaligned(memarg, effective_address, 8)?;
+                let result =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i64_ty, effective_address, ""));
                 let load = result.as_instruction_value().unwrap();
                 self.annotate_user_memaccess(memory_index, memarg, 8, load)?;
                 load.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
@@ -9116,22 +9614,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 1);
-                let narrow_result = self
-                    .builder
-                    .build_load(self.intrinsics.i8_ty, effective_address, "")
+                self.trap_if_misaligned(memarg, effective_address, 1)?;
+                let narrow_result =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i8_ty, effective_address, ""))
                     .into_int_value();
                 let load = narrow_result.as_instruction_value().unwrap();
                 self.annotate_user_memaccess(memory_index, memarg, 1, load)?;
                 load.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
                     .unwrap();
-                let result =
-                    self.builder
-                        .build_int_z_extend(narrow_result, self.intrinsics.i32_ty, "");
+                let result = err!(self.builder.build_int_z_extend(
+                    narrow_result,
+                    self.intrinsics.i32_ty,
+                    ""
+                ));
                 self.state.push1_extra(result, ExtraInfo::arithmetic_f32());
             }
             Operator::I32AtomicLoad16U { ref memarg } => {
@@ -9140,22 +9641,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 2);
-                let narrow_result = self
-                    .builder
-                    .build_load(self.intrinsics.i16_ty, effective_address, "")
+                self.trap_if_misaligned(memarg, effective_address, 2)?;
+                let narrow_result =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i16_ty, effective_address, ""))
                     .into_int_value();
                 let load = narrow_result.as_instruction_value().unwrap();
                 self.annotate_user_memaccess(memory_index, memarg, 2, load)?;
                 load.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
                     .unwrap();
-                let result =
-                    self.builder
-                        .build_int_z_extend(narrow_result, self.intrinsics.i32_ty, "");
+                let result = err!(self.builder.build_int_z_extend(
+                    narrow_result,
+                    self.intrinsics.i32_ty,
+                    ""
+                ));
                 self.state.push1_extra(result, ExtraInfo::arithmetic_f32());
             }
             Operator::I64AtomicLoad8U { ref memarg } => {
@@ -9164,22 +9668,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 1);
-                let narrow_result = self
-                    .builder
-                    .build_load(self.intrinsics.i8_ty, effective_address, "")
+                self.trap_if_misaligned(memarg, effective_address, 1)?;
+                let narrow_result =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i8_ty, effective_address, ""))
                     .into_int_value();
                 let load = narrow_result.as_instruction_value().unwrap();
                 self.annotate_user_memaccess(memory_index, memarg, 1, load)?;
                 load.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
                     .unwrap();
-                let result =
-                    self.builder
-                        .build_int_z_extend(narrow_result, self.intrinsics.i64_ty, "");
+                let result = err!(self.builder.build_int_z_extend(
+                    narrow_result,
+                    self.intrinsics.i64_ty,
+                    ""
+                ));
                 self.state.push1_extra(result, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicLoad16U { ref memarg } => {
@@ -9188,22 +9695,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 2);
-                let narrow_result = self
-                    .builder
-                    .build_load(self.intrinsics.i16_ty, effective_address, "")
+                self.trap_if_misaligned(memarg, effective_address, 2)?;
+                let narrow_result =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i16_ty, effective_address, ""))
                     .into_int_value();
                 let load = narrow_result.as_instruction_value().unwrap();
                 self.annotate_user_memaccess(memory_index, memarg, 2, load)?;
                 load.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
                     .unwrap();
-                let result =
-                    self.builder
-                        .build_int_z_extend(narrow_result, self.intrinsics.i64_ty, "");
+                let result = err!(self.builder.build_int_z_extend(
+                    narrow_result,
+                    self.intrinsics.i64_ty,
+                    ""
+                ));
                 self.state.push1_extra(result, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicLoad32U { ref memarg } => {
@@ -9212,22 +9722,25 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 4);
-                let narrow_result = self
-                    .builder
-                    .build_load(self.intrinsics.i32_ty, effective_address, "")
+                self.trap_if_misaligned(memarg, effective_address, 4)?;
+                let narrow_result =
+                    err!(self
+                        .builder
+                        .build_load(self.intrinsics.i32_ty, effective_address, ""))
                     .into_int_value();
                 let load = narrow_result.as_instruction_value().unwrap();
                 self.annotate_user_memaccess(memory_index, memarg, 4, load)?;
                 load.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
                     .unwrap();
-                let result =
-                    self.builder
-                        .build_int_z_extend(narrow_result, self.intrinsics.i64_ty, "");
+                let result = err!(self.builder.build_int_z_extend(
+                    narrow_result,
+                    self.intrinsics.i64_ty,
+                    ""
+                ));
                 self.state.push1_extra(result, ExtraInfo::arithmetic_f64());
             }
             Operator::I32AtomicStore { ref memarg } => {
@@ -9237,12 +9750,12 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 4);
-                let store = self.builder.build_store(effective_address, value);
+                self.trap_if_misaligned(memarg, effective_address, 4)?;
+                let store = err!(self.builder.build_store(effective_address, value));
                 self.annotate_user_memaccess(memory_index, memarg, 4, store)?;
                 store
                     .set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
@@ -9255,12 +9768,12 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 8);
-                let store = self.builder.build_store(effective_address, value);
+                self.trap_if_misaligned(memarg, effective_address, 8)?;
+                let store = err!(self.builder.build_store(effective_address, value));
                 self.annotate_user_memaccess(memory_index, memarg, 8, store)?;
                 store
                     .set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
@@ -9273,15 +9786,16 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 1);
+                self.trap_if_misaligned(memarg, effective_address, 1)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i8_ty, "");
-                let store = self.builder.build_store(effective_address, narrow_value);
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i8_ty, ""));
+                let store = err!(self.builder.build_store(effective_address, narrow_value));
                 self.annotate_user_memaccess(memory_index, memarg, 1, store)?;
                 store
                     .set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
@@ -9295,15 +9809,16 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 2);
+                self.trap_if_misaligned(memarg, effective_address, 2)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i16_ty, "");
-                let store = self.builder.build_store(effective_address, narrow_value);
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i16_ty, ""));
+                let store = err!(self.builder.build_store(effective_address, narrow_value));
                 self.annotate_user_memaccess(memory_index, memarg, 2, store)?;
                 store
                     .set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
@@ -9316,15 +9831,16 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 4);
+                self.trap_if_misaligned(memarg, effective_address, 4)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i32_ty, "");
-                let store = self.builder.build_store(effective_address, narrow_value);
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i32_ty, ""));
+                let store = err!(self.builder.build_store(effective_address, narrow_value));
                 self.annotate_user_memaccess(memory_index, memarg, 4, store)?;
                 store
                     .set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
@@ -9337,14 +9853,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 1);
+                self.trap_if_misaligned(memarg, effective_address, 1)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i8_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i8_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9360,9 +9877,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     format!("memory {}", memory_index.as_u32()),
                     old.as_instruction_value().unwrap(),
                 );
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f32());
             }
             Operator::I32AtomicRmw16AddU { ref memarg } => {
@@ -9372,14 +9889,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 2);
+                self.trap_if_misaligned(memarg, effective_address, 2)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i16_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i16_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9395,9 +9913,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     format!("memory {}", memory_index.as_u32()),
                     old.as_instruction_value().unwrap(),
                 );
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f32());
             }
             Operator::I32AtomicRmwAdd { ref memarg } => {
@@ -9407,11 +9925,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 4);
+                self.trap_if_misaligned(memarg, effective_address, 4)?;
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9436,14 +9954,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 1);
+                self.trap_if_misaligned(memarg, effective_address, 1)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i8_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i8_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9459,9 +9978,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmw16AddU { ref memarg } => {
@@ -9471,14 +9990,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 2);
+                self.trap_if_misaligned(memarg, effective_address, 2)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i16_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i16_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9494,9 +10014,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmw32AddU { ref memarg } => {
@@ -9506,14 +10026,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 4);
+                self.trap_if_misaligned(memarg, effective_address, 4)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i32_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i32_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9529,9 +10050,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmwAdd { ref memarg } => {
@@ -9541,11 +10062,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 8);
+                self.trap_if_misaligned(memarg, effective_address, 8)?;
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9570,14 +10091,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 1);
+                self.trap_if_misaligned(memarg, effective_address, 1)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i8_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i8_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9593,9 +10115,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f32());
             }
             Operator::I32AtomicRmw16SubU { ref memarg } => {
@@ -9605,14 +10127,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 2);
+                self.trap_if_misaligned(memarg, effective_address, 2)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i16_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i16_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9628,9 +10151,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f32());
             }
             Operator::I32AtomicRmwSub { ref memarg } => {
@@ -9640,11 +10163,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 4);
+                self.trap_if_misaligned(memarg, effective_address, 4)?;
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9669,14 +10192,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 1);
+                self.trap_if_misaligned(memarg, effective_address, 1)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i8_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i8_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9692,9 +10216,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f32());
             }
             Operator::I64AtomicRmw16SubU { ref memarg } => {
@@ -9704,14 +10228,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 2);
+                self.trap_if_misaligned(memarg, effective_address, 2)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i16_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i16_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9727,9 +10252,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmw32SubU { ref memarg } => {
@@ -9739,14 +10264,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 4);
+                self.trap_if_misaligned(memarg, effective_address, 4)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i32_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i32_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9762,9 +10288,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmwSub { ref memarg } => {
@@ -9774,11 +10300,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 8);
+                self.trap_if_misaligned(memarg, effective_address, 8)?;
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9803,14 +10329,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 1);
+                self.trap_if_misaligned(memarg, effective_address, 1)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i8_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i8_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9826,9 +10353,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f32());
             }
             Operator::I32AtomicRmw16AndU { ref memarg } => {
@@ -9838,14 +10365,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 2);
+                self.trap_if_misaligned(memarg, effective_address, 2)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i16_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i16_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9861,9 +10389,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f32());
             }
             Operator::I32AtomicRmwAnd { ref memarg } => {
@@ -9873,11 +10401,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 4);
+                self.trap_if_misaligned(memarg, effective_address, 4)?;
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9902,14 +10430,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 1);
+                self.trap_if_misaligned(memarg, effective_address, 1)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i8_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i8_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9925,9 +10454,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmw16AndU { ref memarg } => {
@@ -9937,14 +10466,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 2);
+                self.trap_if_misaligned(memarg, effective_address, 2)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i16_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i16_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9960,9 +10490,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmw32AndU { ref memarg } => {
@@ -9972,14 +10502,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 4);
+                self.trap_if_misaligned(memarg, effective_address, 4)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i32_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i32_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -9995,9 +10526,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmwAnd { ref memarg } => {
@@ -10007,11 +10538,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 8);
+                self.trap_if_misaligned(memarg, effective_address, 8)?;
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10036,14 +10567,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 1);
+                self.trap_if_misaligned(memarg, effective_address, 1)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i8_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i8_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10059,9 +10591,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f32());
             }
             Operator::I32AtomicRmw16OrU { ref memarg } => {
@@ -10071,14 +10603,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 2);
+                self.trap_if_misaligned(memarg, effective_address, 2)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i16_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i16_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10094,9 +10627,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f32());
             }
             Operator::I32AtomicRmwOr { ref memarg } => {
@@ -10106,11 +10639,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 4);
+                self.trap_if_misaligned(memarg, effective_address, 4)?;
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10126,9 +10659,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f32());
             }
             Operator::I64AtomicRmw8OrU { ref memarg } => {
@@ -10138,14 +10671,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 1);
+                self.trap_if_misaligned(memarg, effective_address, 1)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i8_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i8_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10161,9 +10695,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmw16OrU { ref memarg } => {
@@ -10173,14 +10707,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 2);
+                self.trap_if_misaligned(memarg, effective_address, 2)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i16_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i16_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10196,9 +10731,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmw32OrU { ref memarg } => {
@@ -10208,14 +10743,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 4);
+                self.trap_if_misaligned(memarg, effective_address, 4)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i32_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i32_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10231,9 +10767,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmwOr { ref memarg } => {
@@ -10243,11 +10779,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 8);
+                self.trap_if_misaligned(memarg, effective_address, 8)?;
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10272,14 +10808,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 2);
+                self.trap_if_misaligned(memarg, effective_address, 2)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i8_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i8_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10295,9 +10832,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f32());
             }
             Operator::I32AtomicRmw16XorU { ref memarg } => {
@@ -10307,14 +10844,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 2);
+                self.trap_if_misaligned(memarg, effective_address, 2)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i16_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i16_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10330,9 +10868,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f32());
             }
             Operator::I32AtomicRmwXor { ref memarg } => {
@@ -10342,11 +10880,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 4);
+                self.trap_if_misaligned(memarg, effective_address, 4)?;
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10371,14 +10909,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 1);
+                self.trap_if_misaligned(memarg, effective_address, 1)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i8_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i8_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10394,9 +10933,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmw16XorU { ref memarg } => {
@@ -10406,14 +10945,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 2);
+                self.trap_if_misaligned(memarg, effective_address, 2)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i16_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i16_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10429,9 +10969,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmw32XorU { ref memarg } => {
@@ -10441,14 +10981,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 4);
+                self.trap_if_misaligned(memarg, effective_address, 4)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i32_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i32_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10464,9 +11005,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmwXor { ref memarg } => {
@@ -10476,11 +11017,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 8);
+                self.trap_if_misaligned(memarg, effective_address, 8)?;
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10505,14 +11046,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 1);
+                self.trap_if_misaligned(memarg, effective_address, 1)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i8_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i8_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10528,9 +11070,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f32());
             }
             Operator::I32AtomicRmw16XchgU { ref memarg } => {
@@ -10540,14 +11082,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 2);
+                self.trap_if_misaligned(memarg, effective_address, 2)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i16_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i16_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10563,9 +11106,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f32());
             }
             Operator::I32AtomicRmwXchg { ref memarg } => {
@@ -10575,11 +11118,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 4);
+                self.trap_if_misaligned(memarg, effective_address, 4)?;
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10604,14 +11147,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 1);
+                self.trap_if_misaligned(memarg, effective_address, 1)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i8_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i8_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10627,9 +11171,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmw16XchgU { ref memarg } => {
@@ -10639,14 +11183,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 2);
+                self.trap_if_misaligned(memarg, effective_address, 2)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i16_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i16_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10662,9 +11207,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmw32XchgU { ref memarg } => {
@@ -10674,14 +11219,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 4);
+                self.trap_if_misaligned(memarg, effective_address, 4)?;
                 let narrow_value =
-                    self.builder
-                        .build_int_truncate(value, self.intrinsics.i32_ty, "");
+                    err!(self
+                        .builder
+                        .build_int_truncate(value, self.intrinsics.i32_ty, ""));
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10697,9 +11243,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmwXchg { ref memarg } => {
@@ -10709,11 +11255,11 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 8);
+                self.trap_if_misaligned(memarg, effective_address, 8)?;
                 let old = self
                     .builder
                     .build_atomicrmw(
@@ -10733,25 +11279,27 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
             }
             Operator::I32AtomicRmw8CmpxchgU { ref memarg } => {
                 let ((cmp, cmp_info), (new, new_info)) = self.state.pop2_extra()?;
-                let cmp = self.apply_pending_canonicalization(cmp, cmp_info);
-                let new = self.apply_pending_canonicalization(new, new_info);
+                let cmp = self.apply_pending_canonicalization(cmp, cmp_info)?;
+                let new = self.apply_pending_canonicalization(new, new_info)?;
                 let (cmp, new) = (cmp.into_int_value(), new.into_int_value());
                 let offset = self.state.pop1()?.into_int_value();
                 let memory_index = MemoryIndex::from_u32(0);
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 1);
-                let narrow_cmp = self
-                    .builder
-                    .build_int_truncate(cmp, self.intrinsics.i8_ty, "");
-                let narrow_new = self
-                    .builder
-                    .build_int_truncate(new, self.intrinsics.i8_ty, "");
+                self.trap_if_misaligned(memarg, effective_address, 1)?;
+                let narrow_cmp =
+                    err!(self
+                        .builder
+                        .build_int_truncate(cmp, self.intrinsics.i8_ty, ""));
+                let narrow_new =
+                    err!(self
+                        .builder
+                        .build_int_truncate(new, self.intrinsics.i8_ty, ""));
                 let old = self
                     .builder
                     .build_cmpxchg(
@@ -10773,32 +11321,34 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     .build_extract_value(old, 0, "")
                     .unwrap()
                     .into_int_value();
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f32());
             }
             Operator::I32AtomicRmw16CmpxchgU { ref memarg } => {
                 let ((cmp, cmp_info), (new, new_info)) = self.state.pop2_extra()?;
-                let cmp = self.apply_pending_canonicalization(cmp, cmp_info);
-                let new = self.apply_pending_canonicalization(new, new_info);
+                let cmp = self.apply_pending_canonicalization(cmp, cmp_info)?;
+                let new = self.apply_pending_canonicalization(new, new_info)?;
                 let (cmp, new) = (cmp.into_int_value(), new.into_int_value());
                 let offset = self.state.pop1()?.into_int_value();
                 let memory_index = MemoryIndex::from_u32(0);
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 2);
-                let narrow_cmp = self
-                    .builder
-                    .build_int_truncate(cmp, self.intrinsics.i16_ty, "");
-                let narrow_new = self
-                    .builder
-                    .build_int_truncate(new, self.intrinsics.i16_ty, "");
+                self.trap_if_misaligned(memarg, effective_address, 2)?;
+                let narrow_cmp =
+                    err!(self
+                        .builder
+                        .build_int_truncate(cmp, self.intrinsics.i16_ty, ""));
+                let narrow_new =
+                    err!(self
+                        .builder
+                        .build_int_truncate(new, self.intrinsics.i16_ty, ""));
                 let old = self
                     .builder
                     .build_cmpxchg(
@@ -10820,26 +11370,26 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     .build_extract_value(old, 0, "")
                     .unwrap()
                     .into_int_value();
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i32_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i32_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f32());
             }
             Operator::I32AtomicRmwCmpxchg { ref memarg } => {
                 let ((cmp, cmp_info), (new, new_info)) = self.state.pop2_extra()?;
-                let cmp = self.apply_pending_canonicalization(cmp, cmp_info);
-                let new = self.apply_pending_canonicalization(new, new_info);
+                let cmp = self.apply_pending_canonicalization(cmp, cmp_info)?;
+                let new = self.apply_pending_canonicalization(new, new_info)?;
                 let (cmp, new) = (cmp.into_int_value(), new.into_int_value());
                 let offset = self.state.pop1()?.into_int_value();
                 let memory_index = MemoryIndex::from_u32(0);
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 4);
+                self.trap_if_misaligned(memarg, effective_address, 4)?;
                 let old = self
                     .builder
                     .build_cmpxchg(
@@ -10856,30 +11406,32 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self.builder.build_extract_value(old, 0, "").unwrap();
+                let old = err!(self.builder.build_extract_value(old, 0, ""));
                 self.state.push1(old);
             }
             Operator::I64AtomicRmw8CmpxchgU { ref memarg } => {
                 let ((cmp, cmp_info), (new, new_info)) = self.state.pop2_extra()?;
-                let cmp = self.apply_pending_canonicalization(cmp, cmp_info);
-                let new = self.apply_pending_canonicalization(new, new_info);
+                let cmp = self.apply_pending_canonicalization(cmp, cmp_info)?;
+                let new = self.apply_pending_canonicalization(new, new_info)?;
                 let (cmp, new) = (cmp.into_int_value(), new.into_int_value());
                 let offset = self.state.pop1()?.into_int_value();
                 let memory_index = MemoryIndex::from_u32(0);
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i8_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     1,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 1);
-                let narrow_cmp = self
-                    .builder
-                    .build_int_truncate(cmp, self.intrinsics.i8_ty, "");
-                let narrow_new = self
-                    .builder
-                    .build_int_truncate(new, self.intrinsics.i8_ty, "");
+                self.trap_if_misaligned(memarg, effective_address, 1)?;
+                let narrow_cmp =
+                    err!(self
+                        .builder
+                        .build_int_truncate(cmp, self.intrinsics.i8_ty, ""));
+                let narrow_new =
+                    err!(self
+                        .builder
+                        .build_int_truncate(new, self.intrinsics.i8_ty, ""));
                 let old = self
                     .builder
                     .build_cmpxchg(
@@ -10901,32 +11453,34 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     .build_extract_value(old, 0, "")
                     .unwrap()
                     .into_int_value();
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmw16CmpxchgU { ref memarg } => {
                 let ((cmp, cmp_info), (new, new_info)) = self.state.pop2_extra()?;
-                let cmp = self.apply_pending_canonicalization(cmp, cmp_info);
-                let new = self.apply_pending_canonicalization(new, new_info);
+                let cmp = self.apply_pending_canonicalization(cmp, cmp_info)?;
+                let new = self.apply_pending_canonicalization(new, new_info)?;
                 let (cmp, new) = (cmp.into_int_value(), new.into_int_value());
                 let offset = self.state.pop1()?.into_int_value();
                 let memory_index = MemoryIndex::from_u32(0);
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i16_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     2,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 2);
-                let narrow_cmp = self
-                    .builder
-                    .build_int_truncate(cmp, self.intrinsics.i16_ty, "");
-                let narrow_new = self
-                    .builder
-                    .build_int_truncate(new, self.intrinsics.i16_ty, "");
+                self.trap_if_misaligned(memarg, effective_address, 2)?;
+                let narrow_cmp =
+                    err!(self
+                        .builder
+                        .build_int_truncate(cmp, self.intrinsics.i16_ty, ""));
+                let narrow_new =
+                    err!(self
+                        .builder
+                        .build_int_truncate(new, self.intrinsics.i16_ty, ""));
                 let old = self
                     .builder
                     .build_cmpxchg(
@@ -10948,32 +11502,34 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     .build_extract_value(old, 0, "")
                     .unwrap()
                     .into_int_value();
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmw32CmpxchgU { ref memarg } => {
                 let ((cmp, cmp_info), (new, new_info)) = self.state.pop2_extra()?;
-                let cmp = self.apply_pending_canonicalization(cmp, cmp_info);
-                let new = self.apply_pending_canonicalization(new, new_info);
+                let cmp = self.apply_pending_canonicalization(cmp, cmp_info)?;
+                let new = self.apply_pending_canonicalization(new, new_info)?;
                 let (cmp, new) = (cmp.into_int_value(), new.into_int_value());
                 let offset = self.state.pop1()?.into_int_value();
                 let memory_index = MemoryIndex::from_u32(0);
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i32_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     4,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 4);
-                let narrow_cmp = self
-                    .builder
-                    .build_int_truncate(cmp, self.intrinsics.i32_ty, "");
-                let narrow_new = self
-                    .builder
-                    .build_int_truncate(new, self.intrinsics.i32_ty, "");
+                self.trap_if_misaligned(memarg, effective_address, 4)?;
+                let narrow_cmp =
+                    err!(self
+                        .builder
+                        .build_int_truncate(cmp, self.intrinsics.i32_ty, ""));
+                let narrow_new =
+                    err!(self
+                        .builder
+                        .build_int_truncate(new, self.intrinsics.i32_ty, ""));
                 let old = self
                     .builder
                     .build_cmpxchg(
@@ -10995,26 +11551,26 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     .build_extract_value(old, 0, "")
                     .unwrap()
                     .into_int_value();
-                let old = self
+                let old = err!(self
                     .builder
-                    .build_int_z_extend(old, self.intrinsics.i64_ty, "");
+                    .build_int_z_extend(old, self.intrinsics.i64_ty, ""));
                 self.state.push1_extra(old, ExtraInfo::arithmetic_f64());
             }
             Operator::I64AtomicRmwCmpxchg { ref memarg } => {
                 let ((cmp, cmp_info), (new, new_info)) = self.state.pop2_extra()?;
-                let cmp = self.apply_pending_canonicalization(cmp, cmp_info);
-                let new = self.apply_pending_canonicalization(new, new_info);
+                let cmp = self.apply_pending_canonicalization(cmp, cmp_info)?;
+                let new = self.apply_pending_canonicalization(new, new_info)?;
                 let (cmp, new) = (cmp.into_int_value(), new.into_int_value());
                 let offset = self.state.pop1()?.into_int_value();
                 let memory_index = MemoryIndex::from_u32(0);
                 let effective_address = self.resolve_memory_ptr(
                     memory_index,
                     memarg,
-                    self.intrinsics.i64_ptr_ty,
+                    self.intrinsics.ptr_ty,
                     offset,
                     8,
                 )?;
-                self.trap_if_misaligned(memarg, effective_address, 8);
+                self.trap_if_misaligned(memarg, effective_address, 8)?;
                 let old = self
                     .builder
                     .build_cmpxchg(
@@ -11031,15 +11587,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     0,
                     old.as_instruction_value().unwrap(),
                 )?;
-                let old = self.builder.build_extract_value(old, 0, "").unwrap();
+                let old = err!(self.builder.build_extract_value(old, 0, ""));
                 self.state.push1(old);
             }
 
             Operator::MemoryGrow { mem } => {
                 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 grow = self.builder.build_indirect_call(
+                let grow_fn_ptr = self.ctx.memory_grow(memory_index, self.intrinsics)?;
+                let grow = err!(self.builder.build_indirect_call(
                     self.intrinsics.memory_grow_ty,
                     grow_fn_ptr,
                     &[
@@ -11048,13 +11604,13 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_ty.const_int(mem.into(), false).into(),
                     ],
                     "",
-                );
+                ));
                 self.state.push1(grow.try_as_basic_value().left().unwrap());
             }
             Operator::MemorySize { mem } => {
                 let memory_index = MemoryIndex::from_u32(mem);
-                let size_fn_ptr = self.ctx.memory_size(memory_index, self.intrinsics);
-                let size = self.builder.build_indirect_call(
+                let size_fn_ptr = self.ctx.memory_size(memory_index, self.intrinsics)?;
+                let size = err!(self.builder.build_indirect_call(
                     self.intrinsics.memory_size_ty,
                     size_fn_ptr,
                     &[
@@ -11062,15 +11618,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         self.intrinsics.i32_ty.const_int(mem.into(), false).into(),
                     ],
                     "",
-                );
-                size.add_attribute(AttributeLoc::Function, self.intrinsics.readonly);
+                ));
+                //size.add_attribute(AttributeLoc::Function, self.intrinsics.readonly);
                 self.state.push1(size.try_as_basic_value().left().unwrap());
             }
             Operator::MemoryInit { data_index, mem } => {
                 let (dest, src, len) = self.state.pop3()?;
                 let mem = self.intrinsics.i32_ty.const_int(mem.into(), false);
                 let segment = self.intrinsics.i32_ty.const_int(data_index.into(), false);
-                self.builder.build_call(
+                err!(self.builder.build_call(
                     self.intrinsics.memory_init,
                     &[
                         vmctx.as_basic_value_enum().into(),
@@ -11081,15 +11637,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         len.into(),
                     ],
                     "",
-                );
+                ));
             }
             Operator::DataDrop { data_index } => {
                 let segment = self.intrinsics.i32_ty.const_int(data_index.into(), false);
-                self.builder.build_call(
+                err!(self.builder.build_call(
                     self.intrinsics.data_drop,
                     &[vmctx.as_basic_value_enum().into(), segment.into()],
                     "",
-                );
+                ));
             }
             Operator::MemoryCopy { dst_mem, src_mem } => {
                 // ignored until we support multiple memories
@@ -11105,7 +11661,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
 
                 let (dest_pos, src_pos, len) = self.state.pop3()?;
                 let src_index = self.intrinsics.i32_ty.const_int(src.into(), false);
-                self.builder.build_call(
+                err!(self.builder.build_call(
                     memory_copy,
                     &[
                         vmctx.as_basic_value_enum().into(),
@@ -11115,7 +11671,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         len.into(),
                     ],
                     "",
-                );
+                ));
             }
             Operator::MemoryFill { mem } => {
                 let (memory_fill, mem) = if let Some(local_memory_index) = self
@@ -11129,7 +11685,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
 
                 let (dst, val, len) = self.state.pop3()?;
                 let mem_index = self.intrinsics.i32_ty.const_int(mem.into(), false);
-                self.builder.build_call(
+                err!(self.builder.build_call(
                     memory_fill,
                     &[
                         vmctx.as_basic_value_enum().into(),
@@ -11139,23 +11695,24 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         len.into(),
                     ],
                     "",
-                );
+                ));
             }
             /***************************
              * Reference types.
              * https://github.com/WebAssembly/reference-types/blob/master/proposals/reference-types/Overview.md
              ***************************/
             Operator::RefNull { hty } => {
-                let ty = wpheaptype_to_type(hty).map_err(to_compile_error)?;
+                let ty = err!(wpheaptype_to_type(hty));
                 let ty = type_to_llvm(self.intrinsics, ty)?;
                 self.state.push1(ty.const_zero());
             }
             Operator::RefIsNull => {
                 let value = self.state.pop1()?.into_pointer_value();
-                let is_null = self.builder.build_is_null(value, "");
-                let is_null = self
-                    .builder
-                    .build_int_z_extend(is_null, self.intrinsics.i32_ty, "");
+                let is_null = err!(self.builder.build_is_null(value, ""));
+                let is_null =
+                    err!(self
+                        .builder
+                        .build_int_z_extend(is_null, self.intrinsics.i32_ty, ""));
                 self.state.push1(is_null);
             }
             Operator::RefFunc { function_index } => {
@@ -11163,16 +11720,14 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     .intrinsics
                     .i32_ty
                     .const_int(function_index.into(), false);
-                let value = self
-                    .builder
-                    .build_call(
-                        self.intrinsics.func_ref,
-                        &[self.ctx.basic().into(), index.into()],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                let value = err!(self.builder.build_call(
+                    self.intrinsics.func_ref,
+                    &[self.ctx.basic().into(), index.into()],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 self.state.push1(value);
             }
             Operator::TableGet { table } => {
@@ -11187,17 +11742,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 } else {
                     self.intrinsics.imported_table_get
                 };
-                let value = self
-                    .builder
-                    .build_call(
-                        table_get,
-                        &[self.ctx.basic().into(), table_index.into(), elem.into()],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
-                let value = self.builder.build_bitcast(
+                let value = err!(self.builder.build_call(
+                    table_get,
+                    &[self.ctx.basic().into(), table_index.into(), elem.into()],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
+                let value = err!(self.builder.build_bit_cast(
                     value,
                     type_to_llvm(
                         self.intrinsics,
@@ -11208,15 +11761,15 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                             .ty,
                     )?,
                     "",
-                );
+                ));
                 self.state.push1(value);
             }
             Operator::TableSet { table } => {
                 let table_index = self.intrinsics.i32_ty.const_int(table.into(), false);
                 let (elem, value) = self.state.pop2()?;
-                let value = self
+                let value = err!(self
                     .builder
-                    .build_bitcast(value, self.intrinsics.anyref_ty, "");
+                    .build_bit_cast(value, self.intrinsics.ptr_ty, ""));
                 let table_set = if self
                     .wasm_module
                     .local_table_index(TableIndex::from_u32(table))
@@ -11226,7 +11779,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 } else {
                     self.intrinsics.imported_table_set
                 };
-                self.builder.build_call(
+                err!(self.builder.build_call(
                     table_set,
                     &[
                         self.ctx.basic().into(),
@@ -11235,7 +11788,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         value.into(),
                     ],
                     "",
-                );
+                ));
             }
             Operator::TableCopy {
                 dst_table,
@@ -11244,7 +11797,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                 let (dst, src, len) = self.state.pop3()?;
                 let dst_table = self.intrinsics.i32_ty.const_int(dst_table as u64, false);
                 let src_table = self.intrinsics.i32_ty.const_int(src_table as u64, false);
-                self.builder.build_call(
+                err!(self.builder.build_call(
                     self.intrinsics.table_copy,
                     &[
                         self.ctx.basic().into(),
@@ -11255,13 +11808,13 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         len.into(),
                     ],
                     "",
-                );
+                ));
             }
             Operator::TableInit { elem_index, table } => {
                 let (dst, src, len) = self.state.pop3()?;
                 let segment = self.intrinsics.i32_ty.const_int(elem_index as u64, false);
                 let table = self.intrinsics.i32_ty.const_int(table as u64, false);
-                self.builder.build_call(
+                err!(self.builder.build_call(
                     self.intrinsics.table_init,
                     &[
                         self.ctx.basic().into(),
@@ -11272,23 +11825,23 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         len.into(),
                     ],
                     "",
-                );
+                ));
             }
             Operator::ElemDrop { elem_index } => {
                 let segment = self.intrinsics.i32_ty.const_int(elem_index as u64, false);
-                self.builder.build_call(
+                err!(self.builder.build_call(
                     self.intrinsics.elem_drop,
                     &[self.ctx.basic().into(), segment.into()],
                     "",
-                );
+                ));
             }
             Operator::TableFill { table } => {
                 let table = self.intrinsics.i32_ty.const_int(table as u64, false);
                 let (start, elem, len) = self.state.pop3()?;
-                let elem = self
+                let elem = err!(self
                     .builder
-                    .build_bitcast(elem, self.intrinsics.anyref_ty, "");
-                self.builder.build_call(
+                    .build_bit_cast(elem, self.intrinsics.ptr_ty, ""));
+                err!(self.builder.build_call(
                     self.intrinsics.table_fill,
                     &[
                         self.ctx.basic().into(),
@@ -11298,13 +11851,13 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         len.into(),
                     ],
                     "",
-                );
+                ));
             }
             Operator::TableGrow { table } => {
                 let (elem, delta) = self.state.pop2()?;
-                let elem = self
+                let elem = err!(self
                     .builder
-                    .build_bitcast(elem, self.intrinsics.anyref_ty, "");
+                    .build_bit_cast(elem, self.intrinsics.ptr_ty, ""));
                 let (table_grow, table_index) = if let Some(local_table_index) = self
                     .wasm_module
                     .local_table_index(TableIndex::from_u32(table))
@@ -11314,21 +11867,19 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     (self.intrinsics.imported_table_grow, table)
                 };
                 let table_index = self.intrinsics.i32_ty.const_int(table_index as u64, false);
-                let size = self
-                    .builder
-                    .build_call(
-                        table_grow,
-                        &[
-                            self.ctx.basic().into(),
-                            elem.into(),
-                            delta.into(),
-                            table_index.into(),
-                        ],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                let size = err!(self.builder.build_call(
+                    table_grow,
+                    &[
+                        self.ctx.basic().into(),
+                        elem.into(),
+                        delta.into(),
+                        table_index.into(),
+                    ],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 self.state.push1(size);
             }
             Operator::TableSize { table } => {
@@ -11341,23 +11892,21 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                     (self.intrinsics.imported_table_size, table)
                 };
                 let table_index = self.intrinsics.i32_ty.const_int(table_index as u64, false);
-                let size = self
-                    .builder
-                    .build_call(
-                        table_size,
-                        &[self.ctx.basic().into(), table_index.into()],
-                        "",
-                    )
-                    .try_as_basic_value()
-                    .left()
-                    .unwrap();
+                let size = err!(self.builder.build_call(
+                    table_size,
+                    &[self.ctx.basic().into(), table_index.into()],
+                    "",
+                ))
+                .try_as_basic_value()
+                .left()
+                .unwrap();
                 self.state.push1(size);
             }
             Operator::MemoryAtomicWait32 { memarg } => {
                 let memory_index = MemoryIndex::from_u32(memarg.memory);
                 let (dst, val, timeout) = self.state.pop3()?;
-                let wait32_fn_ptr = self.ctx.memory_wait32(memory_index, self.intrinsics);
-                let ret = self.builder.build_indirect_call(
+                let wait32_fn_ptr = self.ctx.memory_wait32(memory_index, self.intrinsics)?;
+                let ret = err!(self.builder.build_indirect_call(
                     self.intrinsics.memory_wait32_ty,
                     wait32_fn_ptr,
                     &[
@@ -11371,14 +11920,14 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         timeout.into(),
                     ],
                     "",
-                );
+                ));
                 self.state.push1(ret.try_as_basic_value().left().unwrap());
             }
             Operator::MemoryAtomicWait64 { memarg } => {
                 let memory_index = MemoryIndex::from_u32(memarg.memory);
                 let (dst, val, timeout) = self.state.pop3()?;
-                let wait64_fn_ptr = self.ctx.memory_wait64(memory_index, self.intrinsics);
-                let ret = self.builder.build_indirect_call(
+                let wait64_fn_ptr = self.ctx.memory_wait64(memory_index, self.intrinsics)?;
+                let ret = err!(self.builder.build_indirect_call(
                     self.intrinsics.memory_wait64_ty,
                     wait64_fn_ptr,
                     &[
@@ -11392,14 +11941,14 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         timeout.into(),
                     ],
                     "",
-                );
+                ));
                 self.state.push1(ret.try_as_basic_value().left().unwrap());
             }
             Operator::MemoryAtomicNotify { memarg } => {
                 let memory_index = MemoryIndex::from_u32(memarg.memory);
                 let (dst, count) = self.state.pop2()?;
-                let notify_fn_ptr = self.ctx.memory_notify(memory_index, self.intrinsics);
-                let cnt = self.builder.build_indirect_call(
+                let notify_fn_ptr = self.ctx.memory_notify(memory_index, self.intrinsics)?;
+                let cnt = err!(self.builder.build_indirect_call(
                     self.intrinsics.memory_notify_ty,
                     notify_fn_ptr,
                     &[
@@ -11412,7 +11961,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
                         count.into(),
                     ],
                     "",
-                );
+                ));
                 self.state.push1(cnt.try_as_basic_value().left().unwrap());
             }
             _ => {
diff --git a/lib/compiler-llvm/src/translator/intrinsics.rs b/lib/compiler-llvm/src/translator/intrinsics.rs
index f1f7346c415..59516fab70f 100644
--- a/lib/compiler-llvm/src/translator/intrinsics.rs
+++ b/lib/compiler-llvm/src/translator/intrinsics.rs
@@ -5,6 +5,7 @@
 //! [llvm-intrinsics]: https://llvm.org/docs/LangRef.html#intrinsic-functions
 
 use crate::abi::Abi;
+use crate::error::err;
 use inkwell::values::BasicMetadataValueEnum;
 use inkwell::{
     attributes::{Attribute, AttributeLoc},
@@ -32,17 +33,10 @@ use wasmer_vm::{MemoryStyle, TrapCode, VMBuiltinFunctionIndex, VMOffsets};
 
 pub fn type_to_llvm_ptr<'ctx>(
     intrinsics: &Intrinsics<'ctx>,
-    ty: Type,
+    _ty: Type,
 ) -> Result<PointerType<'ctx>, CompileError> {
-    match ty {
-        Type::I32 => Ok(intrinsics.i32_ptr_ty),
-        Type::I64 => Ok(intrinsics.i64_ptr_ty),
-        Type::F32 => Ok(intrinsics.f32_ptr_ty),
-        Type::F64 => Ok(intrinsics.f64_ptr_ty),
-        Type::V128 => Ok(intrinsics.i128_ptr_ty),
-        Type::FuncRef => Ok(intrinsics.funcref_ty.ptr_type(AddressSpace::default())),
-        Type::ExternRef => Ok(intrinsics.externref_ty.ptr_type(AddressSpace::default())),
-    }
+    // LLVM v. > 15 has a single pointer type.
+    Ok(intrinsics.ptr_ty)
 }
 
 pub fn type_to_llvm<'ctx>(
@@ -55,8 +49,8 @@ pub fn type_to_llvm<'ctx>(
         Type::F32 => Ok(intrinsics.f32_ty.as_basic_type_enum()),
         Type::F64 => Ok(intrinsics.f64_ty.as_basic_type_enum()),
         Type::V128 => Ok(intrinsics.i128_ty.as_basic_type_enum()),
-        Type::FuncRef => Ok(intrinsics.funcref_ty.as_basic_type_enum()),
-        Type::ExternRef => Ok(intrinsics.externref_ty.as_basic_type_enum()),
+        Type::FuncRef => Ok(intrinsics.ptr_ty.as_basic_type_enum()),
+        Type::ExternRef => Ok(intrinsics.ptr_ty.as_basic_type_enum()),
     }
 }
 
@@ -181,21 +175,10 @@ pub struct Intrinsics<'ctx> {
     pub f64x2_ty: VectorType<'ctx>,
     pub i32x8_ty: VectorType<'ctx>,
 
-    pub i8_ptr_ty: PointerType<'ctx>,
-    pub i16_ptr_ty: PointerType<'ctx>,
-    pub i32_ptr_ty: PointerType<'ctx>,
-    pub i64_ptr_ty: PointerType<'ctx>,
-    pub i128_ptr_ty: PointerType<'ctx>,
-    pub isize_ptr_ty: PointerType<'ctx>,
-    pub f32_ptr_ty: PointerType<'ctx>,
-    pub f64_ptr_ty: PointerType<'ctx>,
+    pub ptr_ty: PointerType<'ctx>,
 
     pub anyfunc_ty: StructType<'ctx>,
 
-    pub funcref_ty: PointerType<'ctx>,
-    pub externref_ty: PointerType<'ctx>,
-    pub anyref_ty: PointerType<'ctx>,
-
     pub i1_zero: IntValue<'ctx>,
     pub i8_zero: IntValue<'ctx>,
     pub i32_zero: IntValue<'ctx>,
@@ -255,29 +238,13 @@ pub struct Intrinsics<'ctx> {
     pub throw_trap: FunctionValue<'ctx>,
 
     // VM builtins.
-    pub vmfunction_import_ptr_ty: PointerType<'ctx>,
     pub vmfunction_import_ty: StructType<'ctx>,
     pub vmfunction_import_body_element: u32,
     pub vmfunction_import_vmctx_element: u32,
 
-    pub vmmemory_definition_ptr_ty: PointerType<'ctx>,
     pub vmmemory_definition_ty: StructType<'ctx>,
     pub vmmemory_definition_base_element: u32,
     pub vmmemory_definition_current_length_element: u32,
-
-    pub memory32_grow_ptr_ty: PointerType<'ctx>,
-    pub imported_memory32_grow_ptr_ty: PointerType<'ctx>,
-    pub memory32_size_ptr_ty: PointerType<'ctx>,
-    pub imported_memory32_size_ptr_ty: PointerType<'ctx>,
-    pub memory32_wait32_ptr_ty: PointerType<'ctx>,
-    pub imported_memory32_wait32_ptr_ty: PointerType<'ctx>,
-    pub memory32_wait64_ptr_ty: PointerType<'ctx>,
-    pub imported_memory32_wait64_ptr_ty: PointerType<'ctx>,
-    pub memory32_notify_ptr_ty: PointerType<'ctx>,
-    pub imported_memory32_notify_ptr_ty: PointerType<'ctx>,
-
-    // Pointer to the VM.
-    pub ctx_ptr_ty: PointerType<'ctx>,
 }
 
 impl<'ctx> Intrinsics<'ctx> {
@@ -311,14 +278,7 @@ impl<'ctx> Intrinsics<'ctx> {
         let f64x2_ty = f64_ty.vec_type(2);
         let i32x8_ty = i32_ty.vec_type(8);
 
-        let i8_ptr_ty = i8_ty.ptr_type(AddressSpace::default());
-        let i16_ptr_ty = i16_ty.ptr_type(AddressSpace::default());
-        let i32_ptr_ty = i32_ty.ptr_type(AddressSpace::default());
-        let i64_ptr_ty = i64_ty.ptr_type(AddressSpace::default());
-        let i128_ptr_ty = i128_ty.ptr_type(AddressSpace::default());
-        let isize_ptr_ty = isize_ty.ptr_type(AddressSpace::default());
-        let f32_ptr_ty = f32_ty.ptr_type(AddressSpace::default());
-        let f64_ptr_ty = f64_ty.ptr_type(AddressSpace::default());
+        let ptr_ty = context.ptr_type(AddressSpace::default());
 
         let i1_zero = i1_ty.const_int(0, false);
         let i8_zero = i8_ty.const_int(0, false);
@@ -351,7 +311,7 @@ impl<'ctx> Intrinsics<'ctx> {
 
         let md_ty = context.metadata_type();
 
-        let i8_ptr_ty_basic = i8_ptr_ty.as_basic_type_enum();
+        let i8_ptr_ty_basic = ptr_ty.as_basic_type_enum();
 
         let i1_ty_basic_md: BasicMetadataTypeEnum = i1_ty.into();
         let i32_ty_basic_md: BasicMetadataTypeEnum = i32_ty.into();
@@ -364,8 +324,7 @@ impl<'ctx> Intrinsics<'ctx> {
         let f64x2_ty_basic_md: BasicMetadataTypeEnum = f64x2_ty.into();
         let md_ty_basic_md: BasicMetadataTypeEnum = md_ty.into();
 
-        let ctx_ty = i8_ty;
-        let ctx_ptr_ty = ctx_ty.ptr_type(AddressSpace::default());
+        let ctx_ptr_ty = ptr_ty;
         let ctx_ptr_ty_basic = ctx_ptr_ty.as_basic_type_enum();
         let ctx_ptr_ty_basic_md: BasicMetadataTypeEnum = ctx_ptr_ty.into();
 
@@ -375,9 +334,8 @@ impl<'ctx> Intrinsics<'ctx> {
             &[i8_ptr_ty_basic, sigindex_ty.into(), ctx_ptr_ty_basic],
             false,
         );
-        let funcref_ty = anyfunc_ty.ptr_type(AddressSpace::default());
-        let externref_ty = funcref_ty;
-        let anyref_ty = i8_ptr_ty;
+        let funcref_ty = ptr_ty;
+        let anyref_ty = ptr_ty;
         let anyref_ty_basic_md: BasicMetadataTypeEnum = anyref_ty.into();
 
         let ret_i8x16_take_i8x16 = i8x16_ty.fn_type(&[i8x16_ty_basic_md], false);
@@ -745,21 +703,7 @@ impl<'ctx> Intrinsics<'ctx> {
             f64x2_ty,
             i32x8_ty,
 
-            i8_ptr_ty,
-            i16_ptr_ty,
-            i32_ptr_ty,
-            i64_ptr_ty,
-            i128_ptr_ty,
-            isize_ptr_ty,
-            f32_ptr_ty,
-            f64_ptr_ty,
-
             anyfunc_ty,
-
-            funcref_ty,
-            externref_ty,
-            anyref_ty,
-
             i1_zero,
             i8_zero,
             i32_zero,
@@ -1143,110 +1087,15 @@ impl<'ctx> Intrinsics<'ctx> {
                 None,
             ),
 
-            vmfunction_import_ptr_ty: context
-                .struct_type(&[i8_ptr_ty_basic, i8_ptr_ty_basic], false)
-                .ptr_type(AddressSpace::default()),
             vmfunction_import_ty: context.struct_type(&[i8_ptr_ty_basic, i8_ptr_ty_basic], false),
             vmfunction_import_body_element: 0,
             vmfunction_import_vmctx_element: 1,
-
-            vmmemory_definition_ptr_ty: context
-                .struct_type(&[i8_ptr_ty_basic, isize_ty.into()], false)
-                .ptr_type(AddressSpace::default()),
             vmmemory_definition_ty: context.struct_type(&[i8_ptr_ty_basic, isize_ty.into()], false),
             vmmemory_definition_base_element: 0,
             vmmemory_definition_current_length_element: 1,
 
-            memory32_grow_ptr_ty: i32_ty
-                .fn_type(
-                    &[ctx_ptr_ty_basic_md, i32_ty_basic_md, i32_ty_basic_md],
-                    false,
-                )
-                .ptr_type(AddressSpace::default()),
-            imported_memory32_grow_ptr_ty: i32_ty
-                .fn_type(
-                    &[ctx_ptr_ty_basic_md, i32_ty_basic_md, i32_ty_basic_md],
-                    false,
-                )
-                .ptr_type(AddressSpace::default()),
-            memory32_size_ptr_ty: i32_ty
-                .fn_type(&[ctx_ptr_ty_basic_md, i32_ty_basic_md], false)
-                .ptr_type(AddressSpace::default()),
-            imported_memory32_size_ptr_ty: i32_ty
-                .fn_type(&[ctx_ptr_ty_basic_md, i32_ty_basic_md], false)
-                .ptr_type(AddressSpace::default()),
-            memory32_wait32_ptr_ty: i32_ty
-                .fn_type(
-                    &[
-                        ctx_ptr_ty_basic_md,
-                        i32_ty_basic_md,
-                        i32_ty_basic_md,
-                        i32_ty_basic_md,
-                        i64_ty_basic_md,
-                    ],
-                    false,
-                )
-                .ptr_type(AddressSpace::default()),
-            imported_memory32_wait32_ptr_ty: i32_ty
-                .fn_type(
-                    &[
-                        ctx_ptr_ty_basic_md,
-                        i32_ty_basic_md,
-                        i32_ty_basic_md,
-                        i32_ty_basic_md,
-                        i64_ty_basic_md,
-                    ],
-                    false,
-                )
-                .ptr_type(AddressSpace::default()),
-            memory32_wait64_ptr_ty: i32_ty
-                .fn_type(
-                    &[
-                        ctx_ptr_ty_basic_md,
-                        i32_ty_basic_md,
-                        i32_ty_basic_md,
-                        i64_ty_basic_md,
-                        i64_ty_basic_md,
-                    ],
-                    false,
-                )
-                .ptr_type(AddressSpace::default()),
-            imported_memory32_wait64_ptr_ty: i32_ty
-                .fn_type(
-                    &[
-                        ctx_ptr_ty_basic_md,
-                        i32_ty_basic_md,
-                        i32_ty_basic_md,
-                        i64_ty_basic_md,
-                        i64_ty_basic_md,
-                    ],
-                    false,
-                )
-                .ptr_type(AddressSpace::default()),
-            memory32_notify_ptr_ty: i32_ty
-                .fn_type(
-                    &[
-                        ctx_ptr_ty_basic_md,
-                        i32_ty_basic_md,
-                        i32_ty_basic_md,
-                        i32_ty_basic_md,
-                    ],
-                    false,
-                )
-                .ptr_type(AddressSpace::default()),
-            imported_memory32_notify_ptr_ty: i32_ty
-                .fn_type(
-                    &[
-                        ctx_ptr_ty_basic_md,
-                        i32_ty_basic_md,
-                        i32_ty_basic_md,
-                        i32_ty_basic_md,
-                    ],
-                    false,
-                )
-                .ptr_type(AddressSpace::default()),
-
-            ctx_ptr_ty,
+            // LLVM > 15 has a single type for pointers.
+            ptr_ty,
         };
 
         let noreturn =
@@ -1254,9 +1103,9 @@ impl<'ctx> Intrinsics<'ctx> {
         intrinsics
             .throw_trap
             .add_attribute(AttributeLoc::Function, noreturn);
-        intrinsics
-            .func_ref
-            .add_attribute(AttributeLoc::Function, intrinsics.readonly);
+        //intrinsics
+        //    .func_ref
+        //    .add_attribute(AttributeLoc::Function, intrinsics.readonly);
 
         intrinsics
     }
@@ -1273,6 +1122,7 @@ pub enum MemoryCache<'ctx> {
     Static { base_ptr: PointerValue<'ctx> },
 }
 
+#[derive(Clone)]
 struct TableCache<'ctx> {
     ptr_to_base_ptr: PointerValue<'ctx>,
     ptr_to_bounds: PointerValue<'ctx>,
@@ -1352,7 +1202,7 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
         intrinsics: &Intrinsics<'ctx>,
         module: &Module<'ctx>,
         memory_styles: &PrimaryMap<MemoryIndex, MemoryStyle>,
-    ) -> MemoryCache<'ctx> {
+    ) -> Result<MemoryCache<'ctx>, CompileError> {
         let (cached_memories, wasm_module, ctx_ptr_value, cache_builder, offsets) = (
             &mut self.cached_memories,
             self.wasm_module,
@@ -1361,78 +1211,91 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
             &self.offsets,
         );
         let memory_style = &memory_styles[index];
-        *cached_memories.entry(index).or_insert_with(|| {
-            let memory_definition_ptr = if let Some(local_memory_index) =
-                wasm_module.local_memory_index(index)
-            {
-                let offset = offsets.vmctx_vmmemory_definition(local_memory_index);
-                let offset = intrinsics.i32_ty.const_int(offset.into(), false);
-                unsafe { cache_builder.build_gep(intrinsics.i8_ty, ctx_ptr_value, &[offset], "") }
-            } else {
-                let offset = offsets.vmctx_vmmemory_import(index);
-                let offset = intrinsics.i32_ty.const_int(offset.into(), false);
-                let memory_definition_ptr_ptr = unsafe {
-                    cache_builder.build_gep(intrinsics.i8_ty, ctx_ptr_value, &[offset], "")
-                };
-                let memory_definition_ptr_ptr = cache_builder
-                    .build_bitcast(
-                        memory_definition_ptr_ptr,
-                        intrinsics.i8_ptr_ty.ptr_type(AddressSpace::default()),
-                        "",
-                    )
-                    .into_pointer_value();
-                let memory_definition_ptr = cache_builder
-                    .build_load(intrinsics.i8_ptr_ty, memory_definition_ptr_ptr, "")
-                    .into_pointer_value();
-                tbaa_label(
-                    module,
-                    intrinsics,
-                    format!("memory {} definition", index.as_u32()),
-                    memory_definition_ptr.as_instruction_value().unwrap(),
-                );
-                memory_definition_ptr
-            };
-            let memory_definition_ptr = cache_builder
-                .build_bitcast(
+        match cached_memories.get(&index) {
+            Some(r) => Ok(*r),
+            None => {
+                let memory_definition_ptr =
+                    if let Some(local_memory_index) = wasm_module.local_memory_index(index) {
+                        let offset = offsets.vmctx_vmmemory_definition(local_memory_index);
+                        let offset = intrinsics.i32_ty.const_int(offset.into(), false);
+                        unsafe {
+                            err!(cache_builder.build_gep(
+                                intrinsics.i8_ty,
+                                ctx_ptr_value,
+                                &[offset],
+                                ""
+                            ))
+                        }
+                    } else {
+                        let offset = offsets.vmctx_vmmemory_import(index);
+                        let offset = intrinsics.i32_ty.const_int(offset.into(), false);
+                        let memory_definition_ptr_ptr = unsafe {
+                            err!(cache_builder.build_gep(
+                                intrinsics.i8_ty,
+                                ctx_ptr_value,
+                                &[offset],
+                                ""
+                            ))
+                        };
+                        let memory_definition_ptr_ptr = err!(cache_builder.build_bit_cast(
+                            memory_definition_ptr_ptr,
+                            intrinsics.ptr_ty,
+                            "",
+                        ))
+                        .into_pointer_value();
+                        let memory_definition_ptr = err!(cache_builder.build_load(
+                            intrinsics.ptr_ty,
+                            memory_definition_ptr_ptr,
+                            ""
+                        ))
+                        .into_pointer_value();
+                        tbaa_label(
+                            module,
+                            intrinsics,
+                            format!("memory {} definition", index.as_u32()),
+                            memory_definition_ptr.as_instruction_value().unwrap(),
+                        );
+                        memory_definition_ptr
+                    };
+                let memory_definition_ptr = err!(cache_builder.build_bit_cast(
                     memory_definition_ptr,
-                    intrinsics.vmmemory_definition_ptr_ty,
+                    intrinsics.ptr_ty,
                     "",
-                )
+                ))
                 .into_pointer_value();
-            let base_ptr = cache_builder
-                .build_struct_gep(
+                let base_ptr = err!(cache_builder.build_struct_gep(
                     intrinsics.vmmemory_definition_ty,
                     memory_definition_ptr,
                     intrinsics.vmmemory_definition_base_element,
                     "",
-                )
-                .unwrap();
-            if let MemoryStyle::Dynamic { .. } = memory_style {
-                let current_length_ptr = cache_builder
-                    .build_struct_gep(
+                ));
+                let value = if let MemoryStyle::Dynamic { .. } = memory_style {
+                    let current_length_ptr = err!(cache_builder.build_struct_gep(
                         intrinsics.vmmemory_definition_ty,
                         memory_definition_ptr,
                         intrinsics.vmmemory_definition_current_length_element,
                         "",
-                    )
-                    .unwrap();
-                MemoryCache::Dynamic {
-                    ptr_to_base_ptr: base_ptr,
-                    ptr_to_current_length: current_length_ptr,
-                }
-            } else {
-                let base_ptr = cache_builder
-                    .build_load(intrinsics.i8_ptr_ty, base_ptr, "")
-                    .into_pointer_value();
-                tbaa_label(
-                    module,
-                    intrinsics,
-                    format!("memory base_ptr {}", index.as_u32()),
-                    base_ptr.as_instruction_value().unwrap(),
-                );
-                MemoryCache::Static { base_ptr }
+                    ));
+                    MemoryCache::Dynamic {
+                        ptr_to_base_ptr: base_ptr,
+                        ptr_to_current_length: current_length_ptr,
+                    }
+                } else {
+                    let base_ptr = err!(cache_builder.build_load(intrinsics.ptr_ty, base_ptr, ""))
+                        .into_pointer_value();
+                    tbaa_label(
+                        module,
+                        intrinsics,
+                        format!("memory base_ptr {}", index.as_u32()),
+                        base_ptr.as_instruction_value().unwrap(),
+                    );
+                    MemoryCache::Static { base_ptr }
+                };
+
+                self.cached_memories.insert(index, value);
+                Ok(*self.cached_memories.get(&index).unwrap())
             }
-        })
+        }
     }
 
     fn table_prepare(
@@ -1440,7 +1303,7 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
         table_index: TableIndex,
         intrinsics: &Intrinsics<'ctx>,
         module: &Module<'ctx>,
-    ) -> (PointerValue<'ctx>, PointerValue<'ctx>) {
+    ) -> Result<(PointerValue<'ctx>, PointerValue<'ctx>), CompileError> {
         let (cached_tables, wasm_module, ctx_ptr_value, cache_builder, offsets) = (
             &mut self.cached_tables,
             self.wasm_module,
@@ -1451,9 +1314,12 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
         let TableCache {
             ptr_to_base_ptr,
             ptr_to_bounds,
-        } = *cached_tables.entry(table_index).or_insert_with(|| {
-            let (ptr_to_base_ptr, ptr_to_bounds) =
-                if let Some(local_table_index) = wasm_module.local_table_index(table_index) {
+        } = match cached_tables.entry(table_index) {
+            Entry::Occupied(entry) => entry.get().clone(),
+            Entry::Vacant(entry) => {
+                let (ptr_to_base_ptr, ptr_to_bounds) = if let Some(local_table_index) =
+                    wasm_module.local_table_index(table_index)
+                {
                     let offset = intrinsics.i64_ty.const_int(
                         offsets
                             .vmctx_vmtable_definition_base(local_table_index)
@@ -1461,15 +1327,16 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
                         false,
                     );
                     let ptr_to_base_ptr = unsafe {
-                        cache_builder.build_gep(intrinsics.i8_ty, ctx_ptr_value, &[offset], "")
+                        err!(cache_builder.build_gep(
+                            intrinsics.i8_ty,
+                            ctx_ptr_value,
+                            &[offset],
+                            ""
+                        ))
                     };
-                    let ptr_to_base_ptr = cache_builder
-                        .build_bitcast(
-                            ptr_to_base_ptr,
-                            intrinsics.i8_ptr_ty.ptr_type(AddressSpace::default()),
-                            "",
-                        )
-                        .into_pointer_value();
+                    let ptr_to_base_ptr =
+                        err!(cache_builder.build_bit_cast(ptr_to_base_ptr, intrinsics.ptr_ty, "",))
+                            .into_pointer_value();
                     let offset = intrinsics.i64_ty.const_int(
                         offsets
                             .vmctx_vmtable_definition_current_elements(local_table_index)
@@ -1477,11 +1344,16 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
                         false,
                     );
                     let ptr_to_bounds = unsafe {
-                        cache_builder.build_gep(intrinsics.i8_ty, ctx_ptr_value, &[offset], "")
+                        err!(cache_builder.build_gep(
+                            intrinsics.i8_ty,
+                            ctx_ptr_value,
+                            &[offset],
+                            ""
+                        ))
                     };
-                    let ptr_to_bounds = cache_builder
-                        .build_bitcast(ptr_to_bounds, intrinsics.i32_ptr_ty, "")
-                        .into_pointer_value();
+                    let ptr_to_bounds =
+                        err!(cache_builder.build_bit_cast(ptr_to_bounds, intrinsics.ptr_ty, ""))
+                            .into_pointer_value();
                     (ptr_to_base_ptr, ptr_to_bounds)
                 } else {
                     let offset = intrinsics.i64_ty.const_int(
@@ -1489,18 +1361,22 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
                         false,
                     );
                     let definition_ptr_ptr = unsafe {
-                        cache_builder.build_gep(intrinsics.i8_ty, ctx_ptr_value, &[offset], "")
+                        err!(cache_builder.build_gep(
+                            intrinsics.i8_ty,
+                            ctx_ptr_value,
+                            &[offset],
+                            ""
+                        ))
                     };
-                    let definition_ptr_ptr = cache_builder
-                        .build_bitcast(
-                            definition_ptr_ptr,
-                            intrinsics.i8_ptr_ty.ptr_type(AddressSpace::default()),
-                            "",
-                        )
-                        .into_pointer_value();
-                    let definition_ptr = cache_builder
-                        .build_load(intrinsics.i8_ptr_ty, definition_ptr_ptr, "")
-                        .into_pointer_value();
+                    let definition_ptr_ptr = err!(cache_builder.build_bit_cast(
+                        definition_ptr_ptr,
+                        intrinsics.ptr_ty,
+                        "",
+                    ))
+                    .into_pointer_value();
+                    let definition_ptr =
+                        err!(cache_builder.build_load(intrinsics.ptr_ty, definition_ptr_ptr, ""))
+                            .into_pointer_value();
                     tbaa_label(
                         module,
                         intrinsics,
@@ -1512,33 +1388,45 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
                         .i64_ty
                         .const_int(offsets.vmtable_definition_base().into(), false);
                     let ptr_to_base_ptr = unsafe {
-                        cache_builder.build_gep(intrinsics.i8_ty, definition_ptr, &[offset], "")
+                        err!(cache_builder.build_gep(
+                            intrinsics.i8_ty,
+                            definition_ptr,
+                            &[offset],
+                            ""
+                        ))
                     };
-                    let ptr_to_base_ptr = cache_builder
-                        .build_bitcast(
-                            ptr_to_base_ptr,
-                            intrinsics.i8_ptr_ty.ptr_type(AddressSpace::default()),
-                            "",
-                        )
-                        .into_pointer_value();
+                    let ptr_to_base_ptr =
+                        err!(cache_builder.build_bit_cast(ptr_to_base_ptr, intrinsics.ptr_ty, "",))
+                            .into_pointer_value();
                     let offset = intrinsics
                         .i64_ty
                         .const_int(offsets.vmtable_definition_current_elements().into(), false);
                     let ptr_to_bounds = unsafe {
-                        cache_builder.build_gep(intrinsics.i8_ty, definition_ptr, &[offset], "")
+                        err!(cache_builder.build_gep(
+                            intrinsics.i8_ty,
+                            definition_ptr,
+                            &[offset],
+                            ""
+                        ))
                     };
-                    let ptr_to_bounds = cache_builder
-                        .build_bitcast(ptr_to_bounds, intrinsics.i32_ptr_ty, "")
-                        .into_pointer_value();
+                    let ptr_to_bounds =
+                        err!(cache_builder.build_bit_cast(ptr_to_bounds, intrinsics.ptr_ty, ""))
+                            .into_pointer_value();
                     (ptr_to_base_ptr, ptr_to_bounds)
                 };
-            TableCache {
-                ptr_to_base_ptr,
-                ptr_to_bounds,
+
+                let v = TableCache {
+                    ptr_to_base_ptr,
+                    ptr_to_bounds,
+                };
+
+                entry.insert(v.clone());
+
+                v
             }
-        });
+        };
 
-        (ptr_to_base_ptr, ptr_to_bounds)
+        Ok((ptr_to_base_ptr, ptr_to_bounds))
     }
 
     pub fn table(
@@ -1546,15 +1434,17 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
         index: TableIndex,
         intrinsics: &Intrinsics<'ctx>,
         module: &Module<'ctx>,
-    ) -> (PointerValue<'ctx>, IntValue<'ctx>) {
-        let (ptr_to_base_ptr, ptr_to_bounds) = self.table_prepare(index, intrinsics, module);
-        let base_ptr = self
-            .cache_builder
-            .build_load(intrinsics.i8_ptr_ty, ptr_to_base_ptr, "base_ptr")
+    ) -> Result<(PointerValue<'ctx>, IntValue<'ctx>), CompileError> {
+        let (ptr_to_base_ptr, ptr_to_bounds) = self.table_prepare(index, intrinsics, module)?;
+        let base_ptr =
+            err!(self
+                .cache_builder
+                .build_load(intrinsics.ptr_ty, ptr_to_base_ptr, "base_ptr"))
             .into_pointer_value();
-        let bounds = self
-            .cache_builder
-            .build_load(intrinsics.isize_ty, ptr_to_bounds, "bounds")
+        let bounds =
+            err!(self
+                .cache_builder
+                .build_load(intrinsics.isize_ty, ptr_to_bounds, "bounds"))
             .into_int_value();
         tbaa_label(
             module,
@@ -1568,7 +1458,7 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
             format!("table_bounds {}", index.index()),
             bounds.as_instruction_value().unwrap(),
         );
-        (base_ptr, bounds)
+        Ok((base_ptr, bounds))
     }
 
     pub fn dynamic_sigindex(
@@ -1576,40 +1466,48 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
         index: SignatureIndex,
         intrinsics: &Intrinsics<'ctx>,
         module: &Module<'ctx>,
-    ) -> IntValue<'ctx> {
+    ) -> Result<IntValue<'ctx>, CompileError> {
         let (cached_sigindices, ctx_ptr_value, cache_builder, offsets) = (
             &mut self.cached_sigindices,
             self.ctx_ptr_value,
             &self.cache_builder,
             &self.offsets,
         );
-        *cached_sigindices.entry(index).or_insert_with(|| {
-            let byte_offset = intrinsics
-                .i64_ty
-                .const_int(offsets.vmctx_vmshared_signature_id(index).into(), false);
-            let sigindex_ptr = unsafe {
-                cache_builder.build_gep(
-                    intrinsics.i8_ty,
-                    ctx_ptr_value,
-                    &[byte_offset],
-                    "dynamic_sigindex",
-                )
-            };
-            let sigindex_ptr = cache_builder
-                .build_bitcast(sigindex_ptr, intrinsics.i32_ptr_ty, "")
-                .into_pointer_value();
 
-            let sigindex = cache_builder
-                .build_load(intrinsics.i32_ty, sigindex_ptr, "sigindex")
-                .into_int_value();
-            tbaa_label(
-                module,
-                intrinsics,
-                format!("sigindex {}", index.as_u32()),
-                sigindex.as_instruction_value().unwrap(),
-            );
-            sigindex
-        })
+        match cached_sigindices.entry(index) {
+            Entry::Occupied(entry) => Ok(*entry.get()),
+            Entry::Vacant(entry) => {
+                let byte_offset = intrinsics
+                    .i64_ty
+                    .const_int(offsets.vmctx_vmshared_signature_id(index).into(), false);
+
+                let sigindex_ptr = unsafe {
+                    err!(cache_builder.build_gep(
+                        intrinsics.i8_ty,
+                        ctx_ptr_value,
+                        &[byte_offset],
+                        "dynamic_sigindex",
+                    ))
+                };
+
+                let sigindex_ptr =
+                    err!(cache_builder.build_bit_cast(sigindex_ptr, intrinsics.ptr_ty, ""))
+                        .into_pointer_value();
+
+                let sigindex =
+                    err!(cache_builder.build_load(intrinsics.i32_ty, sigindex_ptr, "sigindex"))
+                        .into_int_value();
+                tbaa_label(
+                    module,
+                    intrinsics,
+                    format!("sigindex {}", index.as_u32()),
+                    sigindex.as_instruction_value().unwrap(),
+                );
+
+                entry.insert(sigindex);
+                Ok(sigindex)
+            }
+        }
     }
 
     pub fn global(
@@ -1625,8 +1523,8 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
             &self.cache_builder,
             &self.offsets,
         );
-        Ok(match cached_globals.entry(index) {
-            Entry::Occupied(entry) => entry.into_mut(),
+        match cached_globals.entry(index) {
+            Entry::Occupied(entry) => Ok(entry.into_mut()),
             Entry::Vacant(entry) => {
                 let global_type = wasm_module.globals[index];
                 let global_value_type = global_type.ty;
@@ -1641,18 +1539,19 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
                 let offset = intrinsics.i32_ty.const_int(offset.into(), false);
                 let global_ptr = {
                     let global_ptr_ptr = unsafe {
-                        cache_builder.build_gep(intrinsics.i8_ty, ctx_ptr_value, &[offset], "")
+                        err!(cache_builder.build_gep(
+                            intrinsics.i8_ty,
+                            ctx_ptr_value,
+                            &[offset],
+                            ""
+                        ))
                     };
-                    let global_ptr_ptr = cache_builder
-                        .build_bitcast(
-                            global_ptr_ptr,
-                            intrinsics.i32_ptr_ty.ptr_type(AddressSpace::default()),
-                            "",
-                        )
-                        .into_pointer_value();
-                    let global_ptr = cache_builder
-                        .build_load(intrinsics.i32_ptr_ty, global_ptr_ptr, "")
-                        .into_pointer_value();
+                    let global_ptr_ptr =
+                        err!(cache_builder.build_bit_cast(global_ptr_ptr, intrinsics.ptr_ty, "",))
+                            .into_pointer_value();
+                    let global_ptr =
+                        err!(cache_builder.build_load(intrinsics.ptr_ty, global_ptr_ptr, ""))
+                            .into_pointer_value();
                     tbaa_label(
                         module,
                         intrinsics,
@@ -1661,21 +1560,20 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
                     );
                     global_ptr
                 };
-                let global_ptr = cache_builder
-                    .build_bitcast(
-                        global_ptr,
-                        type_to_llvm_ptr(intrinsics, global_value_type)?,
-                        "",
-                    )
-                    .into_pointer_value();
+                let global_ptr = err!(cache_builder.build_bit_cast(
+                    global_ptr,
+                    type_to_llvm_ptr(intrinsics, global_value_type)?,
+                    "",
+                ))
+                .into_pointer_value();
 
-                entry.insert(match global_mutability {
+                let ret = entry.insert(match global_mutability {
                     Mutability::Const => {
-                        let value = cache_builder.build_load(
+                        let value = err!(cache_builder.build_load(
                             type_to_llvm(intrinsics, global_value_type)?,
                             global_ptr,
                             "",
-                        );
+                        ));
                         tbaa_label(
                             module,
                             intrinsics,
@@ -1688,9 +1586,11 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
                         ptr_to_value: global_ptr,
                         value_type: type_to_llvm(intrinsics, global_value_type)?,
                     },
-                })
+                });
+
+                Ok(ret)
             }
-        })
+        }
     }
 
     pub fn add_func(
@@ -1766,8 +1666,8 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
             &self.cache_builder,
             &self.offsets,
         );
-        Ok(match cached_functions.entry(function_index) {
-            Entry::Occupied(entry) => entry.into_mut(),
+        match cached_functions.entry(function_index) {
+            Entry::Occupied(entry) => Ok(entry.into_mut()),
             Entry::Vacant(entry) => {
                 let (llvm_func_type, llvm_func_attrs) =
                     self.abi
@@ -1776,56 +1676,48 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
                 let offset = offsets.vmctx_vmfunction_import(function_index);
                 let offset = intrinsics.i32_ty.const_int(offset.into(), false);
                 let vmfunction_import_ptr = unsafe {
-                    cache_builder.build_gep(intrinsics.i8_ty, *ctx_ptr_value, &[offset], "")
+                    err!(cache_builder.build_gep(intrinsics.i8_ty, *ctx_ptr_value, &[offset], ""))
                 };
-                let vmfunction_import_ptr = cache_builder
-                    .build_bitcast(
-                        vmfunction_import_ptr,
-                        intrinsics.vmfunction_import_ptr_ty,
-                        "",
-                    )
-                    .into_pointer_value();
+                let vmfunction_import_ptr = err!(cache_builder.build_bit_cast(
+                    vmfunction_import_ptr,
+                    intrinsics.ptr_ty,
+                    "",
+                ))
+                .into_pointer_value();
 
-                let body_ptr_ptr = cache_builder
-                    .build_struct_gep(
-                        intrinsics.vmfunction_import_ty,
-                        vmfunction_import_ptr,
-                        intrinsics.vmfunction_import_body_element,
-                        "",
-                    )
-                    .unwrap();
-                let body_ptr = cache_builder.build_load(intrinsics.i8_ptr_ty, body_ptr_ptr, "");
-                let body_ptr = cache_builder
-                    .build_bitcast(
-                        body_ptr,
-                        llvm_func_type.ptr_type(AddressSpace::default()),
-                        "",
-                    )
+                let body_ptr_ptr = err!(cache_builder.build_struct_gep(
+                    intrinsics.vmfunction_import_ty,
+                    vmfunction_import_ptr,
+                    intrinsics.vmfunction_import_body_element,
+                    "",
+                ));
+                let body_ptr = err!(cache_builder.build_load(intrinsics.ptr_ty, body_ptr_ptr, ""));
+                let body_ptr = err!(cache_builder.build_bit_cast(body_ptr, intrinsics.ptr_ty, "",))
                     .into_pointer_value();
-                let vmctx_ptr_ptr = cache_builder
-                    .build_struct_gep(
-                        intrinsics.vmfunction_import_ty,
-                        vmfunction_import_ptr,
-                        intrinsics.vmfunction_import_vmctx_element,
-                        "",
-                    )
-                    .unwrap();
-                let vmctx_ptr = cache_builder.build_load(intrinsics.ctx_ptr_ty, vmctx_ptr_ptr, "");
-                entry.insert(FunctionCache {
+                let vmctx_ptr_ptr = err!(cache_builder.build_struct_gep(
+                    intrinsics.vmfunction_import_ty,
+                    vmfunction_import_ptr,
+                    intrinsics.vmfunction_import_vmctx_element,
+                    "",
+                ));
+                let vmctx_ptr =
+                    err!(cache_builder.build_load(intrinsics.ptr_ty, vmctx_ptr_ptr, ""));
+
+                Ok(entry.insert(FunctionCache {
                     func: body_ptr,
                     llvm_func_type,
                     vmctx: vmctx_ptr,
                     attrs: llvm_func_attrs,
-                })
+                }))
             }
-        })
+        }
     }
 
     pub fn memory_grow(
         &mut self,
         memory_index: MemoryIndex,
         intrinsics: &Intrinsics<'ctx>,
-    ) -> PointerValue<'ctx> {
+    ) -> Result<PointerValue<'ctx>, CompileError> {
         let (cached_memory_grow, wasm_module, offsets, cache_builder, ctx_ptr_value) = (
             &mut self.cached_memory_grow,
             &self.wasm_module,
@@ -1833,41 +1725,44 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
             &self.cache_builder,
             &self.ctx_ptr_value,
         );
-        *cached_memory_grow.entry(memory_index).or_insert_with(|| {
-            let (grow_fn, grow_fn_ty) = if wasm_module.local_memory_index(memory_index).is_some() {
-                (
-                    VMBuiltinFunctionIndex::get_memory32_grow_index(),
-                    intrinsics.memory32_grow_ptr_ty,
-                )
-            } else {
-                (
-                    VMBuiltinFunctionIndex::get_imported_memory32_grow_index(),
-                    intrinsics.imported_memory32_grow_ptr_ty,
-                )
-            };
-            let offset = offsets.vmctx_builtin_function(grow_fn);
-            let offset = intrinsics.i32_ty.const_int(offset.into(), false);
-            let grow_fn_ptr_ptr =
-                unsafe { cache_builder.build_gep(intrinsics.i8_ty, *ctx_ptr_value, &[offset], "") };
-
-            let grow_fn_ptr_ptr = cache_builder
-                .build_bitcast(
-                    grow_fn_ptr_ptr,
-                    grow_fn_ty.ptr_type(AddressSpace::default()),
-                    "",
-                )
-                .into_pointer_value();
-            cache_builder
-                .build_load(grow_fn_ty, grow_fn_ptr_ptr, "")
-                .into_pointer_value()
-        })
+        match cached_memory_grow.entry(memory_index) {
+            Entry::Occupied(entry) => Ok(*entry.get()),
+            Entry::Vacant(entry) => {
+                let (grow_fn, grow_fn_ty) =
+                    if wasm_module.local_memory_index(memory_index).is_some() {
+                        (
+                            VMBuiltinFunctionIndex::get_memory32_grow_index(),
+                            intrinsics.ptr_ty,
+                        )
+                    } else {
+                        (
+                            VMBuiltinFunctionIndex::get_imported_memory32_grow_index(),
+                            intrinsics.ptr_ty,
+                        )
+                    };
+                let offset = offsets.vmctx_builtin_function(grow_fn);
+                let offset = intrinsics.i32_ty.const_int(offset.into(), false);
+                let grow_fn_ptr_ptr = unsafe {
+                    err!(cache_builder.build_gep(intrinsics.i8_ty, *ctx_ptr_value, &[offset], ""))
+                };
+
+                let grow_fn_ptr_ptr =
+                    err!(cache_builder.build_bit_cast(grow_fn_ptr_ptr, intrinsics.ptr_ty, "",))
+                        .into_pointer_value();
+                let val = err!(cache_builder.build_load(grow_fn_ty, grow_fn_ptr_ptr, ""))
+                    .into_pointer_value();
+
+                entry.insert(val);
+                Ok(val)
+            }
+        }
     }
 
     pub fn memory_size(
         &mut self,
         memory_index: MemoryIndex,
         intrinsics: &Intrinsics<'ctx>,
-    ) -> PointerValue<'ctx> {
+    ) -> Result<PointerValue<'ctx>, CompileError> {
         let (cached_memory_size, wasm_module, offsets, cache_builder, ctx_ptr_value) = (
             &mut self.cached_memory_size,
             &self.wasm_module,
@@ -1875,42 +1770,45 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
             &self.cache_builder,
             &self.ctx_ptr_value,
         );
-        *cached_memory_size.entry(memory_index).or_insert_with(|| {
-            let (size_fn, size_fn_ty) = if wasm_module.local_memory_index(memory_index).is_some() {
-                (
-                    VMBuiltinFunctionIndex::get_memory32_size_index(),
-                    intrinsics.memory32_size_ptr_ty,
-                )
-            } else {
-                (
-                    VMBuiltinFunctionIndex::get_imported_memory32_size_index(),
-                    intrinsics.imported_memory32_size_ptr_ty,
-                )
-            };
-            let offset = offsets.vmctx_builtin_function(size_fn);
-            let offset = intrinsics.i32_ty.const_int(offset.into(), false);
-            let size_fn_ptr_ptr =
-                unsafe { cache_builder.build_gep(intrinsics.i8_ty, *ctx_ptr_value, &[offset], "") };
-
-            let size_fn_ptr_ptr = cache_builder
-                .build_bitcast(
-                    size_fn_ptr_ptr,
-                    size_fn_ty.ptr_type(AddressSpace::default()),
-                    "",
-                )
-                .into_pointer_value();
 
-            cache_builder
-                .build_load(size_fn_ty, size_fn_ptr_ptr, "")
-                .into_pointer_value()
-        })
+        match cached_memory_size.entry(memory_index) {
+            Entry::Occupied(entry) => Ok(*entry.get()),
+            Entry::Vacant(entry) => {
+                let (size_fn, size_fn_ty) =
+                    if wasm_module.local_memory_index(memory_index).is_some() {
+                        (
+                            VMBuiltinFunctionIndex::get_memory32_size_index(),
+                            intrinsics.ptr_ty,
+                        )
+                    } else {
+                        (
+                            VMBuiltinFunctionIndex::get_imported_memory32_size_index(),
+                            intrinsics.ptr_ty,
+                        )
+                    };
+                let offset = offsets.vmctx_builtin_function(size_fn);
+                let offset = intrinsics.i32_ty.const_int(offset.into(), false);
+                let size_fn_ptr_ptr = unsafe {
+                    err!(cache_builder.build_gep(intrinsics.i8_ty, *ctx_ptr_value, &[offset], ""))
+                };
+
+                let size_fn_ptr_ptr =
+                    err!(cache_builder.build_bit_cast(size_fn_ptr_ptr, intrinsics.ptr_ty, "",))
+                        .into_pointer_value();
+
+                let val = err!(cache_builder.build_load(size_fn_ty, size_fn_ptr_ptr, ""))
+                    .into_pointer_value();
+                entry.insert(val);
+                Ok(val)
+            }
+        }
     }
 
     pub fn memory_wait32(
         &mut self,
         memory_index: MemoryIndex,
         intrinsics: &Intrinsics<'ctx>,
-    ) -> PointerValue<'ctx> {
+    ) -> Result<PointerValue<'ctx>, CompileError> {
         let (cached_memory_size, wasm_module, offsets, cache_builder, ctx_ptr_value) = (
             &mut self.cached_memory_size,
             &self.wasm_module,
@@ -1918,42 +1816,45 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
             &self.cache_builder,
             &self.ctx_ptr_value,
         );
-        *cached_memory_size.entry(memory_index).or_insert_with(|| {
-            let (size_fn, size_fn_ty) = if wasm_module.local_memory_index(memory_index).is_some() {
-                (
-                    VMBuiltinFunctionIndex::get_memory_atomic_wait32_index(),
-                    intrinsics.memory32_wait32_ptr_ty,
-                )
-            } else {
-                (
-                    VMBuiltinFunctionIndex::get_imported_memory_atomic_wait32_index(),
-                    intrinsics.imported_memory32_wait32_ptr_ty,
-                )
-            };
-            let offset = offsets.vmctx_builtin_function(size_fn);
-            let offset = intrinsics.i32_ty.const_int(offset.into(), false);
-            let size_fn_ptr_ptr =
-                unsafe { cache_builder.build_gep(intrinsics.i8_ty, *ctx_ptr_value, &[offset], "") };
-
-            let size_fn_ptr_ptr = cache_builder
-                .build_bitcast(
-                    size_fn_ptr_ptr,
-                    size_fn_ty.ptr_type(AddressSpace::default()),
-                    "",
-                )
-                .into_pointer_value();
+        match cached_memory_size.entry(memory_index) {
+            Entry::Occupied(entry) => Ok(*entry.get()),
+            Entry::Vacant(entry) => {
+                let (size_fn, size_fn_ty) =
+                    if wasm_module.local_memory_index(memory_index).is_some() {
+                        (
+                            VMBuiltinFunctionIndex::get_memory_atomic_wait32_index(),
+                            intrinsics.ptr_ty,
+                        )
+                    } else {
+                        (
+                            VMBuiltinFunctionIndex::get_imported_memory_atomic_wait32_index(),
+                            intrinsics.ptr_ty,
+                        )
+                    };
+                let offset = offsets.vmctx_builtin_function(size_fn);
+                let offset = intrinsics.i32_ty.const_int(offset.into(), false);
+                let size_fn_ptr_ptr = unsafe {
+                    err!(cache_builder.build_gep(intrinsics.i8_ty, *ctx_ptr_value, &[offset], ""))
+                };
 
-            cache_builder
-                .build_load(size_fn_ty, size_fn_ptr_ptr, "")
-                .into_pointer_value()
-        })
+                let size_fn_ptr_ptr =
+                    err!(cache_builder.build_bit_cast(size_fn_ptr_ptr, intrinsics.ptr_ty, "",))
+                        .into_pointer_value();
+
+                let val = err!(cache_builder.build_load(size_fn_ty, size_fn_ptr_ptr, ""))
+                    .into_pointer_value();
+
+                entry.insert(val);
+                Ok(val)
+            }
+        }
     }
 
     pub fn memory_wait64(
         &mut self,
         memory_index: MemoryIndex,
         intrinsics: &Intrinsics<'ctx>,
-    ) -> PointerValue<'ctx> {
+    ) -> Result<PointerValue<'ctx>, CompileError> {
         let (cached_memory_size, wasm_module, offsets, cache_builder, ctx_ptr_value) = (
             &mut self.cached_memory_size,
             &self.wasm_module,
@@ -1961,42 +1862,45 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
             &self.cache_builder,
             &self.ctx_ptr_value,
         );
-        *cached_memory_size.entry(memory_index).or_insert_with(|| {
-            let (size_fn, size_fn_ty) = if wasm_module.local_memory_index(memory_index).is_some() {
-                (
-                    VMBuiltinFunctionIndex::get_memory_atomic_wait64_index(),
-                    intrinsics.memory32_wait64_ptr_ty,
-                )
-            } else {
-                (
-                    VMBuiltinFunctionIndex::get_imported_memory_atomic_wait64_index(),
-                    intrinsics.imported_memory32_wait64_ptr_ty,
-                )
-            };
-            let offset = offsets.vmctx_builtin_function(size_fn);
-            let offset = intrinsics.i32_ty.const_int(offset.into(), false);
-            let size_fn_ptr_ptr =
-                unsafe { cache_builder.build_gep(intrinsics.i8_ty, *ctx_ptr_value, &[offset], "") };
-
-            let size_fn_ptr_ptr = cache_builder
-                .build_bitcast(
-                    size_fn_ptr_ptr,
-                    size_fn_ty.ptr_type(AddressSpace::default()),
-                    "",
-                )
-                .into_pointer_value();
 
-            cache_builder
-                .build_load(size_fn_ty, size_fn_ptr_ptr, "")
-                .into_pointer_value()
-        })
+        match cached_memory_size.entry(memory_index) {
+            Entry::Occupied(entry) => Ok(*entry.get()),
+            Entry::Vacant(entry) => {
+                let (size_fn, size_fn_ty) =
+                    if wasm_module.local_memory_index(memory_index).is_some() {
+                        (
+                            VMBuiltinFunctionIndex::get_memory_atomic_wait64_index(),
+                            intrinsics.ptr_ty,
+                        )
+                    } else {
+                        (
+                            VMBuiltinFunctionIndex::get_imported_memory_atomic_wait64_index(),
+                            intrinsics.ptr_ty,
+                        )
+                    };
+                let offset = offsets.vmctx_builtin_function(size_fn);
+                let offset = intrinsics.i32_ty.const_int(offset.into(), false);
+                let size_fn_ptr_ptr = unsafe {
+                    err!(cache_builder.build_gep(intrinsics.i8_ty, *ctx_ptr_value, &[offset], ""))
+                };
+
+                let size_fn_ptr_ptr =
+                    err!(cache_builder.build_bit_cast(size_fn_ptr_ptr, intrinsics.ptr_ty, ""))
+                        .into_pointer_value();
+
+                let val = err!(cache_builder.build_load(size_fn_ty, size_fn_ptr_ptr, ""))
+                    .into_pointer_value();
+                entry.insert(val);
+                Ok(val)
+            }
+        }
     }
 
     pub fn memory_notify(
         &mut self,
         memory_index: MemoryIndex,
         intrinsics: &Intrinsics<'ctx>,
-    ) -> PointerValue<'ctx> {
+    ) -> Result<PointerValue<'ctx>, CompileError> {
         let (cached_memory_size, wasm_module, offsets, cache_builder, ctx_ptr_value) = (
             &mut self.cached_memory_size,
             &self.wasm_module,
@@ -2004,35 +1908,38 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
             &self.cache_builder,
             &self.ctx_ptr_value,
         );
-        *cached_memory_size.entry(memory_index).or_insert_with(|| {
-            let (size_fn, size_fn_ty) = if wasm_module.local_memory_index(memory_index).is_some() {
-                (
-                    VMBuiltinFunctionIndex::get_memory_atomic_notify_index(),
-                    intrinsics.memory32_notify_ptr_ty,
-                )
-            } else {
-                (
-                    VMBuiltinFunctionIndex::get_imported_memory_atomic_notify_index(),
-                    intrinsics.imported_memory32_notify_ptr_ty,
-                )
-            };
-            let offset = offsets.vmctx_builtin_function(size_fn);
-            let offset = intrinsics.i32_ty.const_int(offset.into(), false);
-            let size_fn_ptr_ptr =
-                unsafe { cache_builder.build_gep(intrinsics.i8_ty, *ctx_ptr_value, &[offset], "") };
-
-            let size_fn_ptr_ptr = cache_builder
-                .build_bitcast(
-                    size_fn_ptr_ptr,
-                    size_fn_ty.ptr_type(AddressSpace::default()),
-                    "",
-                )
-                .into_pointer_value();
+        match cached_memory_size.entry(memory_index) {
+            Entry::Occupied(entry) => Ok(*entry.get()),
+            Entry::Vacant(entry) => {
+                let (size_fn, size_fn_ty) =
+                    if wasm_module.local_memory_index(memory_index).is_some() {
+                        (
+                            VMBuiltinFunctionIndex::get_memory_atomic_notify_index(),
+                            intrinsics.ptr_ty,
+                        )
+                    } else {
+                        (
+                            VMBuiltinFunctionIndex::get_imported_memory_atomic_notify_index(),
+                            intrinsics.ptr_ty,
+                        )
+                    };
+                let offset = offsets.vmctx_builtin_function(size_fn);
+                let offset = intrinsics.i32_ty.const_int(offset.into(), false);
+                let size_fn_ptr_ptr = unsafe {
+                    err!(cache_builder.build_gep(intrinsics.i8_ty, *ctx_ptr_value, &[offset], ""))
+                };
 
-            cache_builder
-                .build_load(size_fn_ty, size_fn_ptr_ptr, "")
-                .into_pointer_value()
-        })
+                let size_fn_ptr_ptr =
+                    err!(cache_builder.build_bit_cast(size_fn_ptr_ptr, intrinsics.ptr_ty, "",))
+                        .into_pointer_value();
+
+                let val = err!(cache_builder.build_load(size_fn_ty, size_fn_ptr_ptr, ""))
+                    .into_pointer_value();
+
+                entry.insert(val);
+                Ok(val)
+            }
+        }
     }
 
     pub fn get_offsets(&self) -> &VMOffsets {


Test patch:
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index f36ecc2b87b..1bdb0a1985b 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -64,11 +64,11 @@ jobs:
           sudo apt install -y libtinfo5
       - name: Install LLVM (Linux)
         run: |
-          curl --proto '=https' --tlsv1.2 -sSf https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.6/clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04.tar.xz -L -o /opt/llvm.tar.xz
-          mkdir -p /opt/llvm-15
-          tar xf /opt/llvm.tar.xz --strip-components=1 -C /opt/llvm-15
-          echo '/opt/llvm-15/bin' >> $GITHUB_PATH
-          echo 'LLVM_SYS_150_PREFIX=/opt/llvm-15' >> $GITHUB_ENV
+          curl --proto '=https' --tlsv1.2 -sSf https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-linux-amd64.tar.xz -L -o /opt/llvm.tar.xz
+          mkdir -p /opt/llvm-18
+          tar xf /opt/llvm.tar.xz --strip-components=1 -C /opt/llvm-18
+          echo '/opt/llvm-18/bin' >> $GITHUB_PATH
+          echo 'LLVM_SYS_180_PREFIX=/opt/llvm-18' >> $GITHUB_ENV
       - name: Cache
         uses: whywaita/actions-cache-s3@v2
         with:
@@ -135,6 +135,18 @@ jobs:
       - name: Install wasm-pack
         run: |
           curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
+      - name: Install LLVM 18
+        run: |
+          curl --proto '=https' --tlsv1.2 -sSf https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-linux-amd64.tar.xz -L -o llvm.tar.xz
+          LLVM_DIR=$(pwd)/${{ env.LLVM_DIR }}
+          mkdir ${LLVM_DIR}
+          tar xf llvm.tar.xz --strip-components=1 -C ${LLVM_DIR}
+          echo "ENABLE_LLVM=1" >> $GITHUB_ENV
+          echo "${LLVM_DIR}/bin" >> $GITHUB_PATH
+          echo "${LLVM_DIR}/usr/bin" >> $GITHUB_PATH
+          echo "LLVM_SYS_180_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
+        env:
+          LLVM_DIR: .llvm
       - name: make test-wasi-fyi
         run: |
           make test-wasi-fyi
@@ -171,6 +183,18 @@ jobs:
           curl -L "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${{ env.WASI_SDK_VERSION }}/wasi-sdk-${{ env.WASI_SDK_VERSION }}.0-linux.tar.gz" -o wasi-sdk.tar.gz
           tar -xzf wasi-sdk.tar.gz
           cp -r wasi-sdk-${{ env.WASI_SDK_VERSION }}.0 ~/wasi-sdk
+      - name: Install LLVM 18
+        run: |
+          curl --proto '=https' --tlsv1.2 -sSf https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-linux-amd64.tar.xz -L -o llvm.tar.xz
+          LLVM_DIR=$(pwd)/${{ env.LLVM_DIR }}
+          mkdir ${LLVM_DIR}
+          tar xf llvm.tar.xz --strip-components=1 -C ${LLVM_DIR}
+          echo "ENABLE_LLVM=1" >> $GITHUB_ENV
+          echo "${LLVM_DIR}/bin" >> $GITHUB_PATH
+          echo "${LLVM_DIR}/usr/bin" >> $GITHUB_PATH
+          echo "LLVM_SYS_180_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
+        env:
+          LLVM_DIR: .llvm
       - name: Install wasm-opt
         run: |
           sudo apt-get install -y binaryen
@@ -216,6 +240,18 @@ jobs:
           toolchain: "nightly-2024-08-21"
           target: x86_64-unknown-linux-gnu
       - run: cargo install toml-cli # toml-cli is required to run `make test-build-docs-rs`
+      - name: Install LLVM 18
+        run: |
+          curl --proto '=https' --tlsv1.2 -sSf https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-linux-amd64.tar.xz -L -o llvm.tar.xz
+          LLVM_DIR=$(pwd)/${{ env.LLVM_DIR }}
+          mkdir ${LLVM_DIR}
+          tar xf llvm.tar.xz --strip-components=1 -C ${LLVM_DIR}
+          echo "ENABLE_LLVM=1" >> $GITHUB_ENV
+          echo "${LLVM_DIR}/bin" >> $GITHUB_PATH
+          echo "${LLVM_DIR}/usr/bin" >> $GITHUB_PATH
+          echo "LLVM_SYS_180_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
+        env:
+          LLVM_DIR: .llvm
       - name: make test-build-docs-rs-ci
         run: make test-build-docs-rs-ci
 
@@ -361,36 +397,41 @@ jobs:
             build: linux-x64,
             os: ubuntu-22.04,
             target: x86_64-unknown-linux-gnu,
-            llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.6/clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04.tar.xz'
-          },
-          {
-            build: linux-musl,
-            target: x86_64-unknown-linux-musl,
-            os: ubuntu-22.04,
-            container: 'alpine:latest'
+            exe: '',
+            llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-linux-amd64.tar.xz'
           },
           {
             build: macos-x64,
             os: macos-12,
             target: x86_64-apple-darwin,
-            llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/clang+llvm-15.0.7-x86_64-apple-darwin21.0.tar.xz'
+            exe: '',
+            llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-darwin-amd64.tar.xz'
+
           },
           {
-            build: macos-arm,
-            os: macos-12,
+            build: macos-arm64,
+            os: macos-14,
             target: aarch64-apple-darwin,
+            exe: '',
+            # [todo] xdoardo: Reinstate when the code we generate for aarch64 is working correctly. 
+            # llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-darwin-aarch64.tar.xz'
           },
           {
             build: windows-x64,
-            os: windows-2019,
+            os: windows-2022,
             target: x86_64-pc-windows-msvc,
-            llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/15.x/llvm-windows-amd64.tar.xz'
+            exe: '.exe',
+            # For now, disable LLVM in `windows-x64.`
+            # llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-windows-amd64.tar.xz'
           },
           {
-            build: windows-gnu,
-            target: x86_64-pc-windows-gnu,
+            build: linux-musl,
+            target: x86_64-unknown-linux-musl,
             os: ubuntu-22.04,
+            exe: '',
+            container: 'alpine:latest'
           }
+
         ]
     container: ${{ matrix.metadata.container }}
     env:
@@ -421,6 +462,13 @@ jobs:
           target: ${{ matrix.metadata.target }}
       - name: Install Nextest
         uses: taiki-e/install-action@nextest
+      - name: Install MSVC dev-cmd (Windows)
+        uses: ilammy/msvc-dev-cmd@v1
+        if: ${{ matrix.metadata.build == 'windows-x64' }}
+      - name: Delete unwanted link to stop it from interfering (Windows) 
+        shell: bash
+        run: rm /usr/bin/link.exe
+        if: ${{ matrix.metadata.build == 'windows-x64' }}
       - name: Install Windows-GNU linker
         if: ${{ matrix.metadata.build == 'windows-gnu' }}
         shell: bash
@@ -458,8 +506,8 @@ jobs:
         run: |
           brew install llvm
       - name: Install LLVM
-        if: matrix.metadata.llvm_url
         shell: bash
+        if: matrix.metadata.llvm_url
         run: |
           curl --proto '=https' --tlsv1.2 -sSf ${{ matrix.metadata.llvm_url }} -L -o llvm.tar.xz
           LLVM_DIR=$(pwd)/${{ env.LLVM_DIR }}
@@ -468,9 +516,14 @@ jobs:
           echo "ENABLE_LLVM=1" >> $GITHUB_ENV
           echo "${LLVM_DIR}/bin" >> $GITHUB_PATH
           echo "${LLVM_DIR}/usr/bin" >> $GITHUB_PATH
-          echo "LLVM_SYS_150_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
+          echo "LLVM_SYS_180_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
         env:
           LLVM_DIR: .llvm
+      - name: Add `brew` libs to `RUSTFLAGS`
+        if: matrix.metadata.os == 'macos-14'
+        shell: bash
+        run: |
+          echo "RUSTFLAGS=-L/opt/homebrew/lib" >> $GITHUB_ENV
       - name: Setup Rust target
         shell: bash
         run: |
@@ -592,27 +645,31 @@ jobs:
             os: ubuntu-22.04,
             target: x86_64-unknown-linux-gnu,
             exe: '',
-            llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.6/clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04.tar.xz'
+            llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-linux-amd64.tar.xz'
           },
           {
             build: macos-x64,
             os: macos-12,
             target: x86_64-apple-darwin,
             exe: '',
-            llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/clang+llvm-15.0.7-x86_64-apple-darwin21.0.tar.xz'
+            llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-darwin-amd64.tar.xz'
+
           },
           {
             build: macos-arm64,
             os: macos-14,
             target: aarch64-apple-darwin,
             exe: '',
+            # [todo] xdoardo: Reinstate when the code we generate for aarch64 is working correctly. 
+            # llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-darwin-aarch64.tar.xz'
           },
           {
             build: windows-x64,
-            os: windows-2019,
+            os: windows-2022,
             target: x86_64-pc-windows-msvc,
             exe: '.exe',
-            llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/15.x/llvm-windows-amd64.tar.xz'
+            # For now, disable LLVM in `windows-x64.`
+            # llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-windows-amd64.tar.xz'
           },
           {
             build: linux-musl,
@@ -637,6 +694,14 @@ jobs:
       - name: Set up base deps on musl
         if: matrix.metadata.build == 'linux-musl'
         run: ./scripts/alpine-linux-install-deps.sh
+      - name: Install MSVC dev-cmd (Windows)
+        uses: ilammy/msvc-dev-cmd@v1
+        if: ${{ matrix.metadata.build == 'windows-x64' }}
+      - name: Delete unwanted link to stop it from interfering (Windows) 
+        shell: bash
+        run: rm /usr/bin/link.exe
+        if: ${{ matrix.metadata.build == 'windows-x64' }}
+
       - name: Set up dependencies for Mac OS
         run: |
           brew install automake
@@ -656,17 +721,24 @@ jobs:
         run: |
           brew install llvm
       - name: Install LLVM
-        if: matrix.metadata.llvm_url
         shell: bash
+        if: matrix.metadata.llvm_url
         run: |
           curl --proto '=https' --tlsv1.2 -sSf ${{ matrix.metadata.llvm_url }} -L -o llvm.tar.xz
           LLVM_DIR=$(pwd)/${{ env.LLVM_DIR }}
           mkdir ${LLVM_DIR}
           tar xf llvm.tar.xz --strip-components=1 -C ${LLVM_DIR}
           echo "${LLVM_DIR}/bin" >> $GITHUB_PATH
-          echo "LLVM_SYS_120_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
+          echo "${LLVM_DIR}/usr/bin" >> $GITHUB_PATH
+          echo "LLVM_SYS_180_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
+          echo "ENABLE_LLVM=1" >> $GITHUB_ENV
         env:
           LLVM_DIR: .llvm
+      - name: Add `brew` libs to `RUSTFLAGS`
+        if: matrix.metadata.os == 'macos-14'
+        shell: bash
+        run: |
+          echo "RUSTFLAGS=-L/opt/homebrew/lib" >> $GITHUB_ENV
       - name: Setup Rust target
         shell: bash
         run: |
@@ -691,12 +763,14 @@ jobs:
           aws-s3-bucket-endpoint: false
           aws-s3-force-path-style: true
       - name: ${{ matrix.stage.description }}
+        shell: bash
         run: make ${{ matrix.stage.make }}
         env:
           TARGET: ${{ matrix.metadata.target }}
           TARGET_DIR: target/${{ matrix.metadata.target }}/release
           CARGO_TARGET: ${{ matrix.metadata.target }}
 
+
   test_integration_cli:
     name: CLI integration tests on ${{ matrix.build }}
     runs-on: ${{ matrix.os }}
@@ -708,13 +782,12 @@ jobs:
           - build: linux-x64
             os: ubuntu-22.04
             target: x86_64-unknown-linux-gnu
-            llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.6/clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04.tar.xz'
+            llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-linux-amd64.tar.xz'
           - build: macos-x64
             os: macos-12
             target: x86_64-apple-darwin
-            llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/clang+llvm-15.0.7-x86_64-apple-darwin21.0.tar.xz'
           # we only build the integration-test CLI, we don't run tests
-          - build: macos-arm
+          - build: macos-arm64
             os: macos-12
             target: aarch64-apple-darwin,
           - build: linux-musl
@@ -724,6 +797,9 @@ jobs:
           - build: windows-x64
             os: windows-2019
             target: x86_64-pc-windows-msvc
+            # For now, disable LLVM in `windows-x64.`
+            # llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/18.x/llvm-windows-amd64.tar.xz'
+
     container: ${{ matrix.container }}
     env:
       SCCACHE_AZURE_BLOB_CONTAINER: wasmerstoragesccacheblob
@@ -777,11 +853,11 @@ jobs:
           path: package/cache/wasmercache1
       - uses: actions/download-artifact@v3
         with:
-          name: capi-windows-gnu
+          name: capi-windows-x64
           path: package/cache/wasmercache2
       - uses: actions/download-artifact@v3
         with:
-          name: capi-macos-arm
+          name: capi-macos-arm64
           path: package/cache/wasmercache3
       - uses: actions/download-artifact@v3
         with:
@@ -812,7 +888,7 @@ jobs:
       - uses: actions/download-artifact@v3
         if: ${{ matrix.build == 'windows-x64' }}
         with:
-          name: capi-windows-gnu
+          name: capi-windows-x64
           path: download_link
       - uses: actions/download-artifact@v3
         if: ${{ matrix.build == 'linux-musl' }}
@@ -820,9 +896,9 @@ jobs:
           name: capi-linux-musl
           path: download_link
       - uses: actions/download-artifact@v3
-        if: ${{ matrix.build == 'macos-arm' }}
+        if: ${{ matrix.build == 'macos-arm64' }}
         with:
-          name: capi-macos-arm
+          name: capi-macos-arm64
           path: download_link
       - uses: actions/download-artifact@v3
         if: ${{ matrix.build == 'macos-x64' }}