mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
intrinsics: Move the call to upcall_fail out of rust_intrinsic_cast
This commit is contained in:
parent
44aebb978c
commit
3feaecd757
@ -19,7 +19,14 @@ Function: reinterpret_cast
|
||||
|
||||
Casts the value at `src` to U. The two types must have the same length.
|
||||
*/
|
||||
unsafe fn reinterpret_cast<T, U>(src: T) -> U { ret rusti::cast(src); }
|
||||
unsafe fn reinterpret_cast<T, U>(src: T) -> U {
|
||||
let t1 = sys::get_type_desc::<T>();
|
||||
let t2 = sys::get_type_desc::<U>();
|
||||
if (*t1).size != (*t2).size {
|
||||
fail "attempt to cast values of differing sizes";
|
||||
}
|
||||
ret rusti::cast(src);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: leak
|
||||
|
@ -6,9 +6,6 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
extern "C" CDECL void
|
||||
upcall_fail(char const *expr, char const *file, size_t line);
|
||||
|
||||
extern "C" CDECL void
|
||||
port_recv(uintptr_t *dptr, rust_port *port);
|
||||
|
||||
@ -41,12 +38,8 @@ rust_intrinsic_cast(void *retptr,
|
||||
type_desc *t2,
|
||||
void *src)
|
||||
{
|
||||
if (t1->size != t2->size) {
|
||||
upcall_fail("attempt to cast values of differing sizes",
|
||||
__FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
// assert t1->size == t2->size
|
||||
// FIXME: This should be easily expressible in rust
|
||||
memmove(retptr, src, t1->size);
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,6 @@ target triple = "@CFG_TARGET_TRIPLE@"
|
||||
%"struct.hash_map<int, rust_task *>::map_entry" = type opaque
|
||||
%class.circular_buffer = type { %class.rust_kernel*, i32, i32, i32, i32, i8* }
|
||||
|
||||
@.str = private unnamed_addr constant [42 x i8] c"attempt to cast values of differing sizes\00", align 1
|
||||
@.str1 = private unnamed_addr constant [33 x i8] c"src/rt/intrinsics/intrinsics.cpp\00", align 1
|
||||
|
||||
define void @rust_intrinsic_vec_len(i32* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, %struct.rust_vec** nocapture %vp) nounwind {
|
||||
%1 = load %struct.rust_vec** %vp, align 4, !tbaa !0
|
||||
%2 = getelementptr inbounds %struct.rust_vec* %1, i32 0, i32 0
|
||||
@ -80,28 +77,13 @@ define void @rust_intrinsic_ptr_offset(i8** nocapture %retptr, i8* nocapture %en
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @rust_intrinsic_cast(i8* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) {
|
||||
define void @rust_intrinsic_cast(i8* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) nounwind {
|
||||
%1 = getelementptr inbounds %struct.type_desc* %t1, i32 0, i32 1
|
||||
%2 = load i32* %1, align 4, !tbaa !3
|
||||
%3 = getelementptr inbounds %struct.type_desc* %t2, i32 0, i32 1
|
||||
%4 = load i32* %3, align 4, !tbaa !3
|
||||
%5 = icmp eq i32 %2, %4
|
||||
br i1 %5, label %7, label %6
|
||||
|
||||
; <label>:6 ; preds = %0
|
||||
tail call void @upcall_fail(i8* getelementptr inbounds ([42 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([33 x i8]* @.str1, i32 0, i32 0), i32 46)
|
||||
br label %8
|
||||
|
||||
; <label>:7 ; preds = %0
|
||||
tail call void @llvm.memmove.p0i8.p0i8.i32(i8* %retptr, i8* %src, i32 %2, i32 1, i1 false)
|
||||
br label %8
|
||||
|
||||
; <label>:8 ; preds = %7, %6
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @upcall_fail(i8*, i8*, i32)
|
||||
|
||||
declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
|
||||
|
||||
define void @rust_intrinsic_addr_of(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* %valptr) nounwind {
|
||||
|
@ -57,9 +57,6 @@ target triple = "@CFG_TARGET_TRIPLE@"
|
||||
%"struct.hash_map<long, rust_task *>::map_entry" = type opaque
|
||||
%class.circular_buffer = type { %class.rust_kernel*, i64, i64, i64, i64, i8* }
|
||||
|
||||
@.str = private unnamed_addr constant [42 x i8] c"attempt to cast values of differing sizes\00", align 1
|
||||
@.str1 = private unnamed_addr constant [33 x i8] c"src/rt/intrinsics/intrinsics.cpp\00", align 1
|
||||
|
||||
define void @rust_intrinsic_vec_len(i64* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, %struct.rust_vec** nocapture %vp) nounwind uwtable {
|
||||
%1 = load %struct.rust_vec** %vp, align 8, !tbaa !0
|
||||
%2 = getelementptr inbounds %struct.rust_vec* %1, i64 0, i32 0
|
||||
@ -80,28 +77,13 @@ define void @rust_intrinsic_ptr_offset(i8** nocapture %retptr, i8* nocapture %en
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @rust_intrinsic_cast(i8* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) uwtable {
|
||||
define void @rust_intrinsic_cast(i8* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) nounwind uwtable {
|
||||
%1 = getelementptr inbounds %struct.type_desc* %t1, i64 0, i32 1
|
||||
%2 = load i64* %1, align 8, !tbaa !3
|
||||
%3 = getelementptr inbounds %struct.type_desc* %t2, i64 0, i32 1
|
||||
%4 = load i64* %3, align 8, !tbaa !3
|
||||
%5 = icmp eq i64 %2, %4
|
||||
br i1 %5, label %7, label %6
|
||||
|
||||
; <label>:6 ; preds = %0
|
||||
tail call void @upcall_fail(i8* getelementptr inbounds ([42 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8]* @.str1, i64 0, i64 0), i64 46)
|
||||
br label %8
|
||||
|
||||
; <label>:7 ; preds = %0
|
||||
tail call void @llvm.memmove.p0i8.p0i8.i64(i8* %retptr, i8* %src, i64 %2, i32 1, i1 false)
|
||||
br label %8
|
||||
|
||||
; <label>:8 ; preds = %7, %6
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @upcall_fail(i8*, i8*, i64)
|
||||
|
||||
declare void @llvm.memmove.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
|
||||
|
||||
define void @rust_intrinsic_addr_of(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* %valptr) nounwind uwtable {
|
||||
|
Loading…
Reference in New Issue
Block a user