rust
rust copied to clipboard
could not statically determine size of realloc
#![feature(bench_black_box)]
use autodiff::autodiff;
use std::ptr;
#[autodiff(sin_vec, Reverse, Active)]
fn cos_vec(#[dup] x: &Vec<f32>) -> f32 {
// uses enum internally and breaks
let res = x.into_iter().collect::<Vec<&f32>>();
*res[0]
}
fn main() {
let x = vec![1.0, 1.0, 1.0];
let mut d_x = vec![0.0; 3];
sin_vec(&x, &mut d_x, 1.0);
dbg!(&d_x, &x);
}
updating analysis of val: %37 = tail call noundef ptr @__rust_alloc(i64 noundef %2, i64 noundef %1) #105 current: {[-1]:Pointer} new {[-1]:Pointer} from %37 = tail call noundef ptr @__rust_alloc(i64 noundef %2, i64 noundef %1) #105 Changed=0 legal=1
analyzing function preprocess___rust_realloc
+ knowndata: ptr %0 : {} - {}
+ knowndata: i64 %1 : {} - {}
+ knowndata: i64 %2 : {} - {}
+ knowndata: i64 %3 : {} - {}
+ retdata: {[-1]:Pointer}
updating analysis of val: ptr %0 current: {} new {} from ptr %0 Changed=0 legal=1
updating analysis of val: i64 %1 current: {} new {} from i64 %1 Changed=0 legal=1
updating analysis of val: i64 %2 current: {} new {} from i64 %2 Changed=0 legal=1
updating analysis of val: i64 %3 current: {} new {} from i64 %3 Changed=0 legal=1
updating analysis of val: ptr %0 current: {} new {} from ptr %0 Changed=0 legal=1
updating analysis of val: i64 %1 current: {} new {} from i64 %1 Changed=0 legal=1
updating analysis of val: i64 %2 current: {} new {} from i64 %2 Changed=0 legal=1
updating analysis of val: i64 %3 current: {} new {} from i64 %3 Changed=0 legal=1
updating analysis of val: %5 = tail call ptr @__rdl_realloc(ptr %0, i64 %1, i64 %2, i64 %3) #105 current: {} new {[-1]:Pointer} from %5 = tail call ptr @__rdl_realloc(ptr %0, i64 %1, i64 %2, i64 %3) #105 Changed=1 legal=1
updating analysis of val: %5 = tail call ptr @__rdl_realloc(ptr %0, i64 %1, i64 %2, i64 %3) #105 current: {[-1]:Pointer} new {[-1]:Pointer} from %5 = tail call ptr @__rdl_realloc(ptr %0, i64 %1, i64 %2, i64 %3) #105 Changed=0 legal=1
starting IPO of %5 = tail call ptr @__rdl_realloc(ptr %0, i64 %1, i64 %2, i64 %3) #105
ending IPO of %5 = tail call ptr @__rdl_realloc(ptr %0, i64 %1, i64 %2, i64 %3) #105
updating ptr %0 = {} via IPO of %5 = tail call ptr @__rdl_realloc(ptr %0, i64 %1, i64 %2, i64 %3) #105 arg ptr %0
updating analysis of val: ptr %0 current: {} new {} from %5 = tail call ptr @__rdl_realloc(ptr %0, i64 %1, i64 %2, i64 %3) #105 Changed=0 legal=1
updating i64 %1 = {} via IPO of %5 = tail call ptr @__rdl_realloc(ptr %0, i64 %1, i64 %2, i64 %3) #105 arg i64 %1
updating analysis of val: i64 %1 current: {} new {} from %5 = tail call ptr @__rdl_realloc(ptr %0, i64 %1, i64 %2, i64 %3) #105 Changed=0 legal=1
updating i64 %2 = {[-1]:Integer} via IPO of %5 = tail call ptr @__rdl_realloc(ptr %0, i64 %1, i64 %2, i64 %3) #105 arg i64 %2
updating analysis of val: i64 %2 current: {} new {[-1]:Integer} from %5 = tail call ptr @__rdl_realloc(ptr %0, i64 %1, i64 %2, i64 %3) #105 Changed=1 legal=1
updating i64 %3 = {[-1]:Integer} via IPO of %5 = tail call ptr @__rdl_realloc(ptr %0, i64 %1, i64 %2, i64 %3) #105 arg i64 %3
updating analysis of val: i64 %3 current: {} new {[-1]:Integer} from %5 = tail call ptr @__rdl_realloc(ptr %0, i64 %1, i64 %2, i64 %3) #105 Changed=1 legal=1
updating analysis of val: %5 = tail call ptr @__rdl_realloc(ptr %0, i64 %1, i64 %2, i64 %3) #105 current: {[-1]:Pointer} new {[-1]:Pointer} from %5 = tail call ptr @__rdl_realloc(ptr %0, i64 %1, i64 %2, i64 %3) #105 Changed=0 legal=1
error: <unknown>:0:0: in function preprocess___rdl_realloc ptr (ptr, i64, i64, i64): Enzyme: could not statically determine size of realloc %23 = tail call noundef ptr @realloc(ptr noundef %0, i64 noundef %3) #107 - because of - ptr %0
after simplification :
; Function Attrs: mustprogress noinline nonlazybind sanitize_hwaddress willreturn uwtable
define internal noundef float @preprocess__ZN11broken_iter7cos_vec17hbc9894bdb3f615dbE(ptr noalias noundef readonly align 8 dereferenceable(24) %0) unnamed_addr #99 personality ptr @rust_eh_personality {
%2 = alloca %3, align 8
call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #100
%3 = tail call { ptr, ptr } @"_ZN94_$LT$$RF$alloc..vec..Vec$LT$T$C$A$GT$$u20$as$u20$core..iter..traits..collect..IntoIterator$GT$9into_iter17h605c318a31fd00daE"(ptr noalias noundef nonnull readonly align 8 dereferenceable(24) %0) #100
%4 = extractvalue { ptr, ptr } %3, 0
%5 = extractvalue { ptr, ptr } %3, 1
call void @"_ZN98_$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$alloc..vec..spec_from_iter..SpecFromIter$LT$T$C$I$GT$$GT$9from_iter17h884dc8043d6d7f00E"(ptr noalias nocapture noundef nonnull sret(%3) dereferenceable(24) %2, ptr noundef nonnull %4, ptr noundef %5) #100
%6 = getelementptr inbounds i8, ptr %2, i64 16
%7 = load i64, ptr %6, align 8, !noundef !7
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10, !prof !8
9: ; preds = %1
call void @_ZN4core9panicking18panic_bounds_check17h813e7c5548f0e1edE(i64 noundef 0, i64 noundef 0, ptr noalias noundef nonnull readonly align 8 dereferenceable(24) @anon.07363652236cd270cb5813abe9650064.6) #101
unreachable
10: ; preds = %1
%11 = load ptr, ptr %2, align 8, !nonnull !7, !noundef !7
%12 = load ptr, ptr %11, align 8, !nonnull !7, !align !9, !noundef !7
%13 = load float, ptr %12, align 4, !noundef !7
call void @"_ZN70_$LT$alloc..vec..Vec$LT$T$C$A$GT$$u20$as$u20$core..ops..drop..Drop$GT$4drop17h8b22aa3a15ee3340E"(ptr noalias noundef nonnull align 8 dereferenceable(24) %2) #100
call void @"_ZN77_$LT$alloc..raw_vec..RawVec$LT$T$C$A$GT$$u20$as$u20$core..ops..drop..Drop$GT$4drop17h2cd9e5f06b089a64E"(ptr noalias noundef nonnull align 8 dereferenceable(16) %2) #100
call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #100
ret float %13
}
after simplification :
; Function Attrs: mustprogress nonlazybind sanitize_hwaddress willreturn uwtable
define internal void @"preprocess__ZN98_$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$alloc..vec..spec_from_iter..SpecFromIter$LT$T$C$I$GT$$GT$9from_iter17h884dc8043d6d7f00E"(ptr noalias nocapture noundef writeonly sret(%2) dereferenceable(24) %0, ptr noundef nonnull %1, ptr noundef %2) unnamed_addr #101 personality ptr @rust_eh_personality {
%4 = tail call noalias nonnull dereferenceable(24) dereferenceable_or_null(24) ptr @malloc(i64 24), !enzyme_fromstack !11
call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #102, !noalias !1139
%5 = ptrtoint ptr %2 to i64
%6 = ptrtoint ptr %1 to i64
%7 = sub nuw i64 %5, %6
%8 = lshr exact i64 %7, 2
%9 = tail call { ptr, i64 } @"_ZN5alloc7raw_vec19RawVec$LT$T$C$A$GT$11allocate_in17h65877e3a6a257a6eE"(i64 noundef %8, i1 noundef zeroext false) #102, !noalias !1139
%10 = extractvalue { ptr, i64 } %9, 0
%11 = extractvalue { ptr, i64 } %9, 1
store ptr %10, ptr %4, align 8, !noalias !1139
%12 = getelementptr inbounds { ptr, i64 }, ptr %4, i64 0, i32 1
store i64 %11, ptr %12, align 8, !noalias !1139
%13 = getelementptr inbounds %2, ptr %4, i64 0, i32 1
store i64 0, ptr %13, align 8, !noalias !1139
%14 = icmp ult i64 %11, %8
br i1 %14, label %15, label %16
15: ; preds = %3
call void @"_ZN5alloc7raw_vec19RawVec$LT$T$C$A$GT$7reserve21do_reserve_and_handle17h41b5dec7cfbaea49E"(ptr noalias noundef nonnull align 8 dereferenceable(16) %4, i64 noundef 0, i64 noundef %8) #102
br label %16
16: ; preds = %15, %3
%17 = load ptr, ptr %4, align 8, !alias.scope !1142, !noalias !1139, !nonnull !7, !noundef !7
%18 = load i64, ptr %13, align 8, !alias.scope !1142, !noalias !1139, !noundef !7
%19 = icmp ne ptr %2, null
call void @llvm.assume(i1 %19) #102
%20 = icmp eq ptr %1, %2
br i1 %20, label %33, label %21
21: ; preds = %16
br label %22
22: ; preds = %21, %22
%23 = phi i64 [ 0, %21 ], [ %25, %22 ]
%24 = shl i64 %23, 2
%25 = add nuw nsw i64 %23, 1
%26 = getelementptr i8, ptr %1, i64 %24
%27 = add i64 %18, %23
%28 = getelementptr inbounds float, ptr %26, i64 1
%29 = getelementptr inbounds ptr, ptr %17, i64 %27
store ptr %26, ptr %29, align 8, !noalias !1147
%30 = add i64 %27, 1
%31 = icmp eq ptr %28, %2
br i1 %31, label %32, label %22
32: ; preds = %22
br label %33
33: ; preds = %32, %16
%34 = phi i64 [ %18, %16 ], [ %30, %32 ]
store i64 %34, ptr %13, align 8, !alias.scope !1142, !noalias !1153
call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %4, i64 24, i1 false) #102
call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #102, !noalias !1139
ret void
}
after simplification :
; Function Attrs: mustprogress nonlazybind sanitize_hwaddress willreturn uwtable
define internal { ptr, i64 } @"preprocess__ZN5alloc7raw_vec19RawVec$LT$T$C$A$GT$11allocate_in17h65877e3a6a257a6eE"(i64 noundef %0, i1 noundef zeroext %1) unnamed_addr #101 personality ptr @rust_eh_personality {
%3 = icmp eq i64 %0, 0
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = icmp ugt i64 %0, 1152921504606846975
%6 = shl i64 %0, 3
%7 = select i1 %5, i64 0, i64 8
br i1 %5, label %12, label %13
8: ; preds = %25, %2
%9 = phi ptr [ inttoptr (i64 8 to ptr), %2 ], [ %26, %25 ]
%10 = insertvalue { ptr, i64 } poison, ptr %9, 0
%11 = insertvalue { ptr, i64 } %10, i64 %0, 1
ret { ptr, i64 } %11
12: ; preds = %4
tail call void @_ZN5alloc7raw_vec17capacity_overflow17h392c7a84dec5c99dE() #102
unreachable
13: ; preds = %4
%14 = icmp eq i64 %6, 0
br i1 %1, label %20, label %15
15: ; preds = %13
br i1 %14, label %16, label %18
16: ; preds = %15
%17 = inttoptr i64 %7 to ptr
br label %25
18: ; preds = %15
%19 = tail call noundef ptr @__rust_alloc(i64 noundef %6, i64 noundef %7) #103
br label %25
20: ; preds = %13
br i1 %14, label %21, label %23
21: ; preds = %20
%22 = inttoptr i64 %7 to ptr
br label %25
23: ; preds = %20
%24 = tail call noundef ptr @__rust_alloc_zeroed(i64 noundef %6, i64 noundef %7) #103
br label %25
25: ; preds = %23, %21, %18, %16
%26 = phi ptr [ %17, %16 ], [ %19, %18 ], [ %22, %21 ], [ %24, %23 ]
%27 = icmp eq ptr %26, null
br i1 %27, label %28, label %8
28: ; preds = %25
tail call void @_ZN5alloc5alloc18handle_alloc_error17h72f1ff06b14774ccE(i64 noundef %7, i64 noundef %6) #102
unreachable
}
; Function Attrs: mustprogress nonlazybind sanitize_hwaddress willreturn uwtable
define internal { { ptr, ptr, ptr, ptr }, { ptr, i64 }, { ptr, i64 } } @"augmented__ZN5alloc7raw_vec19RawVec$LT$T$C$A$GT$11allocate_in17h65877e3a6a257a6eE"(i64 noundef %0, i1 noundef zeroext %1) unnamed_addr #101 personality ptr @rust_eh_personality {
%3 = icmp eq i64 %0, 0
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = icmp ugt i64 %0, 1152921504606846975
%6 = shl i64 %0, 3
%7 = select i1 %5, i64 0, i64 8
br i1 %5, label %32, label %33
8: ; preds = %65, %2
%9 = phi ptr [ undef, %2 ], [ %66, %65 ]
%10 = phi ptr [ undef, %2 ], [ %67, %65 ]
%11 = phi ptr [ undef, %2 ], [ %68, %65 ]
%12 = phi ptr [ undef, %2 ], [ %69, %65 ]
%13 = phi ptr [ inttoptr (i64 8 to ptr), %2 ], [ %70, %65 ]
%14 = phi ptr [ inttoptr (i64 8 to ptr), %2 ], [ %71, %65 ]
%15 = insertvalue { ptr, i64 } zeroinitializer, ptr %13, 0
%16 = insertvalue { ptr, i64 } poison, ptr %14, 0
%17 = insertvalue { ptr, i64 } %15, i64 %0, 1
%18 = insertvalue { ptr, i64 } %16, i64 %0, 1
%19 = insertvalue { ptr, { ptr, i64 }, { ptr, i64 } } undef, { ptr, i64 } %18, 1
%20 = extractvalue { ptr, i64 } %18, 0
%21 = extractvalue { ptr, i64 } %18, 1
%22 = extractvalue { ptr, i64 } %17, 0
%23 = extractvalue { ptr, i64 } %17, 1
%24 = insertvalue { { ptr, ptr, ptr, ptr }, { ptr, i64 }, { ptr, i64 } } poison, ptr %12, 0, 0
%25 = insertvalue { { ptr, ptr, ptr, ptr }, { ptr, i64 }, { ptr, i64 } } %24, ptr %11, 0, 1
%26 = insertvalue { { ptr, ptr, ptr, ptr }, { ptr, i64 }, { ptr, i64 } } %25, ptr %10, 0, 2
%27 = insertvalue { { ptr, ptr, ptr, ptr }, { ptr, i64 }, { ptr, i64 } } %26, ptr %9, 0, 3
%28 = insertvalue { { ptr, ptr, ptr, ptr }, { ptr, i64 }, { ptr, i64 } } %27, ptr %20, 1, 0
%29 = insertvalue { { ptr, ptr, ptr, ptr }, { ptr, i64 }, { ptr, i64 } } %28, i64 %21, 1, 1
%30 = insertvalue { { ptr, ptr, ptr, ptr }, { ptr, i64 }, { ptr, i64 } } %29, ptr %22, 2, 0
%31 = insertvalue { { ptr, ptr, ptr, ptr }, { ptr, i64 }, { ptr, i64 } } %30, i64 %23, 2, 1
ret { { ptr, ptr, ptr, ptr }, { ptr, i64 }, { ptr, i64 } } %31
32: ; preds = %4
tail call void @_ZN5alloc7raw_vec17capacity_overflow17h392c7a84dec5c99dE() #102
unreachable
33: ; preds = %4
%34 = icmp eq i64 %6, 0
br i1 %1, label %50, label %35
35: ; preds = %33
br i1 %34, label %36, label %47
36: ; preds = %35
%37 = inttoptr i64 8 to ptr
%38 = alloca ptr, align 8
store ptr %37, ptr %38, align 8
store i8 0, ptr %38, align 1
%39 = getelementptr inbounds [8 x i8], ptr %38, i32 0, i32 1
store i8 0, ptr %39, align 1
%40 = getelementptr inbounds [8 x i8], ptr %38, i32 0, i32 2
store i8 0, ptr %40, align 1
%41 = getelementptr inbounds [8 x i8], ptr %38, i32 0, i32 3
store i8 0, ptr %41, align 1
%42 = getelementptr inbounds [8 x i8], ptr %38, i32 0, i32 4
store i8 0, ptr %42, align 1
%43 = getelementptr inbounds [8 x i8], ptr %38, i32 0, i32 5
store i8 0, ptr %43, align 1
%44 = getelementptr inbounds [8 x i8], ptr %38, i32 0, i32 6
store i8 0, ptr %44, align 1
%45 = getelementptr inbounds [8 x i8], ptr %38, i32 0, i32 7
store i8 0, ptr %45, align 1
%46 = load ptr, ptr %38, align 8
br label %65
47: ; preds = %35
%48 = tail call noalias noundef nonnull ptr @__rust_alloc(i64 noundef %6, i64 noundef 8) #103
call void @llvm.memset.p0.i64(ptr nonnull %48, i8 0, i64 %6, i1 false)
%49 = tail call noundef ptr @__rust_alloc(i64 noundef %6, i64 noundef 8) #103
br label %65
50: ; preds = %33
br i1 %34, label %51, label %62
51: ; preds = %50
%52 = inttoptr i64 8 to ptr
%53 = alloca ptr, align 8
store ptr %52, ptr %53, align 8
store i8 0, ptr %53, align 1
%54 = getelementptr inbounds [8 x i8], ptr %53, i32 0, i32 1
store i8 0, ptr %54, align 1
%55 = getelementptr inbounds [8 x i8], ptr %53, i32 0, i32 2
store i8 0, ptr %55, align 1
%56 = getelementptr inbounds [8 x i8], ptr %53, i32 0, i32 3
store i8 0, ptr %56, align 1
%57 = getelementptr inbounds [8 x i8], ptr %53, i32 0, i32 4
store i8 0, ptr %57, align 1
%58 = getelementptr inbounds [8 x i8], ptr %53, i32 0, i32 5
store i8 0, ptr %58, align 1
%59 = getelementptr inbounds [8 x i8], ptr %53, i32 0, i32 6
store i8 0, ptr %59, align 1
%60 = getelementptr inbounds [8 x i8], ptr %53, i32 0, i32 7
store i8 0, ptr %60, align 1
%61 = load ptr, ptr %53, align 8
br label %65
62: ; preds = %50
%63 = tail call noalias noundef nonnull ptr @__rust_alloc_zeroed(i64 noundef %6, i64 noundef 8) #103
%64 = tail call noundef ptr @__rust_alloc_zeroed(i64 noundef %6, i64 noundef 8) #103
br label %65
65: ; preds = %62, %51, %47, %36
%66 = phi ptr [ undef, %51 ], [ %64, %62 ], [ undef, %36 ], [ undef, %47 ]
%67 = phi ptr [ undef, %51 ], [ %63, %62 ], [ undef, %36 ], [ undef, %47 ]
%68 = phi ptr [ undef, %51 ], [ undef, %62 ], [ undef, %36 ], [ %49, %47 ]
%69 = phi ptr [ undef, %51 ], [ undef, %62 ], [ undef, %36 ], [ %48, %47 ]
%70 = phi ptr [ %46, %36 ], [ %48, %47 ], [ %61, %51 ], [ %63, %62 ]
%71 = phi ptr [ %37, %36 ], [ %49, %47 ], [ %52, %51 ], [ %64, %62 ]
%72 = icmp eq ptr %71, null
br i1 %72, label %73, label %8
73: ; preds = %65
tail call void @_ZN5alloc5alloc18handle_alloc_error17h72f1ff06b14774ccE(i64 noundef 8, i64 noundef %6) #102
unreachable
}
after simplification :
; Function Attrs: cold mustprogress nonlazybind sanitize_hwaddress willreturn uwtable
define internal void @"preprocess__ZN5alloc7raw_vec19RawVec$LT$T$C$A$GT$7reserve21do_reserve_and_handle17h41b5dec7cfbaea49E"(ptr noalias nocapture noundef align 8 dereferenceable(16) %0, i64 noundef %1, i64 noundef %2) unnamed_addr #102 personality ptr @rust_eh_personality {
%4 = tail call noalias nonnull dereferenceable(24) dereferenceable_or_null(24) ptr @malloc(i64 24), !enzyme_fromstack !11
%5 = tail call noalias nonnull dereferenceable(24) dereferenceable_or_null(24) ptr @malloc(i64 24), !enzyme_fromstack !11
tail call void @llvm.experimental.noalias.scope.decl(metadata !1157) #103
%6 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %1, i64 %2) #103
%7 = extractvalue { i64, i1 } %6, 1
br i1 %7, label %38, label %8
8: ; preds = %3
%9 = extractvalue { i64, i1 } %6, 0
%10 = getelementptr { ptr, i64 }, ptr %0, i64 0, i32 1
%11 = load i64, ptr %10, align 8, !alias.scope !1157
%12 = shl i64 %11, 1
%13 = tail call i64 @llvm.umax.i64(i64 %12, i64 %9) #103
%14 = tail call i64 @llvm.umax.i64(i64 %13, i64 4) #103
%15 = icmp ugt i64 %14, 1152921504606846975
%16 = shl i64 %14, 3
%17 = select i1 %15, i64 0, i64 8
call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #103, !noalias !1157
call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #103, !noalias !1157
%18 = icmp eq i64 %11, 0
br i1 %18, label %24, label %19
19: ; preds = %8
%20 = load ptr, ptr %0, align 8, !alias.scope !1157, !nonnull !7
%21 = shl nuw i64 %11, 3
store ptr %20, ptr %4, align 8, !alias.scope !1160, !noalias !1157
%22 = getelementptr inbounds i8, ptr %4, i64 8
store i64 8, ptr %22, align 8, !alias.scope !1160, !noalias !1157
%23 = getelementptr inbounds i8, ptr %4, i64 16
store i64 %21, ptr %23, align 8, !alias.scope !1160, !noalias !1157
br label %26
24: ; preds = %8
%25 = getelementptr inbounds %10, ptr %4, i64 0, i32 1
store i64 0, ptr %25, align 8, !alias.scope !1160, !noalias !1157
br label %26
26: ; preds = %24, %19
call fastcc void @_ZN5alloc7raw_vec11finish_grow17hd7ff164a14ffa34aE(ptr noalias nocapture noundef nonnull dereferenceable(24) %5, i64 noundef %17, i64 %16, ptr noalias nocapture noundef nonnull readonly dereferenceable(24) %4) #103, !noalias !1157
call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #103, !noalias !1157
%27 = load i64, ptr %5, align 8, !range !76, !noalias !1157, !noundef !7
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = getelementptr inbounds %12, ptr %5, i64 0, i32 1
%31 = load ptr, ptr %30, align 8, !noalias !1157, !nonnull !7, !noundef !7
call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #103, !noalias !1157
store ptr %31, ptr %0, align 8, !alias.scope !1163
store i64 %14, ptr %10, align 8, !alias.scope !1163
ret void
32: ; preds = %26
%33 = getelementptr inbounds %11, ptr %5, i64 0, i32 1
%34 = load i64, ptr %33, align 8, !range !66, !noalias !1157, !noundef !7
%35 = getelementptr inbounds %11, ptr %5, i64 0, i32 1, i32 1
%36 = load i64, ptr %35, align 8, !noalias !1157
call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #103, !noalias !1157
%37 = icmp eq i64 %34, 0
br i1 %37, label %38, label %39
38: ; preds = %32, %3
tail call void @_ZN5alloc7raw_vec17capacity_overflow17h392c7a84dec5c99dE() #104
unreachable
39: ; preds = %32
tail call void @_ZN5alloc5alloc18handle_alloc_error17h72f1ff06b14774ccE(i64 noundef %34, i64 noundef %36) #104
unreachable
}
after simplification :
; Function Attrs: mustprogress noinline nounwind nonlazybind sanitize_hwaddress willreturn uwtable
define internal fastcc void @preprocess__ZN5alloc7raw_vec11finish_grow17hd7ff164a14ffa34aE(ptr noalias nocapture noundef writeonly dereferenceable(24) %0, i64 noundef %1, i64 %2, ptr noalias nocapture noundef readonly dereferenceable(24) %3) unnamed_addr #103 {
%5 = icmp eq i64 %1, 0
br i1 %5, label %10, label %6
6: ; preds = %4
%7 = getelementptr inbounds %10, ptr %3, i64 0, i32 1
%8 = load i64, ptr %7, align 8, !range !66, !noundef !7
%9 = icmp eq i64 %8, 0
br i1 %9, label %32, label %16
10: ; preds = %4
%11 = getelementptr inbounds %11, ptr %0, i64 0, i32 1
store i64 0, ptr %11, align 8
%12 = getelementptr inbounds %11, ptr %0, i64 0, i32 1, i32 1
br label %13
13: ; preds = %44, %41, %10
%14 = phi ptr [ %46, %44 ], [ %43, %41 ], [ %12, %10 ]
%15 = phi i64 [ 1, %44 ], [ 0, %41 ], [ 1, %10 ]
store i64 %2, ptr %14, align 8
store i64 %15, ptr %0, align 8
ret void
16: ; preds = %6
%17 = load ptr, ptr %3, align 8, !nonnull !7, !noundef !7
%18 = load i64, ptr %7, align 8, !range !1166, !noundef !7
%19 = getelementptr inbounds { ptr, { i64, i64 } }, ptr %3, i64 0, i32 1, i32 1
%20 = load i64, ptr %19, align 8, !noundef !7
%21 = icmp eq i64 %18, %1
tail call void @llvm.assume(i1 %21) #104
%22 = icmp eq i64 %20, 0
br i1 %22, label %23, label %29
23: ; preds = %16
%24 = icmp eq i64 %2, 0
br i1 %24, label %25, label %27
25: ; preds = %23
%26 = inttoptr i64 %1 to ptr
br label %38
27: ; preds = %23
%28 = tail call noundef ptr @__rust_alloc(i64 noundef %2, i64 noundef %1) #105
br label %38
29: ; preds = %16
%30 = icmp ule i64 %20, %2
tail call void @llvm.assume(i1 %30) #104
%31 = tail call noundef ptr @__rust_realloc(ptr noundef nonnull %17, i64 noundef %20, i64 noundef %1, i64 noundef %2) #105
br label %38
32: ; preds = %6
%33 = icmp eq i64 %2, 0
br i1 %33, label %34, label %36
34: ; preds = %32
%35 = inttoptr i64 %1 to ptr
br label %38
36: ; preds = %32
%37 = tail call noundef ptr @__rust_alloc(i64 noundef %2, i64 noundef %1) #105
br label %38
38: ; preds = %36, %34, %29, %27, %25
%39 = phi ptr [ %31, %29 ], [ %26, %25 ], [ %28, %27 ], [ %35, %34 ], [ %37, %36 ]
%40 = icmp eq ptr %39, null
br i1 %40, label %44, label %41
41: ; preds = %38
%42 = getelementptr inbounds %12, ptr %0, i64 0, i32 1
store ptr %39, ptr %42, align 8, !alias.scope !1167
%43 = getelementptr inbounds %12, ptr %0, i64 0, i32 1, i32 1
br label %13
44: ; preds = %38
%45 = getelementptr inbounds %11, ptr %0, i64 0, i32 1
store i64 %1, ptr %45, align 8, !alias.scope !1167
%46 = getelementptr inbounds %11, ptr %0, i64 0, i32 1, i32 1
br label %13
}
after simplification :
; Function Attrs: mustprogress sanitize_hwaddress willreturn uwtable
define internal ptr @preprocess___rust_realloc(ptr %0, i64 %1, i64 %2, i64 %3) #104 {
%5 = tail call ptr @__rdl_realloc(ptr %0, i64 %1, i64 %2, i64 %3) #105
ret ptr %5
}
error: <unknown>:0:0: in function preprocess___rdl_realloc ptr (ptr, i64, i64, i64): Enzyme: could not statically determine size of realloc %23 = tail call noundef ptr @realloc(ptr noundef %0, i64 noundef %3) #107 - because of - ptr %0
The answer here is to have a rule for vector grow
Getting Rules to work was high on my list anyway, let's chat about a design once we fixed blas?
lol, this regressed from one bug to another. But at least this one should be easy to fix, will make a reproducer after the deadline.
cannot handle (augmented) unknown intrinsic
%6 = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %1, i64 %2) #118, !dbg !490