about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDenis Merigoux <denis.merigoux@gmail.com>2018-08-30 15:41:59 +0200
committerEduard-Mihai Burtescu <edy.burt@gmail.com>2018-11-16 14:11:59 +0200
commit3e77f2fc4f679792bc9579fb9716c3a72fd1397b (patch)
tree5627434cc92fb9bd34851f6ef19dcf33ecc53449
parent6c5b990c5f5e17f044d7c4673802a11d50bc709f (diff)
downloadrust-3e77f2fc4f679792bc9579fb9716c3a72fd1397b.tar.gz
rust-3e77f2fc4f679792bc9579fb9716c3a72fd1397b.zip
Use the method form for CodegenCx everywhere
-rw-r--r--src/librustc_codegen_llvm/abi.rs2
-rw-r--r--src/librustc_codegen_llvm/asm.rs2
-rw-r--r--src/librustc_codegen_llvm/base.rs18
-rw-r--r--src/librustc_codegen_llvm/builder.rs6
-rw-r--r--src/librustc_codegen_llvm/common.rs6
-rw-r--r--src/librustc_codegen_llvm/debuginfo/gdb.rs4
-rw-r--r--src/librustc_codegen_llvm/glue.rs9
-rw-r--r--src/librustc_codegen_llvm/interfaces/backend.rs4
-rw-r--r--src/librustc_codegen_llvm/interfaces/builder.rs4
-rw-r--r--src/librustc_codegen_llvm/interfaces/common.rs7
-rw-r--r--src/librustc_codegen_llvm/llvm/ffi.rs8
-rw-r--r--src/librustc_codegen_llvm/llvm/mod.rs2
-rw-r--r--src/librustc_codegen_llvm/meth.rs10
-rw-r--r--src/librustc_codegen_llvm/mir/block.rs17
-rw-r--r--src/librustc_codegen_llvm/mir/constant.rs8
-rw-r--r--src/librustc_codegen_llvm/mir/mod.rs2
16 files changed, 54 insertions, 55 deletions
diff --git a/src/librustc_codegen_llvm/abi.rs b/src/librustc_codegen_llvm/abi.rs
index 9826976d819..9256eaccf91 100644
--- a/src/librustc_codegen_llvm/abi.rs
+++ b/src/librustc_codegen_llvm/abi.rs
@@ -244,7 +244,7 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
                                   self.layout.align,
                                   bx.pointercast(llscratch, Type::i8p(cx)),
                                   scratch_align,
-                                  CodegenCx::c_usize(cx, self.layout.size.bytes()),
+                                  cx.c_usize(self.layout.size.bytes()),
                                   MemFlags::empty());
 
                 bx.lifetime_end(llscratch, scratch_size);
diff --git a/src/librustc_codegen_llvm/asm.rs b/src/librustc_codegen_llvm/asm.rs
index 028596950f5..076fa400a27 100644
--- a/src/librustc_codegen_llvm/asm.rs
+++ b/src/librustc_codegen_llvm/asm.rs
@@ -111,7 +111,7 @@ pub fn codegen_inline_asm(
         let kind = llvm::LLVMGetMDKindIDInContext(bx.cx().llcx,
             key.as_ptr() as *const c_char, key.len() as c_uint);
 
-        let val: &'ll Value = CodegenCx::c_i32(bx.cx(), ia.ctxt.outer().as_u32() as i32);
+        let val: &'ll Value = bx.cx().c_i32(ia.ctxt.outer().as_u32() as i32);
 
         llvm::LLVMSetMetadata(r, kind,
             llvm::LLVMMDNodeInContext(bx.cx().llcx, &val, 1));
diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs
index e13c488d2b7..9c4570f8a31 100644
--- a/src/librustc_codegen_llvm/base.rs
+++ b/src/librustc_codegen_llvm/base.rs
@@ -157,14 +157,14 @@ pub fn bin_op_to_fcmp_predicate(op: hir::BinOpKind) -> RealPredicate {
     }
 }
 
