]> git.lizzy.rs Git - rust.git/blob - src/librustc_codegen_llvm/context.rs
Rollup merge of #67363 - alexcrichton:wasm-import-modules, r=eddyb
[rust.git] / src / librustc_codegen_llvm / context.rs
1 use crate::abi::FnAbi;
2 use crate::attributes;
3 use crate::llvm;
4 use crate::llvm_util;
5 use crate::debuginfo;
6 use crate::value::Value;
7 use rustc::dep_graph::DepGraphSafe;
8 use rustc::hir;
9
10 use crate::type_::Type;
11 use rustc_codegen_ssa::traits::*;
12
13 use rustc_data_structures::base_n;
14 use rustc_data_structures::small_c_str::SmallCStr;
15 use rustc::bug;
16 use rustc::mir::mono::CodegenUnit;
17 use rustc::session::config::{self, DebugInfo};
18 use rustc::session::Session;
19 use rustc::ty::layout::{
20     FnAbiExt, LayoutError, LayoutOf, PointeeInfo, Size, TyLayout, VariantIdx, HasParamEnv
21 };
22 use rustc::ty::{self, Ty, TyCtxt, Instance};
23 use rustc::util::nodemap::FxHashMap;
24 use rustc_target::spec::{HasTargetSpec, Target};
25 use rustc_codegen_ssa::base::wants_msvc_seh;
26 use crate::callee::get_fn;
27 use rustc_data_structures::const_cstr;
28
29 use std::ffi::CStr;
30 use std::cell::{Cell, RefCell};
31 use std::iter;
32 use std::str;
33 use std::sync::Arc;
34 use syntax::symbol::Symbol;
35 use syntax::source_map::{DUMMY_SP, Span};
36 use crate::abi::Abi;
37
38 /// There is one `CodegenCx` per compilation unit. Each one has its own LLVM
39 /// `llvm::Context` so that several compilation units may be optimized in parallel.
40 /// All other LLVM data structures in the `CodegenCx` are tied to that `llvm::Context`.
41 pub struct CodegenCx<'ll, 'tcx> {
42     pub tcx: TyCtxt<'tcx>,
43     pub check_overflow: bool,
44     pub use_dll_storage_attrs: bool,
45     pub tls_model: llvm::ThreadLocalMode,
46
47     pub llmod: &'ll llvm::Module,
48     pub llcx: &'ll llvm::Context,
49     pub codegen_unit: Arc<CodegenUnit<'tcx>>,
50
51     /// Cache instances of monomorphic and polymorphic items
52     pub instances: RefCell<FxHashMap<Instance<'tcx>, &'ll Value>>,
53     /// Cache generated vtables
54     pub vtables:
55         RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), &'ll Value>>,
56     /// Cache of constant strings,
57     pub const_cstr_cache: RefCell<FxHashMap<Symbol, &'ll Value>>,
58
59     /// Reverse-direction for const ptrs cast from globals.
60     /// Key is a Value holding a *T,
61     /// Val is a Value holding a *[T].
62     ///
63     /// Needed because LLVM loses pointer->pointee association
64     /// when we ptrcast, and we have to ptrcast during codegen
65     /// of a [T] const because we form a slice, a (*T,usize) pair, not
66     /// a pointer to an LLVM array type. Similar for trait objects.
67     pub const_unsized: RefCell<FxHashMap<&'ll Value, &'ll Value>>,
68
69     /// Cache of emitted const globals (value -> global)
70     pub const_globals: RefCell<FxHashMap<&'ll Value, &'ll Value>>,
71
72     /// List of globals for static variables which need to be passed to the
73     /// LLVM function ReplaceAllUsesWith (RAUW) when codegen is complete.
74     /// (We have to make sure we don't invalidate any Values referring
75     /// to constants.)
76     pub statics_to_rauw: RefCell<Vec<(&'ll Value, &'ll Value)>>,
77
78     /// Statics that will be placed in the llvm.used variable
79     /// See <http://llvm.org/docs/LangRef.html#the-llvm-used-global-variable> for details
80     pub used_statics: RefCell<Vec<&'ll Value>>,
81
82     pub lltypes: RefCell<FxHashMap<(Ty<'tcx>, Option<VariantIdx>), &'ll Type>>,
83     pub scalar_lltypes: RefCell<FxHashMap<Ty<'tcx>, &'ll Type>>,
84     pub pointee_infos: RefCell<FxHashMap<(Ty<'tcx>, Size), Option<PointeeInfo>>>,
85     pub isize_ty: &'ll Type,
86
87     pub dbg_cx: Option<debuginfo::CrateDebugContext<'ll, 'tcx>>,
88
89     eh_personality: Cell<Option<&'ll Value>>,
90     eh_unwind_resume: Cell<Option<&'ll Value>>,
91     pub rust_try_fn: Cell<Option<&'ll Value>>,
92
93     intrinsics: RefCell<FxHashMap<&'static str, &'ll Value>>,
94
95     /// A counter that is used for generating local symbol names
96     local_gen_sym_counter: Cell<usize>,
97 }
98
99 impl<'ll, 'tcx> DepGraphSafe for CodegenCx<'ll, 'tcx> {}
100
101 pub fn get_reloc_model(sess: &Session) -> llvm::RelocMode {
102     let reloc_model_arg = match sess.opts.cg.relocation_model {
103         Some(ref s) => &s[..],
104         None => &sess.target.target.options.relocation_model[..],
105     };
106
107     match crate::back::write::RELOC_MODEL_ARGS.iter().find(
108         |&&arg| arg.0 == reloc_model_arg) {
109         Some(x) => x.1,
110         _ => {
111             sess.err(&format!("{:?} is not a valid relocation mode",
112                               reloc_model_arg));
113             sess.abort_if_errors();
114             bug!();
115         }
116     }
117 }
118
119 fn get_tls_model(sess: &Session) -> llvm::ThreadLocalMode {
120     let tls_model_arg = match sess.opts.debugging_opts.tls_model {
121         Some(ref s) => &s[..],
122         None => &sess.target.target.options.tls_model[..],
123     };
124
125     match crate::back::write::TLS_MODEL_ARGS.iter().find(
126         |&&arg| arg.0 == tls_model_arg) {
127         Some(x) => x.1,
128         _ => {
129             sess.err(&format!("{:?} is not a valid TLS model",
130                               tls_model_arg));
131             sess.abort_if_errors();
132             bug!();
133         }
134     }
135 }
136
137 fn is_any_library(sess: &Session) -> bool {
138     sess.crate_types.borrow().iter().any(|ty| {
139         *ty != config::CrateType::Executable
140     })
141 }
142
143 pub fn is_pie_binary(sess: &Session) -> bool {
144     !is_any_library(sess) && get_reloc_model(sess) == llvm::RelocMode::PIC
145 }
146
147 fn strip_function_ptr_alignment(data_layout: String) -> String {
148     // FIXME: Make this more general.
149     data_layout.replace("-Fi8-", "-")
150 }
151
152 pub unsafe fn create_module(
153     tcx: TyCtxt<'_>,
154     llcx: &'ll llvm::Context,
155     mod_name: &str,
156 ) -> &'ll llvm::Module {
157     let sess = tcx.sess;
158     let mod_name = SmallCStr::new(mod_name);
159     let llmod = llvm::LLVMModuleCreateWithNameInContext(mod_name.as_ptr(), llcx);
160
161     let mut target_data_layout = sess.target.target.data_layout.clone();
162     if llvm_util::get_major_version() < 9 {
163         target_data_layout = strip_function_ptr_alignment(target_data_layout);
164     }
165
166     // Ensure the data-layout values hardcoded remain the defaults.
167     if sess.target.target.options.is_builtin {
168         let tm = crate::back::write::create_informational_target_machine(&tcx.sess, false);
169         llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, tm);
170         llvm::LLVMRustDisposeTargetMachine(tm);
171
172         let llvm_data_layout = llvm::LLVMGetDataLayout(llmod);
173         let llvm_data_layout = str::from_utf8(CStr::from_ptr(llvm_data_layout).to_bytes())
174             .ok().expect("got a non-UTF8 data-layout from LLVM");
175
176         // Unfortunately LLVM target specs change over time, and right now we
177         // don't have proper support to work with any more than one
178         // `data_layout` than the one that is in the rust-lang/rust repo. If
179         // this compiler is configured against a custom LLVM, we may have a
180         // differing data layout, even though we should update our own to use
181         // that one.
182         //
183         // As an interim hack, if CFG_LLVM_ROOT is not an empty string then we
184         // disable this check entirely as we may be configured with something
185         // that has a different target layout.
186         //
187         // Unsure if this will actually cause breakage when rustc is configured
188         // as such.
189         //
190         // FIXME(#34960)
191         let cfg_llvm_root = option_env!("CFG_LLVM_ROOT").unwrap_or("");
192         let custom_llvm_used = cfg_llvm_root.trim() != "";
193
194         if !custom_llvm_used && target_data_layout != llvm_data_layout {
195             bug!("data-layout for builtin `{}` target, `{}`, \
196                   differs from LLVM default, `{}`",
197                  sess.target.target.llvm_target,
198                  target_data_layout,
199                  llvm_data_layout);
200         }
201     }
202
203     let data_layout = SmallCStr::new(&target_data_layout);
204     llvm::LLVMSetDataLayout(llmod, data_layout.as_ptr());
205
206     let llvm_target = SmallCStr::new(&sess.target.target.llvm_target);
207     llvm::LLVMRustSetNormalizedTarget(llmod, llvm_target.as_ptr());
208
209     if get_reloc_model(sess) == llvm::RelocMode::PIC {
210         llvm::LLVMRustSetModulePICLevel(llmod);
211     }
212
213     if is_pie_binary(sess) {
214         llvm::LLVMRustSetModulePIELevel(llmod);
215     }
216
217     // If skipping the PLT is enabled, we need to add some module metadata
218     // to ensure intrinsic calls don't use it.
219     if !sess.needs_plt() {
220         let avoid_plt = "RtLibUseGOT\0".as_ptr().cast();
221         llvm::LLVMRustAddModuleFlag(llmod, avoid_plt, 1);
222     }
223
224     llmod
225 }
226
227 impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
228     crate fn new(
229         tcx: TyCtxt<'tcx>,
230         codegen_unit: Arc<CodegenUnit<'tcx>>,
231         llvm_module: &'ll crate::ModuleLlvm,
232     ) -> Self {
233         // An interesting part of Windows which MSVC forces our hand on (and
234         // apparently MinGW didn't) is the usage of `dllimport` and `dllexport`
235         // attributes in LLVM IR as well as native dependencies (in C these
236         // correspond to `__declspec(dllimport)`).
237         //
238         // Whenever a dynamic library is built by MSVC it must have its public
239         // interface specified by functions tagged with `dllexport` or otherwise
240         // they're not available to be linked against. This poses a few problems
241         // for the compiler, some of which are somewhat fundamental, but we use
242         // the `use_dll_storage_attrs` variable below to attach the `dllexport`
243         // attribute to all LLVM functions that are exported e.g., they're
244         // already tagged with external linkage). This is suboptimal for a few
245         // reasons:
246         //
247         // * If an object file will never be included in a dynamic library,
248         //   there's no need to attach the dllexport attribute. Most object
249         //   files in Rust are not destined to become part of a dll as binaries
250         //   are statically linked by default.
251         // * If the compiler is emitting both an rlib and a dylib, the same
252         //   source object file is currently used but with MSVC this may be less
253         //   feasible. The compiler may be able to get around this, but it may
254         //   involve some invasive changes to deal with this.
255         //
256         // The flipside of this situation is that whenever you link to a dll and
257         // you import a function from it, the import should be tagged with
258         // `dllimport`. At this time, however, the compiler does not emit
259         // `dllimport` for any declarations other than constants (where it is
260         // required), which is again suboptimal for even more reasons!
261         //
262         // * Calling a function imported from another dll without using
263         //   `dllimport` causes the linker/compiler to have extra overhead (one
264         //   `jmp` instruction on x86) when calling the function.
265         // * The same object file may be used in different circumstances, so a
266         //   function may be imported from a dll if the object is linked into a
267         //   dll, but it may be just linked against if linked into an rlib.
268         // * The compiler has no knowledge about whether native functions should
269         //   be tagged dllimport or not.
270         //
271         // For now the compiler takes the perf hit (I do not have any numbers to
272         // this effect) by marking very little as `dllimport` and praying the
273         // linker will take care of everything. Fixing this problem will likely
274         // require adding a few attributes to Rust itself (feature gated at the
275         // start) and then strongly recommending static linkage on MSVC!
276         let use_dll_storage_attrs = tcx.sess.target.target.options.is_like_msvc;
277
278         let check_overflow = tcx.sess.overflow_checks();
279
280         let tls_model = get_tls_model(&tcx.sess);
281
282         let (llcx, llmod) = (&*llvm_module.llcx, llvm_module.llmod());
283
284         let dbg_cx = if tcx.sess.opts.debuginfo != DebugInfo::None {
285             let dctx = debuginfo::CrateDebugContext::new(llmod);
286             debuginfo::metadata::compile_unit_metadata(tcx,
287                                                        &codegen_unit.name().as_str(),
288                                                        &dctx);
289             Some(dctx)
290         } else {
291             None
292         };
293
294         let isize_ty = Type::ix_llcx(llcx, tcx.data_layout.pointer_size.bits());
295
296         CodegenCx {
297             tcx,
298             check_overflow,
299             use_dll_storage_attrs,
300             tls_model,
301             llmod,
302             llcx,
303             codegen_unit,
304             instances: Default::default(),
305             vtables: Default::default(),
306             const_cstr_cache: Default::default(),
307             const_unsized: Default::default(),
308             const_globals: Default::default(),
309             statics_to_rauw: RefCell::new(Vec::new()),
310             used_statics: RefCell::new(Vec::new()),
311             lltypes: Default::default(),
312             scalar_lltypes: Default::default(),
313             pointee_infos: Default::default(),
314             isize_ty,
315             dbg_cx,
316             eh_personality: Cell::new(None),
317             eh_unwind_resume: Cell::new(None),
318             rust_try_fn: Cell::new(None),
319             intrinsics: Default::default(),
320             local_gen_sym_counter: Cell::new(0),
321         }
322     }
323
324     crate fn statics_to_rauw(&self) -> &RefCell<Vec<(&'ll Value, &'ll Value)>> {
325         &self.statics_to_rauw
326     }
327 }
328
329 impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
330     fn vtables(&self) -> &RefCell<FxHashMap<(Ty<'tcx>,
331                                 Option<ty::PolyExistentialTraitRef<'tcx>>), &'ll Value>>
332     {
333         &self.vtables
334     }
335
336     fn get_fn(&self, instance: Instance<'tcx>) -> &'ll Value {
337         get_fn(self, instance)
338     }
339
340     fn get_fn_addr(&self, instance: Instance<'tcx>) -> &'ll Value {
341         get_fn(self, instance)
342     }
343
344     fn eh_personality(&self) -> &'ll Value {
345         // The exception handling personality function.
346         //
347         // If our compilation unit has the `eh_personality` lang item somewhere
348         // within it, then we just need to codegen that. Otherwise, we're
349         // building an rlib which will depend on some upstream implementation of
350         // this function, so we just codegen a generic reference to it. We don't
351         // specify any of the types for the function, we just make it a symbol
352         // that LLVM can later use.
353         //
354         // Note that MSVC is a little special here in that we don't use the
355         // `eh_personality` lang item at all. Currently LLVM has support for
356         // both Dwarf and SEH unwind mechanisms for MSVC targets and uses the
357         // *name of the personality function* to decide what kind of unwind side
358         // tables/landing pads to emit. It looks like Dwarf is used by default,
359         // injecting a dependency on the `_Unwind_Resume` symbol for resuming
360         // an "exception", but for MSVC we want to force SEH. This means that we
361         // can't actually have the personality function be our standard
362         // `rust_eh_personality` function, but rather we wired it up to the
363         // CRT's custom personality function, which forces LLVM to consider
364         // landing pads as "landing pads for SEH".
365         if let Some(llpersonality) = self.eh_personality.get() {
366             return llpersonality
367         }
368         let tcx = self.tcx;
369         let llfn = match tcx.lang_items().eh_personality() {
370             Some(def_id) if !wants_msvc_seh(self.sess()) => {
371                 self.get_fn_addr(
372                     ty::Instance::resolve(
373                         tcx,
374                         ty::ParamEnv::reveal_all(),
375                         def_id,
376                         tcx.intern_substs(&[]),
377                     ).unwrap()
378                 )
379             }
380             _ => {
381                 let name = if wants_msvc_seh(self.sess()) {
382                     "__CxxFrameHandler3"
383                 } else {
384                     "rust_eh_personality"
385                 };
386                 let fty = self.type_variadic_func(&[], self.type_i32());
387                 self.declare_cfn(name, fty)
388             }
389         };
390         attributes::apply_target_cpu_attr(self, llfn);
391         self.eh_personality.set(Some(llfn));
392         llfn
393     }
394
395     // Returns a Value of the "eh_unwind_resume" lang item if one is defined,
396     // otherwise declares it as an external function.
397     fn eh_unwind_resume(&self) -> &'ll Value {
398         let unwresume = &self.eh_unwind_resume;
399         if let Some(llfn) = unwresume.get() {
400             return llfn;
401         }
402
403         let tcx = self.tcx;
404         assert!(self.sess().target.target.options.custom_unwind_resume);
405         if let Some(def_id) = tcx.lang_items().eh_unwind_resume() {
406             let llfn = self.get_fn_addr(
407                 ty::Instance::resolve(
408                     tcx,
409                     ty::ParamEnv::reveal_all(),
410                     def_id,
411                     tcx.intern_substs(&[]),
412                 ).unwrap()
413             );
414             unwresume.set(Some(llfn));
415             return llfn;
416         }
417
418         let sig = ty::Binder::bind(tcx.mk_fn_sig(
419             iter::once(tcx.mk_mut_ptr(tcx.types.u8)),
420             tcx.types.never,
421             false,
422             hir::Unsafety::Unsafe,
423             Abi::C
424         ));
425
426         let fn_abi = FnAbi::of_fn_ptr(self, sig, &[]);
427         let llfn = self.declare_fn("rust_eh_unwind_resume", &fn_abi);
428         attributes::apply_target_cpu_attr(self, llfn);
429         unwresume.set(Some(llfn));
430         llfn
431     }
432
433     fn sess(&self) -> &Session {
434         &self.tcx.sess
435     }
436
437     fn check_overflow(&self) -> bool {
438         self.check_overflow
439     }
440
441     fn codegen_unit(&self) -> &Arc<CodegenUnit<'tcx>> {
442         &self.codegen_unit
443     }
444
445     fn used_statics(&self) -> &RefCell<Vec<&'ll Value>> {
446         &self.used_statics
447     }
448
449     fn set_frame_pointer_elimination(&self, llfn: &'ll Value) {
450         attributes::set_frame_pointer_elimination(self, llfn)
451     }
452
453     fn apply_target_cpu_attr(&self, llfn: &'ll Value) {
454         attributes::apply_target_cpu_attr(self, llfn)
455     }
456
457     fn create_used_variable(&self) {
458         let name = const_cstr!("llvm.used");
459         let section = const_cstr!("llvm.metadata");
460         let array = self.const_array(
461             &self.type_ptr_to(self.type_i8()),
462             &*self.used_statics.borrow()
463         );
464
465         unsafe {
466             let g = llvm::LLVMAddGlobal(self.llmod,
467                                         self.val_ty(array),
468                                         name.as_ptr());
469             llvm::LLVMSetInitializer(g, array);
470             llvm::LLVMRustSetLinkage(g, llvm::Linkage::AppendingLinkage);
471             llvm::LLVMSetSection(g, section.as_ptr());
472         }
473     }
474 }
475
476 impl CodegenCx<'b, 'tcx> {
477     crate fn get_intrinsic(&self, key: &str) -> &'b Value {
478         if let Some(v) = self.intrinsics.borrow().get(key).cloned() {
479             return v;
480         }
481
482         self.declare_intrinsic(key).unwrap_or_else(|| bug!("unknown intrinsic '{}'", key))
483     }
484
485     fn insert_intrinsic(
486         &self, name: &'static str, args: Option<&[&'b llvm::Type]>, ret: &'b llvm::Type
487     ) -> &'b llvm::Value {
488         let fn_ty = if let Some(args) = args {
489             self.type_func(args, ret)
490         } else {
491             self.type_variadic_func(&[], ret)
492         };
493         let f = self.declare_cfn(name, fn_ty);
494         llvm::SetUnnamedAddr(f, false);
495         self.intrinsics.borrow_mut().insert(name, f);
496         f
497     }
498
499     fn declare_intrinsic(
500         &self,
501         key: &str
502     ) -> Option<&'b Value> {
503         macro_rules! ifn {
504             ($name:expr, fn() -> $ret:expr) => (
505                 if key == $name {
506                     return Some(self.insert_intrinsic($name, Some(&[]), $ret));
507                 }
508             );
509             ($name:expr, fn(...) -> $ret:expr) => (
510                 if key == $name {
511                     return Some(self.insert_intrinsic($name, None, $ret));
512                 }
513             );
514             ($name:expr, fn($($arg:expr),*) -> $ret:expr) => (
515                 if key == $name {
516                     return Some(self.insert_intrinsic($name, Some(&[$($arg),*]), $ret));
517                 }
518             );
519         }
520         macro_rules! mk_struct {
521             ($($field_ty:expr),*) => (self.type_struct( &[$($field_ty),*], false))
522         }
523
524         let i8p = self.type_i8p();
525         let void = self.type_void();
526         let i1 = self.type_i1();
527         let t_i8 = self.type_i8();
528         let t_i16 = self.type_i16();
529         let t_i32 = self.type_i32();
530         let t_i64 = self.type_i64();
531         let t_i128 = self.type_i128();
532         let t_f32 = self.type_f32();
533         let t_f64 = self.type_f64();
534
535         macro_rules! vector_types {
536             ($id_out:ident: $elem_ty:ident, $len:expr) => {
537                 let $id_out = self.type_vector($elem_ty, $len);
538             };
539             ($($id_out:ident: $elem_ty:ident, $len:expr;)*) => {
540                 $(vector_types!($id_out: $elem_ty, $len);)*
541             }
542         }
543         vector_types! {
544             t_v2f32: t_f32, 2;
545             t_v4f32: t_f32, 4;
546             t_v8f32: t_f32, 8;
547             t_v16f32: t_f32, 16;
548
549             t_v2f64: t_f64, 2;
550             t_v4f64: t_f64, 4;
551             t_v8f64: t_f64, 8;
552         }
553
554         ifn!("llvm.memset.p0i8.i16", fn(i8p, t_i8, t_i16, t_i32, i1) -> void);
555         ifn!("llvm.memset.p0i8.i32", fn(i8p, t_i8, t_i32, t_i32, i1) -> void);
556         ifn!("llvm.memset.p0i8.i64", fn(i8p, t_i8, t_i64, t_i32, i1) -> void);
557
558         ifn!("llvm.trap", fn() -> void);
559         ifn!("llvm.debugtrap", fn() -> void);
560         ifn!("llvm.frameaddress", fn(t_i32) -> i8p);
561         ifn!("llvm.sideeffect", fn() -> void);
562
563         ifn!("llvm.powi.f32", fn(t_f32, t_i32) -> t_f32);
564         ifn!("llvm.powi.v2f32", fn(t_v2f32, t_i32) -> t_v2f32);
565         ifn!("llvm.powi.v4f32", fn(t_v4f32, t_i32) -> t_v4f32);
566         ifn!("llvm.powi.v8f32", fn(t_v8f32, t_i32) -> t_v8f32);
567         ifn!("llvm.powi.v16f32", fn(t_v16f32, t_i32) -> t_v16f32);
568         ifn!("llvm.powi.f64", fn(t_f64, t_i32) -> t_f64);
569         ifn!("llvm.powi.v2f64", fn(t_v2f64, t_i32) -> t_v2f64);
570         ifn!("llvm.powi.v4f64", fn(t_v4f64, t_i32) -> t_v4f64);
571         ifn!("llvm.powi.v8f64", fn(t_v8f64, t_i32) -> t_v8f64);
572
573         ifn!("llvm.pow.f32", fn(t_f32, t_f32) -> t_f32);
574         ifn!("llvm.pow.v2f32", fn(t_v2f32, t_v2f32) -> t_v2f32);
575         ifn!("llvm.pow.v4f32", fn(t_v4f32, t_v4f32) -> t_v4f32);
576         ifn!("llvm.pow.v8f32", fn(t_v8f32, t_v8f32) -> t_v8f32);
577         ifn!("llvm.pow.v16f32", fn(t_v16f32, t_v16f32) -> t_v16f32);
578         ifn!("llvm.pow.f64", fn(t_f64, t_f64) -> t_f64);
579         ifn!("llvm.pow.v2f64", fn(t_v2f64, t_v2f64) -> t_v2f64);
580         ifn!("llvm.pow.v4f64", fn(t_v4f64, t_v4f64) -> t_v4f64);
581         ifn!("llvm.pow.v8f64", fn(t_v8f64, t_v8f64) -> t_v8f64);
582
583         ifn!("llvm.sqrt.f32", fn(t_f32) -> t_f32);
584         ifn!("llvm.sqrt.v2f32", fn(t_v2f32) -> t_v2f32);
585         ifn!("llvm.sqrt.v4f32", fn(t_v4f32) -> t_v4f32);
586         ifn!("llvm.sqrt.v8f32", fn(t_v8f32) -> t_v8f32);
587         ifn!("llvm.sqrt.v16f32", fn(t_v16f32) -> t_v16f32);
588         ifn!("llvm.sqrt.f64", fn(t_f64) -> t_f64);
589         ifn!("llvm.sqrt.v2f64", fn(t_v2f64) -> t_v2f64);
590         ifn!("llvm.sqrt.v4f64", fn(t_v4f64) -> t_v4f64);
591         ifn!("llvm.sqrt.v8f64", fn(t_v8f64) -> t_v8f64);
592
593         ifn!("llvm.sin.f32", fn(t_f32) -> t_f32);
594         ifn!("llvm.sin.v2f32", fn(t_v2f32) -> t_v2f32);
595         ifn!("llvm.sin.v4f32", fn(t_v4f32) -> t_v4f32);
596         ifn!("llvm.sin.v8f32", fn(t_v8f32) -> t_v8f32);
597         ifn!("llvm.sin.v16f32", fn(t_v16f32) -> t_v16f32);
598         ifn!("llvm.sin.f64", fn(t_f64) -> t_f64);
599         ifn!("llvm.sin.v2f64", fn(t_v2f64) -> t_v2f64);
600         ifn!("llvm.sin.v4f64", fn(t_v4f64) -> t_v4f64);
601         ifn!("llvm.sin.v8f64", fn(t_v8f64) -> t_v8f64);
602
603         ifn!("llvm.cos.f32", fn(t_f32) -> t_f32);
604         ifn!("llvm.cos.v2f32", fn(t_v2f32) -> t_v2f32);
605         ifn!("llvm.cos.v4f32", fn(t_v4f32) -> t_v4f32);
606         ifn!("llvm.cos.v8f32", fn(t_v8f32) -> t_v8f32);
607         ifn!("llvm.cos.v16f32", fn(t_v16f32) -> t_v16f32);
608         ifn!("llvm.cos.f64", fn(t_f64) -> t_f64);
609         ifn!("llvm.cos.v2f64", fn(t_v2f64) -> t_v2f64);
610         ifn!("llvm.cos.v4f64", fn(t_v4f64) -> t_v4f64);
611         ifn!("llvm.cos.v8f64", fn(t_v8f64) -> t_v8f64);
612
613         ifn!("llvm.exp.f32", fn(t_f32) -> t_f32);
614         ifn!("llvm.exp.v2f32", fn(t_v2f32) -> t_v2f32);
615         ifn!("llvm.exp.v4f32", fn(t_v4f32) -> t_v4f32);
616         ifn!("llvm.exp.v8f32", fn(t_v8f32) -> t_v8f32);
617         ifn!("llvm.exp.v16f32", fn(t_v16f32) -> t_v16f32);
618         ifn!("llvm.exp.f64", fn(t_f64) -> t_f64);
619         ifn!("llvm.exp.v2f64", fn(t_v2f64) -> t_v2f64);
620         ifn!("llvm.exp.v4f64", fn(t_v4f64) -> t_v4f64);
621         ifn!("llvm.exp.v8f64", fn(t_v8f64) -> t_v8f64);
622
623         ifn!("llvm.exp2.f32", fn(t_f32) -> t_f32);
624         ifn!("llvm.exp2.v2f32", fn(t_v2f32) -> t_v2f32);
625         ifn!("llvm.exp2.v4f32", fn(t_v4f32) -> t_v4f32);
626         ifn!("llvm.exp2.v8f32", fn(t_v8f32) -> t_v8f32);
627         ifn!("llvm.exp2.v16f32", fn(t_v16f32) -> t_v16f32);
628         ifn!("llvm.exp2.f64", fn(t_f64) -> t_f64);
629         ifn!("llvm.exp2.v2f64", fn(t_v2f64) -> t_v2f64);
630         ifn!("llvm.exp2.v4f64", fn(t_v4f64) -> t_v4f64);
631         ifn!("llvm.exp2.v8f64", fn(t_v8f64) -> t_v8f64);
632
633         ifn!("llvm.log.f32", fn(t_f32) -> t_f32);
634         ifn!("llvm.log.v2f32", fn(t_v2f32) -> t_v2f32);
635         ifn!("llvm.log.v4f32", fn(t_v4f32) -> t_v4f32);
636         ifn!("llvm.log.v8f32", fn(t_v8f32) -> t_v8f32);
637         ifn!("llvm.log.v16f32", fn(t_v16f32) -> t_v16f32);
638         ifn!("llvm.log.f64", fn(t_f64) -> t_f64);
639         ifn!("llvm.log.v2f64", fn(t_v2f64) -> t_v2f64);
640         ifn!("llvm.log.v4f64", fn(t_v4f64) -> t_v4f64);
641         ifn!("llvm.log.v8f64", fn(t_v8f64) -> t_v8f64);
642
643         ifn!("llvm.log10.f32", fn(t_f32) -> t_f32);
644         ifn!("llvm.log10.v2f32", fn(t_v2f32) -> t_v2f32);
645         ifn!("llvm.log10.v4f32", fn(t_v4f32) -> t_v4f32);
646         ifn!("llvm.log10.v8f32", fn(t_v8f32) -> t_v8f32);
647         ifn!("llvm.log10.v16f32", fn(t_v16f32) -> t_v16f32);
648         ifn!("llvm.log10.f64", fn(t_f64) -> t_f64);
649         ifn!("llvm.log10.v2f64", fn(t_v2f64) -> t_v2f64);
650         ifn!("llvm.log10.v4f64", fn(t_v4f64) -> t_v4f64);
651         ifn!("llvm.log10.v8f64", fn(t_v8f64) -> t_v8f64);
652
653         ifn!("llvm.log2.f32", fn(t_f32) -> t_f32);
654         ifn!("llvm.log2.v2f32", fn(t_v2f32) -> t_v2f32);
655         ifn!("llvm.log2.v4f32", fn(t_v4f32) -> t_v4f32);
656         ifn!("llvm.log2.v8f32", fn(t_v8f32) -> t_v8f32);
657         ifn!("llvm.log2.v16f32", fn(t_v16f32) -> t_v16f32);
658         ifn!("llvm.log2.f64", fn(t_f64) -> t_f64);
659         ifn!("llvm.log2.v2f64", fn(t_v2f64) -> t_v2f64);
660         ifn!("llvm.log2.v4f64", fn(t_v4f64) -> t_v4f64);
661         ifn!("llvm.log2.v8f64", fn(t_v8f64) -> t_v8f64);
662
663         ifn!("llvm.fma.f32", fn(t_f32, t_f32, t_f32) -> t_f32);
664         ifn!("llvm.fma.v2f32", fn(t_v2f32, t_v2f32, t_v2f32) -> t_v2f32);
665         ifn!("llvm.fma.v4f32", fn(t_v4f32, t_v4f32, t_v4f32) -> t_v4f32);
666         ifn!("llvm.fma.v8f32", fn(t_v8f32, t_v8f32, t_v8f32) -> t_v8f32);
667         ifn!("llvm.fma.v16f32", fn(t_v16f32, t_v16f32, t_v16f32) -> t_v16f32);
668         ifn!("llvm.fma.f64", fn(t_f64, t_f64, t_f64) -> t_f64);
669         ifn!("llvm.fma.v2f64", fn(t_v2f64, t_v2f64, t_v2f64) -> t_v2f64);
670         ifn!("llvm.fma.v4f64", fn(t_v4f64, t_v4f64, t_v4f64) -> t_v4f64);
671         ifn!("llvm.fma.v8f64", fn(t_v8f64, t_v8f64, t_v8f64) -> t_v8f64);
672
673         ifn!("llvm.fabs.f32", fn(t_f32) -> t_f32);
674         ifn!("llvm.fabs.v2f32", fn(t_v2f32) -> t_v2f32);
675         ifn!("llvm.fabs.v4f32", fn(t_v4f32) -> t_v4f32);
676         ifn!("llvm.fabs.v8f32", fn(t_v8f32) -> t_v8f32);
677         ifn!("llvm.fabs.v16f32", fn(t_v16f32) -> t_v16f32);
678         ifn!("llvm.fabs.f64", fn(t_f64) -> t_f64);
679         ifn!("llvm.fabs.v2f64", fn(t_v2f64) -> t_v2f64);
680         ifn!("llvm.fabs.v4f64", fn(t_v4f64) -> t_v4f64);
681         ifn!("llvm.fabs.v8f64", fn(t_v8f64) -> t_v8f64);
682
683         ifn!("llvm.minnum.f32", fn(t_f32, t_f32) -> t_f32);
684         ifn!("llvm.minnum.f64", fn(t_f64, t_f64) -> t_f64);
685         ifn!("llvm.maxnum.f32", fn(t_f32, t_f32) -> t_f32);
686         ifn!("llvm.maxnum.f64", fn(t_f64, t_f64) -> t_f64);
687
688         ifn!("llvm.floor.f32", fn(t_f32) -> t_f32);
689         ifn!("llvm.floor.v2f32", fn(t_v2f32) -> t_v2f32);
690         ifn!("llvm.floor.v4f32", fn(t_v4f32) -> t_v4f32);
691         ifn!("llvm.floor.v8f32", fn(t_v8f32) -> t_v8f32);
692         ifn!("llvm.floor.v16f32", fn(t_v16f32) -> t_v16f32);
693         ifn!("llvm.floor.f64", fn(t_f64) -> t_f64);
694         ifn!("llvm.floor.v2f64", fn(t_v2f64) -> t_v2f64);
695         ifn!("llvm.floor.v4f64", fn(t_v4f64) -> t_v4f64);
696         ifn!("llvm.floor.v8f64", fn(t_v8f64) -> t_v8f64);
697
698         ifn!("llvm.ceil.f32", fn(t_f32) -> t_f32);
699         ifn!("llvm.ceil.v2f32", fn(t_v2f32) -> t_v2f32);
700         ifn!("llvm.ceil.v4f32", fn(t_v4f32) -> t_v4f32);
701         ifn!("llvm.ceil.v8f32", fn(t_v8f32) -> t_v8f32);
702         ifn!("llvm.ceil.v16f32", fn(t_v16f32) -> t_v16f32);
703         ifn!("llvm.ceil.f64", fn(t_f64) -> t_f64);
704         ifn!("llvm.ceil.v2f64", fn(t_v2f64) -> t_v2f64);
705         ifn!("llvm.ceil.v4f64", fn(t_v4f64) -> t_v4f64);
706         ifn!("llvm.ceil.v8f64", fn(t_v8f64) -> t_v8f64);
707
708         ifn!("llvm.trunc.f32", fn(t_f32) -> t_f32);
709         ifn!("llvm.trunc.f64", fn(t_f64) -> t_f64);
710
711         ifn!("llvm.copysign.f32", fn(t_f32, t_f32) -> t_f32);
712         ifn!("llvm.copysign.f64", fn(t_f64, t_f64) -> t_f64);
713         ifn!("llvm.round.f32", fn(t_f32) -> t_f32);
714         ifn!("llvm.round.f64", fn(t_f64) -> t_f64);
715
716         ifn!("llvm.rint.f32", fn(t_f32) -> t_f32);
717         ifn!("llvm.rint.f64", fn(t_f64) -> t_f64);
718         ifn!("llvm.nearbyint.f32", fn(t_f32) -> t_f32);
719         ifn!("llvm.nearbyint.f64", fn(t_f64) -> t_f64);
720
721         ifn!("llvm.ctpop.i8", fn(t_i8) -> t_i8);
722         ifn!("llvm.ctpop.i16", fn(t_i16) -> t_i16);
723         ifn!("llvm.ctpop.i32", fn(t_i32) -> t_i32);
724         ifn!("llvm.ctpop.i64", fn(t_i64) -> t_i64);
725         ifn!("llvm.ctpop.i128", fn(t_i128) -> t_i128);
726
727         ifn!("llvm.ctlz.i8", fn(t_i8 , i1) -> t_i8);
728         ifn!("llvm.ctlz.i16", fn(t_i16, i1) -> t_i16);
729         ifn!("llvm.ctlz.i32", fn(t_i32, i1) -> t_i32);
730         ifn!("llvm.ctlz.i64", fn(t_i64, i1) -> t_i64);
731         ifn!("llvm.ctlz.i128", fn(t_i128, i1) -> t_i128);
732
733         ifn!("llvm.cttz.i8", fn(t_i8 , i1) -> t_i8);
734         ifn!("llvm.cttz.i16", fn(t_i16, i1) -> t_i16);
735         ifn!("llvm.cttz.i32", fn(t_i32, i1) -> t_i32);
736         ifn!("llvm.cttz.i64", fn(t_i64, i1) -> t_i64);
737         ifn!("llvm.cttz.i128", fn(t_i128, i1) -> t_i128);
738
739         ifn!("llvm.bswap.i16", fn(t_i16) -> t_i16);
740         ifn!("llvm.bswap.i32", fn(t_i32) -> t_i32);
741         ifn!("llvm.bswap.i64", fn(t_i64) -> t_i64);
742         ifn!("llvm.bswap.i128", fn(t_i128) -> t_i128);
743
744         ifn!("llvm.bitreverse.i8", fn(t_i8) -> t_i8);
745         ifn!("llvm.bitreverse.i16", fn(t_i16) -> t_i16);
746         ifn!("llvm.bitreverse.i32", fn(t_i32) -> t_i32);
747         ifn!("llvm.bitreverse.i64", fn(t_i64) -> t_i64);
748         ifn!("llvm.bitreverse.i128", fn(t_i128) -> t_i128);
749
750         ifn!("llvm.fshl.i8", fn(t_i8, t_i8, t_i8) -> t_i8);
751         ifn!("llvm.fshl.i16", fn(t_i16, t_i16, t_i16) -> t_i16);
752         ifn!("llvm.fshl.i32", fn(t_i32, t_i32, t_i32) -> t_i32);
753         ifn!("llvm.fshl.i64", fn(t_i64, t_i64, t_i64) -> t_i64);
754         ifn!("llvm.fshl.i128", fn(t_i128, t_i128, t_i128) -> t_i128);
755
756         ifn!("llvm.fshr.i8", fn(t_i8, t_i8, t_i8) -> t_i8);
757         ifn!("llvm.fshr.i16", fn(t_i16, t_i16, t_i16) -> t_i16);
758         ifn!("llvm.fshr.i32", fn(t_i32, t_i32, t_i32) -> t_i32);
759         ifn!("llvm.fshr.i64", fn(t_i64, t_i64, t_i64) -> t_i64);
760         ifn!("llvm.fshr.i128", fn(t_i128, t_i128, t_i128) -> t_i128);
761
762         ifn!("llvm.sadd.with.overflow.i8", fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
763         ifn!("llvm.sadd.with.overflow.i16", fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
764         ifn!("llvm.sadd.with.overflow.i32", fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
765         ifn!("llvm.sadd.with.overflow.i64", fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
766         ifn!("llvm.sadd.with.overflow.i128", fn(t_i128, t_i128) -> mk_struct!{t_i128, i1});
767
768         ifn!("llvm.uadd.with.overflow.i8", fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
769         ifn!("llvm.uadd.with.overflow.i16", fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
770         ifn!("llvm.uadd.with.overflow.i32", fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
771         ifn!("llvm.uadd.with.overflow.i64", fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
772         ifn!("llvm.uadd.with.overflow.i128", fn(t_i128, t_i128) -> mk_struct!{t_i128, i1});
773
774         ifn!("llvm.ssub.with.overflow.i8", fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
775         ifn!("llvm.ssub.with.overflow.i16", fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
776         ifn!("llvm.ssub.with.overflow.i32", fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
777         ifn!("llvm.ssub.with.overflow.i64", fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
778         ifn!("llvm.ssub.with.overflow.i128", fn(t_i128, t_i128) -> mk_struct!{t_i128, i1});
779
780         ifn!("llvm.usub.with.overflow.i8", fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
781         ifn!("llvm.usub.with.overflow.i16", fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
782         ifn!("llvm.usub.with.overflow.i32", fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
783         ifn!("llvm.usub.with.overflow.i64", fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
784         ifn!("llvm.usub.with.overflow.i128", fn(t_i128, t_i128) -> mk_struct!{t_i128, i1});
785
786         ifn!("llvm.smul.with.overflow.i8", fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
787         ifn!("llvm.smul.with.overflow.i16", fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
788         ifn!("llvm.smul.with.overflow.i32", fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
789         ifn!("llvm.smul.with.overflow.i64", fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
790         ifn!("llvm.smul.with.overflow.i128", fn(t_i128, t_i128) -> mk_struct!{t_i128, i1});
791
792         ifn!("llvm.umul.with.overflow.i8", fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
793         ifn!("llvm.umul.with.overflow.i16", fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
794         ifn!("llvm.umul.with.overflow.i32", fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
795         ifn!("llvm.umul.with.overflow.i64", fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
796         ifn!("llvm.umul.with.overflow.i128", fn(t_i128, t_i128) -> mk_struct!{t_i128, i1});
797
798         ifn!("llvm.sadd.sat.i8", fn(t_i8, t_i8) -> t_i8);
799         ifn!("llvm.sadd.sat.i16", fn(t_i16, t_i16) -> t_i16);
800         ifn!("llvm.sadd.sat.i32", fn(t_i32, t_i32) -> t_i32);
801         ifn!("llvm.sadd.sat.i64", fn(t_i64, t_i64) -> t_i64);
802         ifn!("llvm.sadd.sat.i128", fn(t_i128, t_i128) -> t_i128);
803
804         ifn!("llvm.uadd.sat.i8", fn(t_i8, t_i8) -> t_i8);
805         ifn!("llvm.uadd.sat.i16", fn(t_i16, t_i16) -> t_i16);
806         ifn!("llvm.uadd.sat.i32", fn(t_i32, t_i32) -> t_i32);
807         ifn!("llvm.uadd.sat.i64", fn(t_i64, t_i64) -> t_i64);
808         ifn!("llvm.uadd.sat.i128", fn(t_i128, t_i128) -> t_i128);
809
810         ifn!("llvm.ssub.sat.i8", fn(t_i8, t_i8) -> t_i8);
811         ifn!("llvm.ssub.sat.i16", fn(t_i16, t_i16) -> t_i16);
812         ifn!("llvm.ssub.sat.i32", fn(t_i32, t_i32) -> t_i32);
813         ifn!("llvm.ssub.sat.i64", fn(t_i64, t_i64) -> t_i64);
814         ifn!("llvm.ssub.sat.i128", fn(t_i128, t_i128) -> t_i128);
815
816         ifn!("llvm.usub.sat.i8", fn(t_i8, t_i8) -> t_i8);
817         ifn!("llvm.usub.sat.i16", fn(t_i16, t_i16) -> t_i16);
818         ifn!("llvm.usub.sat.i32", fn(t_i32, t_i32) -> t_i32);
819         ifn!("llvm.usub.sat.i64", fn(t_i64, t_i64) -> t_i64);
820         ifn!("llvm.usub.sat.i128", fn(t_i128, t_i128) -> t_i128);
821
822         ifn!("llvm.lifetime.start", fn(t_i64,i8p) -> void);
823         ifn!("llvm.lifetime.end", fn(t_i64, i8p) -> void);
824
825         ifn!("llvm.expect.i1", fn(i1, i1) -> i1);
826         ifn!("llvm.eh.typeid.for", fn(i8p) -> t_i32);
827         ifn!("llvm.localescape", fn(...) -> void);
828         ifn!("llvm.localrecover", fn(i8p, i8p, t_i32) -> i8p);
829         ifn!("llvm.x86.seh.recoverfp", fn(i8p, i8p) -> i8p);
830
831         ifn!("llvm.assume", fn(i1) -> void);
832         ifn!("llvm.prefetch", fn(i8p, t_i32, t_i32, t_i32) -> void);
833
834         // variadic intrinsics
835         ifn!("llvm.va_start", fn(i8p) -> void);
836         ifn!("llvm.va_end", fn(i8p) -> void);
837         ifn!("llvm.va_copy", fn(i8p, i8p) -> void);
838
839         if self.sess().opts.debuginfo != DebugInfo::None {
840             ifn!("llvm.dbg.declare", fn(self.type_metadata(), self.type_metadata()) -> void);
841             ifn!("llvm.dbg.value", fn(self.type_metadata(), t_i64, self.type_metadata()) -> void);
842         }
843         return None;
844     }
845 }
846
847 impl<'b, 'tcx> CodegenCx<'b, 'tcx> {
848     /// Generates a new symbol name with the given prefix. This symbol name must
849     /// only be used for definitions with `internal` or `private` linkage.
850     pub fn generate_local_symbol_name(&self, prefix: &str) -> String {
851         let idx = self.local_gen_sym_counter.get();
852         self.local_gen_sym_counter.set(idx + 1);
853         // Include a '.' character, so there can be no accidental conflicts with
854         // user defined names
855         let mut name = String::with_capacity(prefix.len() + 6);
856         name.push_str(prefix);
857         name.push_str(".");
858         base_n::push_str(idx as u128, base_n::ALPHANUMERIC_ONLY, &mut name);
859         name
860     }
861 }
862
863 impl ty::layout::HasDataLayout for CodegenCx<'ll, 'tcx> {
864     fn data_layout(&self) -> &ty::layout::TargetDataLayout {
865         &self.tcx.data_layout
866     }
867 }
868
869 impl HasTargetSpec for CodegenCx<'ll, 'tcx> {
870     fn target_spec(&self) -> &Target {
871         &self.tcx.sess.target.target
872     }
873 }
874
875 impl ty::layout::HasTyCtxt<'tcx> for CodegenCx<'ll, 'tcx> {
876     fn tcx(&self) -> TyCtxt<'tcx> {
877         self.tcx
878     }
879 }
880
881 impl LayoutOf for CodegenCx<'ll, 'tcx> {
882     type Ty = Ty<'tcx>;
883     type TyLayout = TyLayout<'tcx>;
884
885     fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
886         self.spanned_layout_of(ty, DUMMY_SP)
887     }
888
889     fn spanned_layout_of(&self, ty: Ty<'tcx>, span: Span) -> Self::TyLayout {
890         self.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty))
891             .unwrap_or_else(|e| if let LayoutError::SizeOverflow(_) = e {
892                 self.sess().span_fatal(span, &e.to_string())
893             } else {
894                 bug!("failed to get layout for `{}`: {}", ty, e)
895             })
896     }
897 }
898
899 impl<'tcx, 'll> HasParamEnv<'tcx> for CodegenCx<'ll, 'tcx> {
900     fn param_env(&self) -> ty::ParamEnv<'tcx> {
901         ty::ParamEnv::reveal_all()
902     }
903 }