about summary refs log tree commit diff
path: root/src/librustc_trans/intrinsic.rs
diff options
context:
space:
mode:
authorPaul Lietar <paul@lietar.net>2017-09-03 19:53:58 +0100
committerPaul LiƩtar <lietar@google.com>2017-10-27 23:01:34 +0200
commit77f7e85d7f4ebcc1a291edae95a3747b0e54d7fa (patch)
tree3a10519372a957925738544a8a7cb651139e7fb5 /src/librustc_trans/intrinsic.rs
parentbed9a85c40f98ab8f4445b66d285d4108de9ad21 (diff)
downloadrust-77f7e85d7f4ebcc1a291edae95a3747b0e54d7fa.tar.gz
rust-77f7e85d7f4ebcc1a291edae95a3747b0e54d7fa.zip
Implement RFC 1861: Extern types
Diffstat (limited to 'src/librustc_trans/intrinsic.rs')
-rw-r--r--src/librustc_trans/intrinsic.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/librustc_trans/intrinsic.rs b/src/librustc_trans/intrinsic.rs
index f78d80a197c..e8023917568 100644
--- a/src/librustc_trans/intrinsic.rs
+++ b/src/librustc_trans/intrinsic.rs
@@ -139,13 +139,15 @@ pub fn trans_intrinsic_call<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
         }
         "size_of_val" => {
             let tp_ty = substs.type_at(0);
-            if !bcx.ccx.shared().type_is_sized(tp_ty) {
+            if bcx.ccx.shared().type_is_sized(tp_ty) {
+                let lltp_ty = type_of::type_of(ccx, tp_ty);
+                C_usize(ccx, machine::llsize_of_alloc(ccx, lltp_ty))
+            } else if bcx.ccx.shared().type_has_metadata(tp_ty) {
                 let (llsize, _) =
                     glue::size_and_align_of_dst(bcx, tp_ty, llargs[1]);
                 llsize
             } else {
-                let lltp_ty = type_of::type_of(ccx, tp_ty);
-                C_usize(ccx, machine::llsize_of_alloc(ccx, lltp_ty))
+                C_usize(ccx, 0u64)
             }
         }
         "min_align_of" => {
@@ -154,12 +156,14 @@ pub fn trans_intrinsic_call<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
         }
         "min_align_of_val" => {
             let tp_ty = substs.type_at(0);
-            if !bcx.ccx.shared().type_is_sized(tp_ty) {
+            if bcx.ccx.shared().type_is_sized(tp_ty) {
+                C_usize(ccx, ccx.align_of(tp_ty) as u64)
+            } else if bcx.ccx.shared().type_has_metadata(tp_ty) {
                 let (_, llalign) =
                     glue::size_and_align_of_dst(bcx, tp_ty, llargs[1]);
                 llalign
             } else {
-                C_usize(ccx, ccx.align_of(tp_ty) as u64)
+                C_usize(ccx, 1u64)
             }
         }
         "pref_align_of" => {