Skip to content

Instantly share code, notes, and snippets.

@TimNN
Last active January 10, 2023 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TimNN/e9a762026083ff265bdccbbcb34be956 to your computer and use it in GitHub Desktop.
Save TimNN/e9a762026083ff265bdccbbcb34be956 to your computer and use it in GitHub Desktop.
Rust Codegen Regression
; ModuleID = 'small.ll'
source_filename = "small.ll"
; `@good` and `@bad` are identical except for how `%tmp11` is computed.
; `@good` is constant-folded, `@bad` is not (using `opt -O3`).
; Note that this only demonstrates how `@llvm.usub.sat.i64` isn't optimized.
; It does not show the optimization that originally added `@llvm.usub.sat.i64`.
define i64 @bad() unnamed_addr {
bb:
br label %bb4
bb1: ; preds = %bb7
%tmp = phi i64 [ %tmp12, %bb7 ]
%tmp2 = add nuw nsw i64 %tmp6, 1
%tmp3 = icmp eq i64 %tmp2, 100000
br i1 %tmp3, label %bb13, label %bb4
bb4: ; preds = %bb1, %bb
%tmp5 = phi i64 [ 0, %bb ], [ %tmp, %bb1 ]
%tmp6 = phi i64 [ 0, %bb ], [ %tmp2, %bb1 ]
br label %bb7
bb7: ; preds = %bb7, %bb4
%tmp8 = phi i64 [ %tmp5, %bb4 ], [ %tmp12, %bb7 ]
%tmp9 = phi i64 [ 100000, %bb4 ], [ %tmp11, %bb7 ]
%tmp10 = icmp eq i64 %tmp9, 0
%tmp11 = tail call i64 @llvm.usub.sat.i64(i64 %tmp9, i64 1)
%tmp12 = add i64 %tmp9, %tmp8
br i1 %tmp10, label %bb1, label %bb7
bb13: ; preds = %bb1
%tmp14 = phi i64 [ %tmp, %bb1 ]
ret i64 %tmp14
}
define i64 @good() unnamed_addr {
bb:
br label %bb4
bb1: ; preds = %bb7
%tmp = phi i64 [ %tmp12, %bb7 ]
%tmp2 = add nuw nsw i64 %tmp6, 1
%tmp3 = icmp eq i64 %tmp2, 100000
br i1 %tmp3, label %bb13, label %bb4
bb4: ; preds = %bb1, %bb
%tmp5 = phi i64 [ 0, %bb ], [ %tmp, %bb1 ]
%tmp6 = phi i64 [ 0, %bb ], [ %tmp2, %bb1 ]
br label %bb7
bb7: ; preds = %bb7, %bb4
%tmp8 = phi i64 [ %tmp5, %bb4 ], [ %tmp12, %bb7 ]
%tmp9 = phi i64 [ 100000, %bb4 ], [ %tmp11, %bb7 ]
%tmp10 = icmp eq i64 %tmp9, 0
%tmp11 = add i64 %tmp9, -1
%tmp12 = add i64 %tmp9, %tmp8
br i1 %tmp10, label %bb1, label %bb7
bb13: ; preds = %bb1
%tmp14 = phi i64 [ %tmp, %bb1 ]
ret i64 %tmp14
}
declare i64 @llvm.usub.sat.i64(i64, i64)
; ModuleID = 'issue_45222.2810b9bc-cgu.0'
; Generated from https://github.com/rust-lang/rust/blob/master/src/test/codegen/issue-45222.rs
source_filename = "issue_45222.2810b9bc-cgu.0"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%"core::ops::range::RangeInclusive<u64>" = type { i64, i64, i8, [7 x i8] }
%"core::iter::adapters::rev::Rev<core::ops::range::RangeInclusive<u64>>" = type { %"core::ops::range::RangeInclusive<u64>" }
@alloc26 = private unnamed_addr constant <{ [57 x i8] }> <{ [57 x i8] c"/home/logic/Projects/rustc/ll/library/core/src/ptr/mod.rs" }>, align 1
@alloc27 = private unnamed_addr constant <{ ptr, [16 x i8] }> <{ ptr @alloc26, [16 x i8] c"9\00\00\00\00\00\00\00\86\04\00\00\0D\00\00\00" }>, align 8
; <core::ops::range::RangeInclusive<T> as core::iter::range::RangeInclusiveIteratorImpl>::spec_next_back
; Function Attrs: inlinehint nonlazybind uwtable
define internal { i64, i64 } @"_ZN107_$LT$core..ops..range..RangeInclusive$LT$T$GT$$u20$as$u20$core..iter..range..RangeInclusiveIteratorImpl$GT$14spec_next_back17h87d30d713fef30d5E"(ptr noalias noundef align 8 dereferenceable(24) %self) unnamed_addr #0 {
start:
%_7 = alloca i64, align 8
%0 = alloca { i64, i64 }, align 8
; call core::ops::range::RangeInclusive<Idx>::is_empty
%_2 = call noundef zeroext i1 @"_ZN4core3ops5range25RangeInclusive$LT$Idx$GT$8is_empty17h34912468b073e4b3E"(ptr noalias noundef readonly align 8 dereferenceable(24) %self)
br i1 %_2, label %bb2, label %bb3
bb3: ; preds = %start
%_6 = getelementptr inbounds %"core::ops::range::RangeInclusive<u64>", ptr %self, i32 0, i32 1
; call core::cmp::impls::<impl core::cmp::PartialOrd for u64>::lt
%is_iterating = call noundef zeroext i1 @"_ZN4core3cmp5impls55_$LT$impl$u20$core..cmp..PartialOrd$u20$for$u20$u64$GT$2lt17h3ff66d7102accf3fE"(ptr noalias noundef readonly align 8 dereferenceable(8) %self, ptr noalias noundef readonly align 8 dereferenceable(8) %_6)
call void @llvm.lifetime.start.p0(i64 8, ptr %_7)
br i1 %is_iterating, label %bb5, label %bb9
bb2: ; preds = %start
store i64 0, ptr %0, align 8
br label %bb12
bb12: ; preds = %bb11, %bb2
%1 = getelementptr inbounds { i64, i64 }, ptr %0, i32 0, i32 0
%2 = load i64, ptr %1, align 8, !range !2, !noundef !3
%3 = getelementptr inbounds { i64, i64 }, ptr %0, i32 0, i32 1
%4 = load i64, ptr %3, align 8
%5 = insertvalue { i64, i64 } undef, i64 %2, 0
%6 = insertvalue { i64, i64 } %5, i64 %4, 1
ret { i64, i64 } %6
bb9: ; preds = %bb3
%7 = getelementptr inbounds %"core::ops::range::RangeInclusive<u64>", ptr %self, i32 0, i32 2
store i8 1, ptr %7, align 8
%_15 = getelementptr inbounds %"core::ops::range::RangeInclusive<u64>", ptr %self, i32 0, i32 1
; call core::clone::impls::<impl core::clone::Clone for u64>::clone
%8 = call i64 @"_ZN4core5clone5impls52_$LT$impl$u20$core..clone..Clone$u20$for$u20$u64$GT$5clone17h4b0887addae72185E"(ptr noalias noundef readonly align 8 dereferenceable(8) %_15)
store i64 %8, ptr %_7, align 8
br label %bb11
bb5: ; preds = %bb3
%_11 = getelementptr inbounds %"core::ops::range::RangeInclusive<u64>", ptr %self, i32 0, i32 1
; call core::clone::impls::<impl core::clone::Clone for u64>::clone
%_10 = call i64 @"_ZN4core5clone5impls52_$LT$impl$u20$core..clone..Clone$u20$for$u20$u64$GT$5clone17h4b0887addae72185E"(ptr noalias noundef readonly align 8 dereferenceable(8) %_11)
; call <u64 as core::iter::range::Step>::backward_unchecked
%n = call i64 @"_ZN47_$LT$u64$u20$as$u20$core..iter..range..Step$GT$18backward_unchecked17he96844d78fb68ceaE"(i64 %_10, i64 1)
%_13 = getelementptr inbounds %"core::ops::range::RangeInclusive<u64>", ptr %self, i32 0, i32 1
; call core::mem::replace
%9 = call i64 @_ZN4core3mem7replace17hb5e6383d7606b99fE(ptr noalias noundef align 8 dereferenceable(8) %_13, i64 %n)
store i64 %9, ptr %_7, align 8
br label %bb11
bb11: ; preds = %bb9, %bb5
%10 = getelementptr inbounds { i64, i64 }, ptr %0, i32 0, i32 1
%11 = load i64, ptr %_7, align 8
store i64 %11, ptr %10, align 8
store i64 1, ptr %0, align 8
call void @llvm.lifetime.end.p0(i64 8, ptr %_7)
br label %bb12
}
; <u64 as core::iter::range::Step>::forward_unchecked
; Function Attrs: inlinehint nonlazybind uwtable
define internal i64 @"_ZN47_$LT$u64$u20$as$u20$core..iter..range..Step$GT$17forward_unchecked17h148489915d758f97E"(i64 %start1, i64 %n) unnamed_addr #0 {
start:
; call core::num::<impl u64>::unchecked_add
%0 = call i64 @"_ZN4core3num21_$LT$impl$u20$u64$GT$13unchecked_add17h9a94eaeec5f4d6d4E"(i64 %start1, i64 %n)
ret i64 %0
}
; <u64 as core::iter::range::Step>::backward_unchecked
; Function Attrs: inlinehint nonlazybind uwtable
define internal i64 @"_ZN47_$LT$u64$u20$as$u20$core..iter..range..Step$GT$18backward_unchecked17he96844d78fb68ceaE"(i64 %start1, i64 %n) unnamed_addr #0 {
start:
; call core::num::<impl u64>::unchecked_sub
%0 = call i64 @"_ZN4core3num21_$LT$impl$u20$u64$GT$13unchecked_sub17ha35472d6ff5e3ff2E"(i64 %start1, i64 %n)
ret i64 %0
}
; core::cmp::impls::<impl core::cmp::PartialOrd for u64>::le
; Function Attrs: inlinehint nonlazybind uwtable
define internal noundef zeroext i1 @"_ZN4core3cmp5impls55_$LT$impl$u20$core..cmp..PartialOrd$u20$for$u20$u64$GT$2le17hc6e56e6bf5e035b2E"(ptr noalias noundef readonly align 8 dereferenceable(8) %self, ptr noalias noundef readonly align 8 dereferenceable(8) %other) unnamed_addr #0 {
start:
%_3 = load i64, ptr %self, align 8
%_4 = load i64, ptr %other, align 8
%0 = icmp ule i64 %_3, %_4
ret i1 %0
}
; core::cmp::impls::<impl core::cmp::PartialOrd for u64>::lt
; Function Attrs: inlinehint nonlazybind uwtable
define internal noundef zeroext i1 @"_ZN4core3cmp5impls55_$LT$impl$u20$core..cmp..PartialOrd$u20$for$u20$u64$GT$2lt17h3ff66d7102accf3fE"(ptr noalias noundef readonly align 8 dereferenceable(8) %self, ptr noalias noundef readonly align 8 dereferenceable(8) %other) unnamed_addr #0 {
start:
%_3 = load i64, ptr %self, align 8
%_4 = load i64, ptr %other, align 8
%0 = icmp ult i64 %_3, %_4
ret i1 %0
}
; core::mem::maybe_uninit::MaybeUninit<T>::as_mut_ptr
; Function Attrs: alwaysinline nonlazybind uwtable
define internal ptr @"_ZN4core3mem12maybe_uninit20MaybeUninit$LT$T$GT$10as_mut_ptr17h260d519ad0770c3dE"(ptr noalias noundef align 8 dereferenceable(8) %self) unnamed_addr #1 {
start:
ret ptr %self
}
; core::mem::maybe_uninit::MaybeUninit<T>::assume_init
; Function Attrs: alwaysinline nonlazybind uwtable
define internal i64 @"_ZN4core3mem12maybe_uninit20MaybeUninit$LT$T$GT$11assume_init17h219d76a19e637e28E"(i64 %self, ptr noalias noundef readonly align 8 dereferenceable(24) %0) unnamed_addr #1 {
start:
; call core::mem::manually_drop::ManuallyDrop<T>::into_inner
%1 = call i64 @"_ZN4core3mem13manually_drop21ManuallyDrop$LT$T$GT$10into_inner17hed0606f94b7e086dE"(i64 %self)
ret i64 %1
}
; core::mem::maybe_uninit::MaybeUninit<T>::uninit
; Function Attrs: alwaysinline nonlazybind uwtable
define internal i64 @"_ZN4core3mem12maybe_uninit20MaybeUninit$LT$T$GT$6uninit17h8e9d4bca8dd52c34E"() unnamed_addr #1 {
start:
%0 = alloca i64, align 8
%1 = load i64, ptr %0, align 8
ret i64 %1
}
; core::mem::manually_drop::ManuallyDrop<T>::into_inner
; Function Attrs: alwaysinline nonlazybind uwtable
define internal i64 @"_ZN4core3mem13manually_drop21ManuallyDrop$LT$T$GT$10into_inner17hed0606f94b7e086dE"(i64 %slot) unnamed_addr #1 {
start:
ret i64 %slot
}
; core::mem::replace
; Function Attrs: inlinehint nonlazybind uwtable
define internal i64 @_ZN4core3mem7replace17hb5e6383d7606b99fE(ptr noalias noundef align 8 dereferenceable(8) %dest, i64 %src) unnamed_addr #0 personality ptr @rust_eh_personality {
start:
%0 = alloca { ptr, i32 }, align 8
%_7 = alloca i8, align 1
store i8 1, ptr %_7, align 1
; invoke core::ptr::read
%result = invoke i64 @_ZN4core3ptr4read17h1fe2a25b617d29f4E(ptr %dest)
to label %bb1 unwind label %cleanup
bb6: ; preds = %bb3, %cleanup
%1 = load i8, ptr %_7, align 1, !range !4, !noundef !3
%2 = trunc i8 %1 to i1
br i1 %2, label %bb5, label %bb4
cleanup: ; preds = %start
%3 = landingpad { ptr, i32 }
cleanup
%4 = extractvalue { ptr, i32 } %3, 0
%5 = extractvalue { ptr, i32 } %3, 1
call void @llvm.lifetime.start.p0(i64 16, ptr %0)
%6 = getelementptr inbounds { ptr, i32 }, ptr %0, i32 0, i32 0
store ptr %4, ptr %6, align 8
%7 = getelementptr inbounds { ptr, i32 }, ptr %0, i32 0, i32 1
store i32 %5, ptr %7, align 8
br label %bb6
bb1: ; preds = %start
store i8 0, ptr %_7, align 1
; invoke core::ptr::write
invoke void @_ZN4core3ptr5write17hd468d00ae21c7acaE(ptr %dest, i64 %src)
to label %bb2 unwind label %cleanup1
bb3: ; preds = %cleanup1
br label %bb6
cleanup1: ; preds = %bb1
%8 = landingpad { ptr, i32 }
cleanup
%9 = extractvalue { ptr, i32 } %8, 0
%10 = extractvalue { ptr, i32 } %8, 1
call void @llvm.lifetime.start.p0(i64 16, ptr %0)
%11 = getelementptr inbounds { ptr, i32 }, ptr %0, i32 0, i32 0
store ptr %9, ptr %11, align 8
%12 = getelementptr inbounds { ptr, i32 }, ptr %0, i32 0, i32 1
store i32 %10, ptr %12, align 8
br label %bb3
bb2: ; preds = %bb1
ret i64 %result
bb4: ; preds = %bb5, %bb6
%13 = load ptr, ptr %0, align 8
%14 = getelementptr inbounds { ptr, i32 }, ptr %0, i32 0, i32 1
%15 = load i32, ptr %14, align 8
call void @llvm.lifetime.end.p0(i64 16, ptr %0)
%16 = insertvalue { ptr, i32 } undef, ptr %13, 0
%17 = insertvalue { ptr, i32 } %16, i32 %15, 1
resume { ptr, i32 } %17
bb5: ; preds = %bb6
br label %bb4
}
; core::num::<impl u64>::unchecked_add
; Function Attrs: alwaysinline nonlazybind uwtable
define internal i64 @"_ZN4core3num21_$LT$impl$u20$u64$GT$13unchecked_add17h9a94eaeec5f4d6d4E"(i64 %self, i64 %rhs) unnamed_addr #1 {
start:
%0 = alloca i64, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr %0)
%1 = add nuw i64 %self, %rhs
store i64 %1, ptr %0, align 8
%2 = load i64, ptr %0, align 8
call void @llvm.lifetime.end.p0(i64 8, ptr %0)
ret i64 %2
}
; core::num::<impl u64>::unchecked_sub
; Function Attrs: alwaysinline nonlazybind uwtable
define internal i64 @"_ZN4core3num21_$LT$impl$u20$u64$GT$13unchecked_sub17ha35472d6ff5e3ff2E"(i64 %self, i64 %rhs) unnamed_addr #1 {
start:
%0 = alloca i64, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr %0)
%1 = sub nuw i64 %self, %rhs
store i64 %1, ptr %0, align 8
%2 = load i64, ptr %0, align 8
call void @llvm.lifetime.end.p0(i64 8, ptr %0)
ret i64 %2
}
; core::ops::range::RangeInclusive<Idx>::is_empty
; Function Attrs: inlinehint nonlazybind uwtable
define internal noundef zeroext i1 @"_ZN4core3ops5range25RangeInclusive$LT$Idx$GT$8is_empty17h34912468b073e4b3E"(ptr noalias noundef readonly align 8 dereferenceable(24) %self) unnamed_addr #0 {
start:
%0 = alloca i8, align 1
%1 = getelementptr inbounds %"core::ops::range::RangeInclusive<u64>", ptr %self, i32 0, i32 2
%2 = load i8, ptr %1, align 8, !range !4, !noundef !3
%_2 = trunc i8 %2 to i1
br i1 %_2, label %bb1, label %bb2
bb2: ; preds = %start
%_6 = getelementptr inbounds %"core::ops::range::RangeInclusive<u64>", ptr %self, i32 0, i32 1
; call core::cmp::impls::<impl core::cmp::PartialOrd for u64>::le
%_4 = call noundef zeroext i1 @"_ZN4core3cmp5impls55_$LT$impl$u20$core..cmp..PartialOrd$u20$for$u20$u64$GT$2le17hc6e56e6bf5e035b2E"(ptr noalias noundef readonly align 8 dereferenceable(8) %self, ptr noalias noundef readonly align 8 dereferenceable(8) %_6)
%_3 = xor i1 %_4, true
%3 = zext i1 %_3 to i8
store i8 %3, ptr %0, align 1
br label %bb3
bb1: ; preds = %start
store i8 1, ptr %0, align 1
br label %bb3
bb3: ; preds = %bb2, %bb1
%4 = load i8, ptr %0, align 1, !range !4, !noundef !3
%5 = trunc i8 %4 to i1
ret i1 %5
}
; core::ptr::read
; Function Attrs: inlinehint nonlazybind uwtable
define internal i64 @_ZN4core3ptr4read17h1fe2a25b617d29f4E(ptr %src) unnamed_addr #0 {
start:
%tmp = alloca i64, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr %tmp)
; call core::mem::maybe_uninit::MaybeUninit<T>::uninit
%0 = call i64 @"_ZN4core3mem12maybe_uninit20MaybeUninit$LT$T$GT$6uninit17h8e9d4bca8dd52c34E"()
store i64 %0, ptr %tmp, align 8
; call core::mem::maybe_uninit::MaybeUninit<T>::as_mut_ptr
%_4 = call ptr @"_ZN4core3mem12maybe_uninit20MaybeUninit$LT$T$GT$10as_mut_ptr17h260d519ad0770c3dE"(ptr noalias noundef align 8 dereferenceable(8) %tmp)
call void @llvm.memcpy.p0.p0.i64(ptr align 8 %_4, ptr align 8 %src, i64 8, i1 false)
%_6 = load i64, ptr %tmp, align 8
; call core::mem::maybe_uninit::MaybeUninit<T>::assume_init
%1 = call i64 @"_ZN4core3mem12maybe_uninit20MaybeUninit$LT$T$GT$11assume_init17h219d76a19e637e28E"(i64 %_6, ptr noalias noundef readonly align 8 dereferenceable(24) @alloc27)
call void @llvm.lifetime.end.p0(i64 8, ptr %tmp)
ret i64 %1
}
; core::ptr::write
; Function Attrs: inlinehint nonlazybind uwtable
define internal void @_ZN4core3ptr5write17hd468d00ae21c7acaE(ptr %dst, i64 %0) unnamed_addr #0 {
start:
%src = alloca i64, align 8
store i64 %0, ptr %src, align 8
call void @llvm.memcpy.p0.p0.i64(ptr align 8 %dst, ptr align 8 %src, i64 8, i1 false)
ret void
}
; core::iter::adapters::rev::Rev<T>::new
; Function Attrs: nonlazybind uwtable
define internal void @"_ZN4core4iter8adapters3rev12Rev$LT$T$GT$3new17h56bbad34c42b3c9cE"(ptr noalias nocapture noundef sret(%"core::iter::adapters::rev::Rev<core::ops::range::RangeInclusive<u64>>") dereferenceable(24) %0, ptr noalias nocapture noundef dereferenceable(24) %iter) unnamed_addr #2 {
start:
%_2 = alloca %"core::ops::range::RangeInclusive<u64>", align 8
call void @llvm.lifetime.start.p0(i64 24, ptr %_2)
call void @llvm.memcpy.p0.p0.i64(ptr align 8 %_2, ptr align 8 %iter, i64 24, i1 false)
call void @llvm.memcpy.p0.p0.i64(ptr align 8 %0, ptr align 8 %_2, i64 24, i1 false)
call void @llvm.lifetime.end.p0(i64 24, ptr %_2)
ret void
}
; core::clone::impls::<impl core::clone::Clone for u64>::clone
; Function Attrs: alwaysinline nonlazybind uwtable
define internal i64 @"_ZN4core5clone5impls52_$LT$impl$u20$core..clone..Clone$u20$for$u20$u64$GT$5clone17h4b0887addae72185E"(ptr noalias noundef readonly align 8 dereferenceable(8) %self) unnamed_addr #1 {
start:
%0 = load i64, ptr %self, align 8
ret i64 %0
}
; <core::ops::range::Range<T> as core::iter::range::RangeIteratorImpl>::spec_next
; Function Attrs: inlinehint nonlazybind uwtable
define internal { i64, i64 } @"_ZN89_$LT$core..ops..range..Range$LT$T$GT$$u20$as$u20$core..iter..range..RangeIteratorImpl$GT$9spec_next17h7faa1bfe233f0c79E"(ptr noalias noundef align 8 dereferenceable(16) %self) unnamed_addr #0 {
start:
%0 = alloca { i64, i64 }, align 8
%_4 = getelementptr inbounds { i64, i64 }, ptr %self, i32 0, i32 1
; call core::cmp::impls::<impl core::cmp::PartialOrd for u64>::lt
%_2 = call noundef zeroext i1 @"_ZN4core3cmp5impls55_$LT$impl$u20$core..cmp..PartialOrd$u20$for$u20$u64$GT$2lt17h3ff66d7102accf3fE"(ptr noalias noundef readonly align 8 dereferenceable(8) %self, ptr noalias noundef readonly align 8 dereferenceable(8) %_4)
br i1 %_2, label %bb2, label %bb6
bb6: ; preds = %start
store i64 0, ptr %0, align 8
br label %bb7
bb2: ; preds = %start
; call core::clone::impls::<impl core::clone::Clone for u64>::clone
%_6 = call i64 @"_ZN4core5clone5impls52_$LT$impl$u20$core..clone..Clone$u20$for$u20$u64$GT$5clone17h4b0887addae72185E"(ptr noalias noundef readonly align 8 dereferenceable(8) %self)
; call <u64 as core::iter::range::Step>::forward_unchecked
%n = call i64 @"_ZN47_$LT$u64$u20$as$u20$core..iter..range..Step$GT$17forward_unchecked17h148489915d758f97E"(i64 %_6, i64 1)
; call core::mem::replace
%_8 = call i64 @_ZN4core3mem7replace17hb5e6383d7606b99fE(ptr noalias noundef align 8 dereferenceable(8) %self, i64 %n)
%1 = getelementptr inbounds { i64, i64 }, ptr %0, i32 0, i32 1
store i64 %_8, ptr %1, align 8
store i64 1, ptr %0, align 8
br label %bb7
bb7: ; preds = %bb6, %bb2
%2 = getelementptr inbounds { i64, i64 }, ptr %0, i32 0, i32 0
%3 = load i64, ptr %2, align 8, !range !2, !noundef !3
%4 = getelementptr inbounds { i64, i64 }, ptr %0, i32 0, i32 1
%5 = load i64, ptr %4, align 8
%6 = insertvalue { i64, i64 } undef, i64 %3, 0
%7 = insertvalue { i64, i64 } %6, i64 %5, 1
ret { i64, i64 } %7
}
; issue_45222::foo2
; Function Attrs: nonlazybind uwtable
define internal i64 @_ZN11issue_452224foo217h611b29b15546776cE(i64 %n) unnamed_addr #2 {
start:
%_24 = alloca %"core::ops::range::RangeInclusive<u64>", align 8
%_15 = alloca { i64, i64 }, align 8
%iter3 = alloca %"core::iter::adapters::rev::Rev<core::ops::range::RangeInclusive<u64>>", align 8
%self2 = alloca %"core::ops::range::RangeInclusive<u64>", align 8
%self1 = alloca %"core::iter::adapters::rev::Rev<core::ops::range::RangeInclusive<u64>>", align 8
%_10 = alloca %"core::iter::adapters::rev::Rev<core::ops::range::RangeInclusive<u64>>", align 8
%_6 = alloca { i64, i64 }, align 8
%iter = alloca { i64, i64 }, align 8
%self = alloca { i64, i64 }, align 8
%count = alloca i64, align 8
store i64 0, ptr %count, align 8
call void @llvm.lifetime.start.p0(i64 16, ptr %self)
store i64 0, ptr %self, align 8
%0 = getelementptr inbounds { i64, i64 }, ptr %self, i32 0, i32 1
store i64 %n, ptr %0, align 8
%1 = getelementptr inbounds { i64, i64 }, ptr %self, i32 0, i32 0
%_2.0 = load i64, ptr %1, align 8
%2 = getelementptr inbounds { i64, i64 }, ptr %self, i32 0, i32 1
%_2.1 = load i64, ptr %2, align 8
call void @llvm.lifetime.end.p0(i64 16, ptr %self)
call void @llvm.lifetime.start.p0(i64 16, ptr %iter)
%3 = getelementptr inbounds { i64, i64 }, ptr %iter, i32 0, i32 0
store i64 %_2.0, ptr %3, align 8
%4 = getelementptr inbounds { i64, i64 }, ptr %iter, i32 0, i32 1
store i64 %_2.1, ptr %4, align 8
br label %bb1
bb1: ; preds = %bb8, %start
call void @llvm.lifetime.start.p0(i64 16, ptr %_6)
; call <core::ops::range::Range<T> as core::iter::range::RangeIteratorImpl>::spec_next
%5 = call { i64, i64 } @"_ZN89_$LT$core..ops..range..Range$LT$T$GT$$u20$as$u20$core..iter..range..RangeIteratorImpl$GT$9spec_next17h7faa1bfe233f0c79E"(ptr noalias noundef align 8 dereferenceable(16) %iter)
store { i64, i64 } %5, ptr %_6, align 8
%_9 = load i64, ptr %_6, align 8, !range !2, !noundef !3
switch i64 %_9, label %bb3 [
i64 0, label %bb4
i64 1, label %bb2
]
bb3: ; preds = %bb1
unreachable
bb4: ; preds = %bb1
call void @llvm.lifetime.end.p0(i64 16, ptr %_6)
call void @llvm.lifetime.end.p0(i64 16, ptr %iter)
%6 = load i64, ptr %count, align 8
ret i64 %6
bb2: ; preds = %bb1
call void @llvm.lifetime.start.p0(i64 24, ptr %_10)
call void @llvm.lifetime.start.p0(i64 24, ptr %self1)
call void @llvm.lifetime.start.p0(i64 24, ptr %self2)
store i64 0, ptr %self2, align 8
%7 = getelementptr inbounds %"core::ops::range::RangeInclusive<u64>", ptr %self2, i32 0, i32 1
store i64 %n, ptr %7, align 8
%8 = getelementptr inbounds %"core::ops::range::RangeInclusive<u64>", ptr %self2, i32 0, i32 2
store i8 0, ptr %8, align 8
call void @llvm.lifetime.start.p0(i64 24, ptr %_24)
call void @llvm.memcpy.p0.p0.i64(ptr align 8 %_24, ptr align 8 %self2, i64 24, i1 false)
; call core::iter::adapters::rev::Rev<T>::new
call void @"_ZN4core4iter8adapters3rev12Rev$LT$T$GT$3new17h56bbad34c42b3c9cE"(ptr noalias nocapture noundef sret(%"core::iter::adapters::rev::Rev<core::ops::range::RangeInclusive<u64>>") dereferenceable(24) %self1, ptr noalias nocapture noundef dereferenceable(24) %_24)
call void @llvm.lifetime.end.p0(i64 24, ptr %_24)
call void @llvm.lifetime.end.p0(i64 24, ptr %self2)
call void @llvm.memcpy.p0.p0.i64(ptr align 8 %_10, ptr align 8 %self1, i64 24, i1 false)
call void @llvm.lifetime.end.p0(i64 24, ptr %self1)
call void @llvm.lifetime.start.p0(i64 24, ptr %iter3)
call void @llvm.memcpy.p0.p0.i64(ptr align 8 %iter3, ptr align 8 %_10, i64 24, i1 false)
br label %bb5
bb5: ; preds = %bb6, %bb2
call void @llvm.lifetime.start.p0(i64 16, ptr %_15)
; call <core::ops::range::RangeInclusive<T> as core::iter::range::RangeInclusiveIteratorImpl>::spec_next_back
%9 = call { i64, i64 } @"_ZN107_$LT$core..ops..range..RangeInclusive$LT$T$GT$$u20$as$u20$core..iter..range..RangeInclusiveIteratorImpl$GT$14spec_next_back17h87d30d713fef30d5E"(ptr noalias noundef align 8 dereferenceable(24) %iter3)
store { i64, i64 } %9, ptr %_15, align 8
%_18 = load i64, ptr %_15, align 8, !range !2, !noundef !3
switch i64 %_18, label %bb7 [
i64 0, label %bb8
i64 1, label %bb6
]
bb7: ; preds = %bb5
unreachable
bb8: ; preds = %bb5
call void @llvm.lifetime.end.p0(i64 16, ptr %_15)
call void @llvm.lifetime.end.p0(i64 24, ptr %iter3)
call void @llvm.lifetime.end.p0(i64 24, ptr %_10)
call void @llvm.lifetime.end.p0(i64 16, ptr %_6)
br label %bb1
bb6: ; preds = %bb5
%10 = getelementptr inbounds { i64, i64 }, ptr %_15, i32 0, i32 1
%j = load i64, ptr %10, align 8
%11 = load i64, ptr %count, align 8
%12 = add i64 %11, %j
store i64 %12, ptr %count, align 8
call void @llvm.lifetime.end.p0(i64 16, ptr %_15)
br label %bb5
}
; Function Attrs: nonlazybind uwtable
define i64 @check_foo2() unnamed_addr #2 {
start:
; call issue_45222::foo2
%0 = call i64 @_ZN11issue_452224foo217h611b29b15546776cE(i64 100000)
ret i64 %0
}
; Function Attrs: nonlazybind uwtable
declare noundef i32 @rust_eh_personality(i32, i32 noundef, i64, ptr, ptr) unnamed_addr #2
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3
; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #4
; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #4
attributes #0 = { inlinehint nonlazybind uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" }
attributes #1 = { alwaysinline nonlazybind uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" }
attributes #2 = { nonlazybind uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
!llvm.module.flags = !{!0, !1}
!0 = !{i32 8, !"PIC Level", i32 2}
!1 = !{i32 2, !"RtLibUseGOT", i32 1}
!2 = !{i64 0, i64 2}
!3 = !{}
!4 = !{i8 0, i8 2}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment