diff options
| author | Simonas Kazlauskas <git@kazlauskas.me> | 2018-05-04 00:49:22 +0300 |
|---|---|---|
| committer | Simonas Kazlauskas <git@kazlauskas.me> | 2018-05-17 23:13:42 +0300 |
| commit | 6d5bf8b23f4e59fdc67f635a10f450dfab2f076b (patch) | |
| tree | d73787a67d3af203fc03693ff7f47c5e2ea9d406 /src/librustc_codegen_llvm | |
| parent | 680031b0164a94aaeee17a1d8c3027e6e8865a4c (diff) | |
| download | rust-6d5bf8b23f4e59fdc67f635a10f450dfab2f076b.tar.gz rust-6d5bf8b23f4e59fdc67f635a10f450dfab2f076b.zip | |
Remove the intrinsic for align_offset
Keep only the language item. This removes some indirection and makes codegen worse for debug builds, but simplifies code significantly, which is a good tradeoff to make, in my opinion. Besides, the codegen can be improved even further with some constant evaluation improvements that we expect to happen in the future.
Diffstat (limited to 'src/librustc_codegen_llvm')
| -rw-r--r-- | src/librustc_codegen_llvm/intrinsic.rs | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs index 93351651db9..cffe7f79e97 100644 --- a/src/librustc_codegen_llvm/intrinsic.rs +++ b/src/librustc_codegen_llvm/intrinsic.rs @@ -25,7 +25,6 @@ use type_of::LayoutLlvmExt; use rustc::ty::{self, Ty}; use rustc::ty::layout::{HasDataLayout, LayoutOf}; use rustc::hir; -use rustc::middle::lang_items::AlignOffsetLangItem; use syntax::ast; use syntax::symbol::Symbol; use builder::Builder; @@ -390,31 +389,6 @@ pub fn codegen_intrinsic_call<'a, 'tcx>(bx: &Builder<'a, 'tcx>, args[0].deref(bx.cx).codegen_get_discr(bx, ret_ty) } - "align_offset" => { - let (ptr, align) = (args[0].immediate(), args[1].immediate()); - let stride_of_t = bx.cx.layout_of(substs.type_at(0)).size_and_align().0.bytes(); - let stride = C_usize(bx.cx, stride_of_t); - let zero = C_null(bx.cx.isize_ty); - let max = C_int(cx.isize_ty, -1); // -1isize (wherein I cheat horribly to make !0usize) - - if stride_of_t <= 1 { - // offset = ptr as usize % align => offset = ptr as usize & (align - 1) - let modmask = bx.sub(align, C_usize(bx.cx, 1)); - let offset = bx.and(bx.ptrtoint(ptr, bx.cx.isize_ty), modmask); - let is_zero = bx.icmp(llvm::IntPredicate::IntEQ, offset, zero); - // if offset == 0 { 0 } else { if stride_of_t == 1 { align - offset } else { !0 } } - bx.select(is_zero, zero, if stride_of_t == 1 { - bx.sub(align, offset) - } else { - max - }) - } else { - let did = ::common::langcall(bx.tcx(), Some(span), "", AlignOffsetLangItem); - let instance = ty::Instance::mono(bx.tcx(), did); - let llfn = ::callee::get_fn(bx.cx, instance); - bx.call(llfn, &[ptr, align, stride], None) - } - } name if name.starts_with("simd_") => { match generic_simd_intrinsic(bx, name, callee_ty, |
