about summary refs log tree commit diff
diff options
context:
space:
mode:
authorantoyo <antoyo@users.noreply.github.com>2021-08-14 10:05:49 -0400
committerGitHub <noreply@github.com>2021-08-14 10:05:49 -0400
commit0c89065b934397b62838fe3e4ef6f6352fc52daf (patch)
tree088380f3ed161f8fca97bcd6d591b2ef4fd5c405
parentafae271d5d3719eeb92c18bc004bb6d1965a5f3f (diff)
downloadrust-0c89065b934397b62838fe3e4ef6f6352fc52daf.tar.gz
rust-0c89065b934397b62838fe3e4ef6f6352fc52daf.zip
Update to nightly-2021-08-12 (#61)
-rw-r--r--rust-toolchain2
-rw-r--r--src/builder.rs34
-rw-r--r--src/context.rs8
-rw-r--r--src/intrinsic/mod.rs6
-rw-r--r--src/type_.rs5
-rw-r--r--src/type_of.rs6
6 files changed, 42 insertions, 19 deletions
diff --git a/rust-toolchain b/rust-toolchain
index 3a29ac5ddb1..4e9771311ef 100644
--- a/rust-toolchain
+++ b/rust-toolchain
@@ -1 +1 @@
-nightly-2021-07-21
+nightly-2021-08-12
diff --git a/src/builder.rs b/src/builder.rs
index 8bdcb08bd3d..bb864c27e1b 100644
--- a/src/builder.rs
+++ b/src/builder.rs
@@ -25,6 +25,7 @@ use rustc_codegen_ssa::traits::{
     BuilderMethods,
     ConstMethods,
     DerivedTypeMethods,
+    LayoutTypeMethods,
     HasCodegen,
     OverflowOp,
     StaticBuilderMethods,
@@ -514,8 +515,12 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
         self.block.expect("block").end_with_switch(None, value, default_block, &gcc_cases);
     }
 
-    fn invoke(&mut self, _func: RValue<'gcc>, _args: &[RValue<'gcc>], _then: Block<'gcc>, _catch: Block<'gcc>, _funclet: Option<&Funclet>) -> RValue<'gcc> {
-        unimplemented!();
+    fn invoke(&mut self, _typ: Type<'gcc>, _func: RValue<'gcc>, _args: &[RValue<'gcc>], then: Block<'gcc>, catch: Block<'gcc>, _funclet: Option<&Funclet>) -> RValue<'gcc> {
+        let condition = self.context.new_rvalue_from_int(self.bool_type, 0);
+        self.llbb().end_with_conditional(None, condition, then, catch);
+        self.context.new_rvalue_from_int(self.int_type, 0)
+
+        // TODO
         /*debug!("invoke {:?} with args ({:?})", func, args);
 
         let args = self.check_call("invoke", func, args);
@@ -1001,9 +1006,10 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
             }
             else if let abi::Abi::ScalarPair(ref a, ref b) = place.layout.abi {
                 let b_offset = a.value.size(self).align_to(b.value.align(self).abi);
+                let pair_type = place.layout.gcc_type(self, false);
 
                 let mut load = |i, scalar: &abi::Scalar, align| {
-                    let llptr = self.struct_gep(place.llval, i as u64);
+                    let llptr = self.struct_gep(pair_type, place.llval, i as u64);
                     let load = self.load(llptr.get_type(), llptr, align);
                     scalar_load_metadata(self, load, scalar);
                     if scalar.is_bool() { self.trunc(load, self.type_i1()) } else { load }
@@ -1044,7 +1050,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
         let align = dest.align.restrict_for_offset(dest.layout.field(self.cx(), 0).size);
         cg_elem.val.store(&mut body_bx, PlaceRef::new_sized_aligned(current_val, cg_elem.layout, align));
 
-        let next = body_bx.inbounds_gep(current.to_rvalue(), &[self.const_usize(1)]);
+        let next = body_bx.inbounds_gep(self.backend_type(cg_elem.layout), current.to_rvalue(), &[self.const_usize(1)]);
         body_bx.llbb().add_assignment(None, current, next);
         body_bx.br(header_bx.llbb());
 
@@ -1130,7 +1136,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
             .add_eval(None, self.context.new_call(None, atomic_store, &[ptr, value, ordering]));
     }
 
-    fn gep(&mut self, ptr: RValue<'gcc>, indices: &[RValue<'gcc>]) -> RValue<'gcc> {
+    fn gep(&mut self, _typ: Type<'gcc>, ptr: RValue<'gcc>, indices: &[RValue<'gcc>]) -> RValue<'gcc> {
         let mut result = ptr;
         for index in indices {
             result = self.context.new_array_access(None, result, *index).get_address(None).to_rvalue();
@@ -1138,7 +1144,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
         result
     }
 
-    fn inbounds_gep(&mut self, ptr: RValue<'gcc>, indices: &[RValue<'gcc>]) -> RValue<'gcc> {
+    fn inbounds_gep(&mut self, _typ: Type<'gcc>, ptr: RValue<'gcc>, indices: &[RValue<'gcc>]) -> RValue<'gcc> {
         // FIXME: would be safer if doing the same thing (loop) as gep.
         // TODO: specify inbounds somehow.
         match indices.len() {
@@ -1153,11 +1159,10 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
         }
     }
 
-    fn struct_gep(&mut self, ptr: RValue<'gcc>, idx: u64) -> RValue<'gcc> {
+    fn struct_gep(&mut self, value_type: Type<'gcc>, ptr: RValue<'gcc>, idx: u64) -> RValue<'gcc> {
         // FIXME: it would be better if the API only called this on struct, not on arrays.
         assert_eq!(idx as usize as u64, idx);
         let value = ptr.dereference(None).to_rvalue();
-        let value_type = value.get_type();
 
         if value_type.is_array().is_some() {
             let index = self.context.new_rvalue_from_long(self.u64_type, i64::try_from(idx).expect("i64::try_from"));
@@ -1449,14 +1454,19 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
     }
 
     fn landing_pad(&mut self, _ty: Type<'gcc>, _pers_fn: RValue<'gcc>, _num_clauses: usize) -> RValue<'gcc> {
-        unimplemented!();
+        let field1 = self.context.new_field(None, self.u8_type, "landing_pad_field_1");
+        let field2 = self.context.new_field(None, self.i32_type, "landing_pad_field_1");
+        let struct_type = self.context.new_struct_type(None, "landing_pad", &[field1, field2]);
+        self.current_func().new_local(None, struct_type.as_type(), "landing_pad")
+            .to_rvalue()
+        // TODO
         /*unsafe {
             llvm::LLVMBuildLandingPad(self.llbuilder, ty, pers_fn, num_clauses as c_uint, UNNAMED)
         }*/
     }
 
     fn set_cleanup(&mut self, _landing_pad: RValue<'gcc>) {
-        unimplemented!();
+        // TODO
         /*unsafe {
             llvm::LLVMSetCleanup(landing_pad, llvm::True);
         }*/
@@ -1527,7 +1537,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
     }
 
     fn set_personality_fn(&mut self, _personality: RValue<'gcc>) {
-        unimplemented!();
+        // TODO
         /*unsafe {
             llvm::LLVMSetPersonalityFn(self.llfn(), personality);
         }*/
@@ -1620,7 +1630,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
         //self.call_lifetime_intrinsic("llvm.lifetime.end.p0i8", ptr, size);
     }
 
-    fn call(&mut self, func: RValue<'gcc>, args: &[RValue<'gcc>], funclet: Option<&Funclet>) -> RValue<'gcc> {
+    fn call(&mut self, _typ: Type<'gcc>, func: RValue<'gcc>, args: &[RValue<'gcc>], funclet: Option<&Funclet>) -> RValue<'gcc> {
         // FIXME: remove when having a proper API.
         let gcc_func = unsafe { std::mem::transmute(func) };
         if self.functions.borrow().values().find(|value| **value == gcc_func).is_some() {
diff --git a/src/context.rs b/src/context.rs
index 9cbbee772c5..19243b0cbce 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -14,7 +14,6 @@ use gccjit::{
 use rustc_codegen_ssa::base::wants_msvc_seh;
 use rustc_codegen_ssa::traits::{
     BackendTypes,
-    BaseTypeMethods,
     MiscMethods,
 };
 use rustc_data_structures::base_n;
@@ -349,12 +348,15 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
                 .unwrap().unwrap(),
             ),
             _ => {
-                let name = if wants_msvc_seh(self.sess()) {
+                let _name = if wants_msvc_seh(self.sess()) {
                     "__CxxFrameHandler3"
                 } else {
                     "rust_eh_personality"
                 };
-                self.declare_func(name, self.type_i32(), &[], true)
+                //let func = self.declare_func(name, self.type_i32(), &[], true);
+                // FIXME: this hack should not be needed. That will probably be removed when
+                // unwinding support is added.
+                self.context.new_rvalue_from_int(self.int_type, 0)
             }
         };
         //attributes::apply_target_cpu_attr(self, llfn);
diff --git a/src/intrinsic/mod.rs b/src/intrinsic/mod.rs
index 083f7e01c80..ad6dfbffbac 100644
--- a/src/intrinsic/mod.rs
+++ b/src/intrinsic/mod.rs
@@ -98,7 +98,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
                 _ if simple.is_some() => {
                     // FIXME: remove this cast when the API supports function.
                     let func = unsafe { std::mem::transmute(simple.expect("simple")) };
-                    self.call(func, &args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(), None)
+                    self.call(self.type_void(), func, &args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(), None)
                 },
                 sym::likely => {
                     self.expect(args[0].immediate(), true)
@@ -392,7 +392,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
     fn abort(&mut self) {
         let func = self.context.get_builtin_function("abort");
         let func: RValue<'gcc> = unsafe { std::mem::transmute(func) };
-        self.call(func, &[], None);
+        self.call(self.type_void(), func, &[], None);
     }
 
     fn assume(&mut self, value: Self::Value) {
@@ -1075,7 +1075,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
 
 fn try_intrinsic<'gcc, 'tcx>(bx: &mut Builder<'_, 'gcc, 'tcx>, try_func: RValue<'gcc>, data: RValue<'gcc>, _catch_func: RValue<'gcc>, dest: RValue<'gcc>) {
     if bx.sess().panic_strategy() == PanicStrategy::Abort {
-        bx.call(try_func, &[data], None);
+        bx.call(bx.type_void(), try_func, &[data], None);
         // Return 0 unconditionally from the intrinsic call;
         // we can never unwind.
         let ret_align = bx.tcx.data_layout.i32_align.abi;
diff --git a/src/type_.rs b/src/type_.rs
index 90f7d9d9bba..2ef90bca5ac 100644
--- a/src/type_.rs
+++ b/src/type_.rs
@@ -293,6 +293,11 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
             }
         }
 
+        // NOTE: see note above. Some other test uses usize::MAX.
+        if len == u64::MAX {
+            len = 0;
+        }
+
         let len: i32 = len.try_into().expect("array len");
 
         self.context.new_array_type(None, ty, len)
diff --git a/src/type_of.rs b/src/type_of.rs
index c5db0a1b2e4..010805808d2 100644
--- a/src/type_of.rs
+++ b/src/type_of.rs
@@ -363,4 +363,10 @@ impl<'gcc, 'tcx> LayoutTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
         unimplemented!();
         //ty.gcc_type(self)
     }
+
+    fn fn_decl_backend_type(&self, _fn_abi: &FnAbi<'tcx, Ty<'tcx>>) -> Type<'gcc> {
+        // FIXME: return correct type.
+        self.type_void()
+        //fn_abi.gcc_type(self)
+    }
 }