Skip to content

Commit

Permalink
[AVR] Use LLVM bitcast instructions rather than pointercasts to avoid…
Browse files Browse the repository at this point in the history
… address space mismatch problems

This was suggested by @eddyb on Zulip:
https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Better.20supporting.20Harvard.20architectures/near/202043069

Bitcasts do not suffer from the same address space casting issues.
  • Loading branch information
dylanmckay committed Jul 21, 2020
1 parent 05630b0 commit a5500b0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
}

fn pointercast(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
unsafe { llvm::LLVMBuildPointerCast(self.llbuilder, val, dest_ty, UNNAMED) }
self.bitcast(val, dest_ty)
}

/* Comparisons */
Expand Down
6 changes: 0 additions & 6 deletions src/librustc_codegen_llvm/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1346,12 +1346,6 @@ extern "C" {
DestTy: &'a Type,
Name: *const c_char,
) -> &'a Value;
pub fn LLVMBuildPointerCast(
B: &Builder<'a>,
Val: &'a Value,
DestTy: &'a Type,
Name: *const c_char,
) -> &'a Value;
pub fn LLVMRustBuildIntCast(
B: &Builder<'a>,
Val: &'a Value,
Expand Down

0 comments on commit a5500b0

Please sign in to comment.