Skip to content

Commit d7ad3fe

Browse files
committed
make bitcast work for new "opaque pointers"?
1 parent f38390b commit d7ad3fe

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

crates/rustc_codegen_nvvm_v19/src/builder.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::ptr;
44

55
use libc::{c_char, c_uint};
66
use rustc_abi as abi;
7-
use rustc_abi::{AddressSpace, Align, HasDataLayout, Size, TargetDataLayout, WrappingRange};
7+
use rustc_abi::{Align, HasDataLayout, Size, TargetDataLayout, WrappingRange};
88
use rustc_codegen_ssa::MemFlags;
99
use rustc_codegen_ssa::common::{AtomicOrdering, IntPredicate, RealPredicate, TypeKind};
1010
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
@@ -829,22 +829,8 @@ impl<'ll, 'tcx, 'a> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
829829
unsafe { llvm::LLVMBuildIntToPtr(self.llbuilder, val, dest_ty, UNNAMED) }
830830
}
831831

832-
fn bitcast(&mut self, mut val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
833-
trace!("Bitcast `{:?}` to ty `{:?}`", val, dest_ty);
834-
unsafe {
835-
let ty = self.val_ty(val);
836-
let kind = llvm::LLVMRustGetTypeKind(ty);
837-
if kind == llvm::TypeKind::Pointer {
838-
let element = self.element_type(ty);
839-
let addrspace = llvm::LLVMGetPointerAddressSpace(ty);
840-
let new_ty = self.type_ptr_to_ext(element, AddressSpace::DATA);
841-
if addrspace != 0 {
842-
trace!("injecting addrspace cast for `{:?}` to `{:?}`", ty, new_ty);
843-
val = llvm::LLVMBuildAddrSpaceCast(self.llbuilder, val, new_ty, UNNAMED);
844-
}
845-
}
846-
llvm::LLVMBuildBitCast(self.llbuilder, val, dest_ty, UNNAMED)
847-
}
832+
fn bitcast(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
833+
unsafe { llvm::LLVMBuildBitCast(self.llbuilder, val, dest_ty, UNNAMED) }
848834
}
849835

850836
fn intcast(&mut self, val: &'ll Value, dest_ty: &'ll Type, is_signed: bool) -> &'ll Value {

0 commit comments

Comments
 (0)