Skip to content

Instantly share code, notes, and snippets.

@nikic
Created March 9, 2020 08:09
Show Gist options
  • Save nikic/5f13662ae7559c16fdcc2e3cd2b17e5d to your computer and use it in GitHub Desktop.
Save nikic/5f13662ae7559c16fdcc2e3cd2b17e5d to your computer and use it in GitHub Desktop.
; Function Attrs: nonlazybind uwtable
define internal void @_ZN5test24main17h2936904f4b527945E() unnamed_addr #0 {
%1 = alloca %"core::fmt::Arguments", align 8
%2 = alloca [2 x i8], align 1
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
call void @llvm.lifetime.start.p0i8(i64 2, i8* nonnull %3)
store i8 49, i8* %3, align 1
%4 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
store i8 10, i8* %4, align 1
br label %5
5: ; preds = %16, %0
%6 = phi i64 [ 0, %0 ], [ %21, %16 ]
%7 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 2
%8 = insertvalue { i8*, i8* } undef, i8* %3, 0
%9 = insertvalue { i8*, i8* } %8, i8* %7, 1
br label %10
10: ; preds = %5, %16
%11 = phi i64 [ %21, %16 ], [ %6, %5 ]
%12 = phi i8* [ %17, %16 ], [ %3, %5 ]
%13 = load i8, i8* %12, align 1
%14 = add i8 %13, -48
%15 = icmp ult i8 %14, 10
br i1 %15, label %16, label %23
16: ; preds = %10
%17 = getelementptr inbounds i8, i8* %12, i64 1
%18 = mul i64 %11, 10
%19 = zext i8 %13 to i64
%20 = add i64 %18, -48
%21 = add i64 %20, %19
%22 = icmp eq i8* %17, %7
br i1 %22, label %5, label %10
23: ; preds = %10
%24 = icmp eq i8 %13, 10
call void @llvm.assume(i1 %24)
%25 = icmp eq i64 %11, 1
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = bitcast %"core::fmt::Arguments"* %1 to i8*
call void @llvm.lifetime.start.p0i8(i64 48, i8* nonnull %27)
%28 = bitcast %"core::fmt::Arguments"* %1 to [0 x { [0 x i8]*, i64 }]**
store [0 x { [0 x i8]*, i64 }]* bitcast (<{ i8*, [8 x i8] }>* @anon.fad58de7366495db4650cfefac2fcd61.1 to [0 x { [0 x i8]*, i64 }]*), [0 x { [0 x i8]*, i64 }]** %28, align 8, !alias.scope !3
%29 = getelementptr inbounds %"core::fmt::Arguments", %"core::fmt::Arguments"* %1, i64 0, i32 1, i32 1
store i64 1, i64* %29, align 8, !alias.scope !3
%30 = getelementptr inbounds %"core::fmt::Arguments", %"core::fmt::Arguments"* %1, i64 0, i32 3, i32 0
store i64* null, i64** %30, align 8, !alias.scope !3
%31 = getelementptr inbounds %"core::fmt::Arguments", %"core::fmt::Arguments"* %1, i64 0, i32 5, i32 0
store [0 x { i8*, i8* }]* bitcast (<{ [0 x i8] }>* @anon.fad58de7366495db4650cfefac2fcd61.2 to [0 x { i8*, i8* }]*), [0 x { i8*, i8* }]** %31, align 8, !alias.scope !3
%32 = getelementptr inbounds %"core::fmt::Arguments", %"core::fmt::Arguments"* %1, i64 0, i32 5, i32 1
store i64 0, i64* %32, align 8, !alias.scope !3
call void @_ZN3std2io5stdio6_print17h3bf8aa1fe2897d93E(%"core::fmt::Arguments"* noalias nocapture nonnull dereferenceable(48) %1)
call void @llvm.lifetime.end.p0i8(i64 48, i8* nonnull %27)
br label %33
33: ; preds = %26, %23
call void @llvm.lifetime.end.p0i8(i64 2, i8* nonnull %3)
ret void
}
*** IR Dump After Combine redundant instructions ***
; Function Attrs: nonlazybind uwtable
define internal void @_ZN5test24main17h2936904f4b527945E() unnamed_addr #0 {
%1 = alloca [2 x i8], align 1
%2 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 0
call void @llvm.lifetime.start.p0i8(i64 2, i8* nonnull %2)
store i8 49, i8* %2, align 1
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 1
store i8 10, i8* %3, align 1
br label %4
4: ; preds = %13, %0
%5 = phi i64 [ 0, %0 ], [ %18, %13 ]
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 2
br label %7
7: ; preds = %4, %13
%8 = phi i64 [ %18, %13 ], [ %5, %4 ]
%9 = phi i8* [ %14, %13 ], [ %2, %4 ]
%10 = load i8, i8* %9, align 1
%11 = add i8 %10, -48
%12 = icmp ult i8 %11, 10
br i1 %12, label %13, label %20
13: ; preds = %7
%14 = getelementptr inbounds i8, i8* %9, i64 1
%15 = mul i64 %8, 10
%16 = zext i8 %10 to i64
%17 = add i64 %15, -48
%18 = add i64 %17, %16
%19 = icmp eq i8* %14, %6
br i1 %19, label %4, label %7
20: ; preds = %7
%21 = icmp eq i8 %10, 10
call void @llvm.assume(i1 %21)
br i1 false, label %22, label %23
22: ; preds = %20
br label %23
23: ; preds = %22, %20
call void @llvm.lifetime.end.p0i8(i64 2, i8* nonnull %2)
ret void
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment