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