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