(
tcx: TyCtxt<'tcx>,
codegen_unit: &'tcx CodegenUnit<'tcx>,
llvm_module: &'ll LlvmMod,
)
| 100 | |
| 101 | impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> { |
| 102 | pub(crate) fn new( |
| 103 | tcx: TyCtxt<'tcx>, |
| 104 | codegen_unit: &'tcx CodegenUnit<'tcx>, |
| 105 | llvm_module: &'ll LlvmMod, |
| 106 | ) -> Self { |
| 107 | debug!("Creating new CodegenCx"); |
| 108 | let check_overflow = tcx.sess.overflow_checks(); |
| 109 | let (llcx, llmod) = (&*llvm_module.llcx, unsafe { |
| 110 | llvm_module.llmod.as_ref().unwrap() |
| 111 | }); |
| 112 | |
| 113 | let isize_ty = Type::ix_llcx(llcx, target::pointer_size() as u64); |
| 114 | // the eh_personality function doesnt make sense on the GPU, but we still need to give |
| 115 | // rustc something, so we just give it an empty function |
| 116 | let eh_personality = unsafe { |
| 117 | let void = llvm::LLVMVoidTypeInContext(llcx); |
| 118 | let llfnty = llvm::LLVMFunctionType(void, null(), 0, llvm::False); |
| 119 | let name = "__rust_eh_personality"; |
| 120 | llvm::LLVMRustGetOrInsertFunction(llmod, name.as_ptr().cast(), name.len(), llfnty) |
| 121 | }; |
| 122 | |
| 123 | let dbg_cx = if tcx.sess.opts.debuginfo != DebugInfo::None { |
| 124 | let dctx = CrateDebugContext::new(llmod); |
| 125 | compile_unit_metadata(tcx, &codegen_unit.name().as_str(), &dctx); |
| 126 | Some(dctx) |
| 127 | } else { |
| 128 | None |
| 129 | }; |
| 130 | |
| 131 | let mut cx = CodegenCx { |
| 132 | tcx, |
| 133 | check_overflow, |
| 134 | llmod, |
| 135 | llcx, |
| 136 | codegen_unit, |
| 137 | instances: Default::default(), |
| 138 | vtables: Default::default(), |
| 139 | const_cstr_cache: Default::default(), |
| 140 | remapped_integer_args: Default::default(), |
| 141 | const_globals: Default::default(), |
| 142 | statics_to_rauw: RefCell::new(Vec::new()), |
| 143 | used_statics: RefCell::new(Vec::new()), |
| 144 | compiler_used_statics: RefCell::new(Vec::new()), |
| 145 | lltypes: Default::default(), |
| 146 | scalar_lltypes: Default::default(), |
| 147 | pointee_infos: Default::default(), |
| 148 | isize_ty, |
| 149 | intrinsics: Default::default(), |
| 150 | intrinsics_map: RefCell::new(FxHashMap::with_capacity_and_hasher( |
| 151 | // ~319 libdevice intrinsics plus some headroom for llvm |
| 152 | 350, |
| 153 | BuildHasherDefault::default(), |
| 154 | )), |
| 155 | local_gen_sym_counter: Cell::new(0), |
| 156 | nvptx_data_layout: TargetDataLayout::parse(&target::target()).unwrap(), |
| 157 | nvptx_target: target::target(), |
| 158 | eh_personality, |
| 159 | symbols: Symbols { |
nothing calls this directly
no test coverage detected