-pub fn compare_simd_types(
-    bx: &Builder<'a, 'll, 'tcx>,
-    lhs: &'ll Value,
-    rhs: &'ll Value,
+pub fn compare_simd_types<'a, 'll:'a, 'tcx:'ll, Builder: BuilderMethods<'a, 'll, 'tcx>>(
+    bx: &Builder,
+    lhs: Builder::Value,
+    rhs: Builder::Value,
     t: Ty<'tcx>,
-    ret_ty: &'ll Type,
+    ret_ty: Builder::Type,
     op: hir::BinOpKind
-) -> &'ll Value {
+) -> Builder::Value {
     let signed = match t.sty {
         ty::Float(_) => {
             let cmp = bin_op_to_fcmp_predicate(op);
@@ -198,7 +198,7 @@ pub fn unsized_info(
     let (source, target) = cx.tcx.struct_lockstep_tails(source, target);
     match (&source.sty, &target.sty) {
         (&ty::Array(_, len), &ty::Slice(_)) => {
-            CodegenCx::c_usize(cx, len.unwrap_usize(cx.tcx))
+            cx.c_usize(len.unwrap_usize(cx.tcx))
         }
         (&ty::Dynamic(..), &ty::Dynamic(..)) => {
             // For now, upcasts are limited to changes in marker
@@ -460,7 +460,7 @@ pub fn memcpy_ty<'a, 'll: 'a, 'tcx: 'll>(
         return;
     }
 
-    call_memcpy(bx, dst, dst_align, src, src_align, CodegenCx::c_usize(bx.cx(), size), flags);
+    call_memcpy(bx, dst, dst_align, src, src_align, bx.cx().c_usize(size), flags);
 }
 
 pub fn call_memset(
@@ -474,7 +474,7 @@ pub fn call_memset(
     let ptr_width = &bx.cx().sess().target.target.target_pointer_width;
     let intrinsic_key = format!("llvm.memset.p0i8.i{}", ptr_width);
     let llintrinsicfn = bx.cx().get_intrinsic(&intrinsic_key);
-    let volatile = CodegenCx::c_bool(bx.cx(), volatile);
+    let volatile = bx.cx().c_bool(volatile);
     bx.call(llintrinsicfn, &[ptr, fill_byte, size, align, volatile], None)
 }
 
diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs
index 2aaccd3c4f8..d74653310e3 100644
--- a/src/librustc_codegen_llvm/builder.rs
+++ b/src/librustc_codegen_llvm/builder.rs
@@ -577,7 +577,7 @@ impl BuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx> {
                 // *always* point to a metadata value of the integer 1.
                 //
                 // [1]: http://llvm.org/docs/LangRef.html#store-instruction
-                let one = CodegenCx::c_i32(self.cx, 1);
+                let one = self.cx.c_i32(1);
                 let node = llvm::LLVMMDNodeInContext(self.cx.llcx, &one, 1);
                 llvm::LLVMSetMetadata(store, llvm::MD_nontemporal as c_uint, node);
             }
@@ -861,7 +861,7 @@ impl BuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx> {
         unsafe {
             let elt_ty = self.cx.val_ty(elt);
             let undef = llvm::LLVMGetUndef(type_::Type::vector(elt_ty, num_elts as u64));
-            let vec = self.insert_element(undef, elt, CodegenCx::c_i32(self.cx, 0));
+            let vec = self.insert_element(undef, elt, self.cx.c_i32(0));
             let vec_i32_ty = type_::Type::vector(type_::Type::i32(self.cx), num_elts as u64);
             self.shuffle_vector(vec, undef, self.cx.c_null(vec_i32_ty))
         }
@@ -1227,7 +1227,7 @@ impl BuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx> {
         let lifetime_intrinsic = self.cx.get_intrinsic(intrinsic);
 
         let ptr = self.pointercast(ptr, type_::Type::i8p(self.cx));
-        self.call(lifetime_intrinsic, &[CodegenCx::c_u64(self.cx, size), ptr], None);
+        self.call(lifetime_intrinsic, &[self.cx.c_u64(size), ptr], None);
     }
 
     fn call(&self, llfn: &'ll Value, args: &[&'ll Value],
diff --git a/src/librustc_codegen_llvm/common.rs b/src/librustc_codegen_llvm/common.rs
index bd356047467..569fbc9f081 100644
--- a/src/librustc_codegen_llvm/common.rs
+++ b/src/librustc_codegen_llvm/common.rs
@@ -50,7 +50,7 @@ pub fn type_is_freeze<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bo
     ty.is_freeze(tcx, ty::ParamEnv::reveal_all(), DUMMY_SP)
 }
 
-pub struct OperandBundleDef<'a, Value : 'a> {
+pub struct OperandBundleDef<'a, Value: 'a> {
     pub name: &'a str,
     pub val: Value
 }
@@ -200,7 +200,7 @@ impl Backend for CodegenCx<'ll, 'tcx> {
     type Context = &'ll llvm::Context;
 }
 
-impl<'ll, 'tcx : 'll> CommonMethods for CodegenCx<'ll, 'tcx> {
+impl<'ll, 'tcx: 'll> CommonMethods for CodegenCx<'ll, 'tcx> {
 
     // LLVM constant constructors.
     fn c_null(&self, t: &'ll Type) -> &'ll Value {
@@ -424,7 +424,7 @@ pub fn c_struct_in_context(
     }
 }
 
-impl<'ll, 'tcx : 'll> CommonWriteMethods for CodegenCx<'ll, 'tcx> {
+impl<'ll, 'tcx: 'll> CommonWriteMethods for CodegenCx<'ll, 'tcx> {
     fn val_ty(&self, v: &'ll Value) -> &'ll Type {
         val_ty(v)
     }
diff --git a/src/librustc_codegen_llvm/debuginfo/gdb.rs b/src/librustc_codegen_llvm/debuginfo/gdb.rs
index 13392a64c7b..78958080a3b 100644
--- a/src/librustc_codegen_llvm/debuginfo/gdb.rs
+++ b/src/librustc_codegen_llvm/debuginfo/gdb.rs
@@ -30,7 +30,7 @@ pub fn insert_reference_to_gdb_debug_scripts_section_global(bx: &Builder) {
         let gdb_debug_scripts_section = get_or_insert_gdb_debug_scripts_section_global(bx.cx());
         // Load just the first byte as that's all that's necessary to force
         // LLVM to keep around the reference to the global.
-        let indices = [CodegenCx::c_i32(bx.cx(), 0), CodegenCx::c_i32(bx.cx(), 0)];
+        let indices = [bx.cx().c_i32(0), bx.cx().c_i32(0)];
         let element = bx.inbounds_gep(gdb_debug_scripts_section, &indices);
         let volative_load_instruction = bx.volatile_load(element);
         unsafe {
@@ -64,7 +64,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(cx: &CodegenCx<'ll, '_>)
                 bug!("symbol `{}` is already defined", section_var_name)
             });
             llvm::LLVMSetSection(section_var, section_name.as_ptr() as *const _);
-            llvm::LLVMSetInitializer(section_var, CodegenCx::c_bytes(cx, section_contents));
+            llvm::LLVMSetInitializer(section_var, cx.c_bytes(section_contents));
             llvm::LLVMSetGlobalConstant(section_var, llvm::True);
             llvm::LLVMSetUnnamedAddr(section_var, llvm::True);
             llvm::LLVMRustSetLinkage(section_var, llvm::Linkage::LinkOnceODRLinkage);
diff --git a/src/librustc_codegen_llvm/glue.rs b/src/librustc_codegen_llvm/glue.rs
index 09bd3ae264b..8e0fbe08c34 100644
--- a/src/librustc_codegen_llvm/glue.rs
+++ b/src/librustc_codegen_llvm/glue.rs
@@ -16,7 +16,6 @@ use std;
 
 use builder::Builder;
 use common::*;
-use context::CodegenCx;
 use meth;
 use rustc::ty::layout::LayoutOf;
 use rustc::ty::{self, Ty};
@@ -66,8 +65,8 @@ pub fn size_and_align_of_dst(
             let sized_align = layout.align.abi();
             debug!("DST {} statically sized prefix size: {} align: {}",
                    t, sized_size, sized_align);
-            let sized_size = CodegenCx::c_usize(cx, sized_size);
-            let sized_align = CodegenCx::c_usize(cx, sized_align);
+            let sized_size = cx.c_usize(sized_size);
+            let sized_align = cx.c_usize(sized_align);
 
             // Recurse to get the size of the dynamically sized field (must be
             // the last field).
@@ -98,7 +97,7 @@ pub fn size_and_align_of_dst(
                 (Some(sized_align), Some(unsized_align)) => {
                     // If both alignments are constant, (the sized_align should always be), then
                     // pick the correct alignment statically.
-                    CodegenCx::c_usize(cx, std::cmp::max(sized_align, unsized_align) as u64)
+                    cx.c_usize(std::cmp::max(sized_align, unsized_align) as u64)
                 }
                 _ => bx.select(bx.icmp(IntPredicate::IntUGT, sized_align, unsized_align),
                                sized_align,
@@ -116,7 +115,7 @@ pub fn size_and_align_of_dst(
             //
             //   `(size + (align-1)) & -align`
 
-            let addend = bx.sub(align, CodegenCx::c_usize(bx.cx(), 1));
+            let addend = bx.sub(align, bx.cx().c_usize(1));
             let size = bx.and(bx.add(size, addend), bx.neg(align));
 
             (size, align)
diff --git a/src/librustc_codegen_llvm/interfaces/backend.rs b/src/librustc_codegen_llvm/interfaces/backend.rs
index 648ae15eb3f..6db014023e9 100644
--- a/src/librustc_codegen_llvm/interfaces/backend.rs
+++ b/src/librustc_codegen_llvm/interfaces/backend.rs
@@ -8,8 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::fmt::Debug;
+
 pub trait Backend {
-    type Value;
+    type Value: Debug + PartialEq;
     type BasicBlock;
     type Type;
     type Context;
diff --git a/src/librustc_codegen_llvm/interfaces/builder.rs b/src/librustc_codegen_llvm/interfaces/builder.rs
index c43e41724ee..143de3c5b07 100644
--- a/src/librustc_codegen_llvm/interfaces/builder.rs
+++ b/src/librustc_codegen_llvm/interfaces/builder.rs
@@ -22,7 +22,7 @@ use syntax::ast::AsmDialect;
 
 
 
-pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll> : Backend {
+pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll>: Backend {
 
     fn new_block<'b>(
         cx: &'a CodegenCx<'ll, 'tcx, Self::Value>,
@@ -271,7 +271,7 @@ pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll> : Backend {
         typ: &str,
         llfn: Self::Value,
         args: &'b [Self::Value]
-    ) -> Cow<'b, [Self::Value]> where [Self::Value] : ToOwned;
+    ) -> Cow<'b, [Self::Value]> where [Self::Value]: ToOwned;
     fn lifetime_start(&self, ptr: Self::Value, size: Size);
     fn lifetime_end(&self, ptr: Self::Value, size: Size);
 
diff --git a/src/librustc_codegen_llvm/interfaces/common.rs b/src/librustc_codegen_llvm/interfaces/common.rs
index 79fed084588..35f588368fe 100644
--- a/src/librustc_codegen_llvm/interfaces/common.rs
+++ b/src/librustc_codegen_llvm/interfaces/common.rs
@@ -11,7 +11,7 @@
 use super::Backend;
 use syntax::symbol::LocalInternedString;
 
-pub trait CommonMethods : Backend + CommonWriteMethods {
+pub trait CommonMethods: Backend + CommonWriteMethods {
     // Constant constructors
     fn c_null(&self, t: Self::Type) -> Self::Value;
     fn c_undef(&self, t: Self::Type) -> Self::Value;
@@ -47,12 +47,13 @@ pub trait CommonMethods : Backend + CommonWriteMethods {
     fn const_get_elt(&self, v: Self::Value, idx: u64) -> Self::Value;
     fn const_get_real(&self, v: Self::Value) -> Option<(f64, bool)>;
     fn const_to_uint(&self, v: Self::Value) -> u64;
+    fn const_to_opt_u128(&self, v: Self::Value, sign_ext: bool) -> Option<u128>;
+
     fn is_const_integral(&self, v: Self::Value) -> bool;
     fn is_const_real(&self, v: Self::Value) -> bool;
-    fn const_to_opt_u128(&self, v: Self::Value, sign_ext: bool) -> Option<u128>;
 }
 
-pub trait CommonWriteMethods : Backend {
+pub trait CommonWriteMethods: Backend {
         fn val_ty(&self, v: Self::Value) -> Self::Type;
         fn c_bytes_in_context(&self, llcx: Self::Context, bytes: &[u8]) -> Self::Value;
         fn c_struct_in_context(
diff --git a/src/librustc_codegen_llvm/llvm/ffi.rs b/src/librustc_codegen_llvm/llvm/ffi.rs
index e35daee0a70..e80c66fbe24 100644
--- a/src/librustc_codegen_llvm/llvm/ffi.rs
+++ b/src/librustc_codegen_llvm/llvm/ffi.rs
@@ -246,7 +246,7 @@ pub enum AtomicRmwBinOp {
 }
 
 impl AtomicRmwBinOp {
-    pub fn from_generic(op : common::AtomicRmwBinOp) -> Self {
+    pub fn from_generic(op: common::AtomicRmwBinOp) -> Self {
         match op {
             common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
             common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
@@ -279,7 +279,7 @@ pub enum AtomicOrdering {
 }
 
 impl AtomicOrdering {
-    pub fn from_generic(ao : common::AtomicOrdering) -> Self {
+    pub fn from_generic(ao: common::AtomicOrdering) -> Self {
         match ao {
             common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
             common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
@@ -306,7 +306,7 @@ pub enum SynchronizationScope {
 }
 
 impl SynchronizationScope {
-    pub fn from_generic(sc : common::SynchronizationScope) -> Self {
+    pub fn from_generic(sc: common::SynchronizationScope) -> Self {
         match sc {
             common::SynchronizationScope::Other => SynchronizationScope::Other,
             common::SynchronizationScope::SingleThread => SynchronizationScope::SingleThread,
@@ -356,7 +356,7 @@ pub enum AsmDialect {
 }
 
 impl AsmDialect {
-    pub fn from_generic(asm : syntax::ast::AsmDialect) -> Self {
+    pub fn from_generic(asm: syntax::ast::AsmDialect) -> Self {
         match asm {
             syntax::ast::AsmDialect::Att => AsmDialect::Att,
             syntax::ast::AsmDialect::Intel => AsmDialect::Intel
diff --git a/src/librustc_codegen_llvm/llvm/mod.rs b/src/librustc_codegen_llvm/llvm/mod.rs
index 3b85690e878..1d90f8be46d 100644
--- a/src/librustc_codegen_llvm/llvm/mod.rs
+++ b/src/librustc_codegen_llvm/llvm/mod.rs
@@ -273,7 +273,7 @@ impl OperandBundleDef<'a> {
         OperandBundleDef { raw: def }
     }
 
-    pub fn from_generic(bundle : &common::OperandBundleDef<'a, &'a Value>) -> Self {
+    pub fn from_generic(bundle: &common::OperandBundleDef<'a, &'a Value>) -> Self {
         Self::new(bundle.name, &[bundle.val])
     }
 }
diff --git a/src/librustc_codegen_llvm/meth.rs b/src/librustc_codegen_llvm/meth.rs
index a4d7260c829..e4c4417654a 100644
--- a/src/librustc_codegen_llvm/meth.rs
+++ b/src/librustc_codegen_llvm/meth.rs
@@ -44,7 +44,7 @@ impl<'a, 'tcx> VirtualIndex {
         let llvtable = bx.pointercast(llvtable, fn_ty.ptr_to_llvm_type(bx.cx()).ptr_to());
         let ptr_align = bx.tcx().data_layout.pointer_align;
         let ptr = bx.load(
-            bx.inbounds_gep(llvtable, &[CodegenCx::c_usize(bx.cx(), self.0)]),
+            bx.inbounds_gep(llvtable, &[bx.cx().c_usize(self.0)]),
             ptr_align
         );
         bx.nonnull_metadata(ptr);
@@ -64,7 +64,7 @@ impl<'a, 'tcx> VirtualIndex {
         let llvtable = bx.pointercast(llvtable, Type::isize(bx.cx()).ptr_to());
         let usize_align = bx.tcx().data_layout.pointer_align;
         let ptr = bx.load(
-            bx.inbounds_gep(llvtable, &[CodegenCx::c_usize(bx.cx(), self.0)]),
+            bx.inbounds_gep(llvtable, &[bx.cx().c_usize(self.0)]),
             usize_align
         );
         // Vtable loads are invariant
@@ -112,11 +112,11 @@ pub fn get_vtable(
     // /////////////////////////////////////////////////////////////////////////////////////////////
     let components: Vec<_> = [
         callee::get_fn(cx, monomorphize::resolve_drop_in_place(cx.tcx, ty)),
-        CodegenCx::c_usize(cx, size.bytes()),
-        CodegenCx::c_usize(cx, align.abi())
+        cx.c_usize(size.bytes()),
+        cx.c_usize(align.abi())
     ].iter().cloned().chain(methods).collect();
 
-    let vtable_const = CodegenCx::c_struct(cx, &components, false);
+    let vtable_const = cx.c_struct(&components, false);
     let align = cx.data_layout().pointer_align;
     let vtable = consts::addr_of(cx, vtable_const, align, Some("vtable"));
 
diff --git a/src/librustc_codegen_llvm/mir/block.rs b/src/librustc_codegen_llvm/mir/block.rs
index b9599d505d3..4b9727d1e7a 100644
--- a/src/librustc_codegen_llvm/mir/block.rs
+++ b/src/librustc_codegen_llvm/mir/block.rs
@@ -19,7 +19,6 @@ use base;
 use callee;
 use builder::{Builder, MemFlags};
 use common::{self, IntPredicate};
-use context::CodegenCx;
 use consts;
 use meth;
 use monomorphize;
@@ -347,7 +346,7 @@ impl FunctionCx<'a, 'll, 'tcx, &'ll Value> {
 
                 // Pass the condition through llvm.expect for branch hinting.
                 let expect = bx.cx().get_intrinsic(&"llvm.expect.i1");
-                let cond = bx.call(expect, &[cond, CodegenCx::c_bool(bx.cx(), expected)], None);
+                let cond = bx.call(expect, &[cond, bx.cx().c_bool(expected)], None);
 
                 // Create the failure block and the conditional branch to it.
                 let lltarget = llblock(self, target);
@@ -365,9 +364,9 @@ impl FunctionCx<'a, 'll, 'tcx, &'ll Value> {
                 // Get the location information.
                 let loc = bx.sess().source_map().lookup_char_pos(span.lo());
                 let filename = Symbol::intern(&loc.file.name.to_string()).as_str();
-                let filename = CodegenCx::c_str_slice(bx.cx(), filename);
-                let line = CodegenCx::c_u32(bx.cx(), loc.line as u32);
-                let col = CodegenCx::c_u32(bx.cx(), loc.col.to_usize() as u32 + 1);
+                let filename = bx.cx().c_str_slice(filename);
+                let line = bx.cx().c_u32(loc.line as u32);
+                let col = bx.cx().c_u32(loc.col.to_usize() as u32 + 1);
                 let align = tcx.data_layout.aggregate_align
                     .max(tcx.data_layout.i32_align)
                     .max(tcx.data_layout.pointer_align);
@@ -378,8 +377,7 @@ impl FunctionCx<'a, 'll, 'tcx, &'ll Value> {
                         let len = self.codegen_operand(&mut bx, len).immediate();
                         let index = self.codegen_operand(&mut bx, index).immediate();
 
-                        let file_line_col = CodegenCx::c_struct(bx.cx(),
-                             &[filename, line, col], false);
+                        let file_line_col = bx.cx().c_struct(&[filename, line, col], false);
                         let file_line_col = consts::addr_of(bx.cx(),
                                                             file_line_col,
                                                             align,
@@ -390,9 +388,8 @@ impl FunctionCx<'a, 'll, 'tcx, &'ll Value> {
                     _ => {
                         let str = msg.description();
                         let msg_str = Symbol::intern(str).as_str();
-                        let msg_str = CodegenCx::c_str_slice(bx.cx(), msg_str);
-                        let msg_file_line_col = CodegenCx::c_struct(
-                            bx.cx(),
+                        let msg_str = bx.cx().c_str_slice(msg_str);
+                        let msg_file_line_col = bx.cx().c_struct(
                             &[msg_str, filename, line, col],
                             false
                         );
diff --git a/src/librustc_codegen_llvm/mir/constant.rs b/src/librustc_codegen_llvm/mir/constant.rs
index ac614dbbda0..70e86b690fa 100644
--- a/src/librustc_codegen_llvm/mir/constant.rs
+++ b/src/librustc_codegen_llvm/mir/constant.rs
@@ -96,7 +96,7 @@ pub fn const_alloc_to_llvm(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> &'ll
         assert_eq!(offset as usize as u64, offset);
         let offset = offset as usize;
         if offset > next_offset {
-            llvals.push(CodegenCx::c_bytes(cx, &alloc.bytes[next_offset..offset]));
+            llvals.push(cx.c_bytes(&alloc.bytes[next_offset..offset]));
         }
         let ptr_offset = read_target_uint(
             dl.endian,
@@ -114,10 +114,10 @@ pub fn const_alloc_to_llvm(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> &'ll
         next_offset = offset + pointer_size;
     }
     if alloc.bytes.len() >= next_offset {
-        llvals.push(CodegenCx::c_bytes(cx, &alloc.bytes[next_offset ..]));
+        llvals.push(cx.c_bytes(&alloc.bytes[next_offset ..]));
     }
 
-    CodegenCx::c_struct(cx, &llvals, true)
+    cx.c_struct(&llvals, true)
 }
 
 pub fn codegen_static_initializer(
@@ -207,7 +207,7 @@ impl FunctionCx<'a, 'll, 'tcx, &'ll Value> {
                         bug!("simd shuffle field {:?}", field)
                     }
                 }).collect();
-                let llval = CodegenCx::c_struct(bx.cx(), &values?, false);
+                let llval = bx.cx().c_struct(&values?, false);
                 Ok((llval, c.ty))
             })
             .unwrap_or_else(|_| {
diff --git a/src/librustc_codegen_llvm/mir/mod.rs b/src/librustc_codegen_llvm/mir/mod.rs
index 2ec4f70e826..84bc4280239 100644
--- a/src/librustc_codegen_llvm/mir/mod.rs
+++ b/src/librustc_codegen_llvm/mir/mod.rs
@@ -421,7 +421,7 @@ fn create_funclets(
                 // it's null. The 64 here is actually a bitfield which
                 // represents that this is a catch-all block.
                 let null = bx.cx().c_null(Type::i8p(bx.cx()));
-                let sixty_four = CodegenCx::c_i32(bx.cx(), 64);
+                let sixty_four = bx.cx().c_i32(64);
                 cleanup = cp_bx.catch_pad(cs, &[null, sixty_four, null]);
                 cp_bx.br(llbb);
             }