Skip to content

Instantly share code, notes, and snippets.

@DemiMarie
Created December 20, 2016 01:14
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 DemiMarie/376d6debc8c0529b7459cd792408cb6e to your computer and use it in GitHub Desktop.
Save DemiMarie/376d6debc8c0529b7459cd792408cb6e to your computer and use it in GitHub Desktop.
Bad LLVM IR
; ModuleID = 'become_bad.cgu-0.rs'
source_filename = "become_bad.cgu-0.rs"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%"unwind::libunwind::_Unwind_Exception" = type { i64, void (i32, %"unwind::libunwind::_Unwind_Exception"*)*, [6 x i64] }
%"unwind::libunwind::_Unwind_Context" = type {}
; Function Attrs: noinline uwtable
define internal fastcc void @_ZN10become_bad13recursive_sum17h5ffeab538ceef8eeE({ i64, i64, i64, i64, i64, i64, i64 }* noalias nocapture sret dereferenceable(56), i64, i64) unnamed_addr #0 personality i32 (i32, i32, i64, %"unwind::libunwind::_Unwind_Exception"*, %"unwind::libunwind::_Unwind_Context"*)* @rust_eh_personality {
entry-block:
%dummy.i.i.i = alloca {}, align 8
%3 = icmp eq i64 %1, 0
br i1 %3, label %bb1, label %bb7
bb1: ; preds = %entry-block
%4 = getelementptr inbounds { i64, i64, i64, i64, i64, i64, i64 }, { i64, i64, i64, i64, i64, i64, i64 }* %0, i64 0, i32 0
store i64 %2, i64* %4, align 8
%5 = getelementptr inbounds { i64, i64, i64, i64, i64, i64, i64 }, { i64, i64, i64, i64, i64, i64, i64 }* %0, i64 0, i32 1
%6 = bitcast i64* %5 to i8*
call void @llvm.memset.p0i8.i64(i8* %6, i8 0, i64 48, i32 8, i1 false)
ret void
bb7: ; preds = %entry-block
%7 = add i64 %1, -1
%8 = bitcast {}* %dummy.i.i.i to i8*
call void @llvm.lifetime.start(i64 0, i8* %8) #2
call void asm "", "r,~{dirflag},~{fpsr},~{flags}"({}* nonnull %dummy.i.i.i) #2, !srcloc !1
call void @llvm.lifetime.end(i64 0, i8* %8) #2
%9 = add i64 %2, %1
tail call fastcc void @_ZN10become_bad13recursive_sum17h5ffeab538ceef8eeE({ i64, i64, i64, i64, i64, i64, i64 }* noalias nocapture nonnull sret dereferenceable(56) %0, i64 %7, i64 %9)
ret void
}
; Function Attrs: uwtable
define internal void @_ZN10become_bad4main17hc53b2550bd1e0ca0E() unnamed_addr #1 {
entry-block:
%dummy.i = alloca { i64, i64, i64, i64, i64, i64, i64 }, align 8
%_2 = alloca { i64, i64, i64, i64, i64, i64, i64 }, align 8
%0 = bitcast { i64, i64, i64, i64, i64, i64, i64 }* %_2 to i8*
call void @llvm.lifetime.start(i64 56, i8* %0)
call fastcc void @_ZN10become_bad13recursive_sum17h5ffeab538ceef8eeE({ i64, i64, i64, i64, i64, i64, i64 }* noalias nocapture nonnull sret dereferenceable(56) %_2, i64 100000000, i64 0)
%1 = bitcast { i64, i64, i64, i64, i64, i64, i64 }* %dummy.i to i8*
call void @llvm.lifetime.start(i64 56, i8* %1) #2, !noalias !2
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %1, i8* %0, i64 56, i32 8, i1 false) #2, !noalias !6
call void asm "", "r,~{dirflag},~{fpsr},~{flags}"({ i64, i64, i64, i64, i64, i64, i64 }* nonnull %dummy.i) #2, !noalias !2, !srcloc !1
call void @llvm.lifetime.end(i64 56, i8* %1) #2, !noalias !2
call void @llvm.lifetime.end(i64 56, i8* %0)
ret void
}
; Function Attrs: nounwind
declare i32 @rust_eh_personality(i32, i32, i64, %"unwind::libunwind::_Unwind_Exception"*, %"unwind::libunwind::_Unwind_Context"*) unnamed_addr #2
; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.start(i64, i8* nocapture) #3
; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.end(i64, i8* nocapture) #3
; Function Attrs: argmemonly nounwind
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) #3
define i64 @main(i64, i8**) unnamed_addr {
top:
%2 = tail call i64 @_ZN3std2rt10lang_start17h8d51a6012f37187dE(i8* bitcast (void ()* @_ZN10become_bad4main17hc53b2550bd1e0ca0E to i8*), i64 %0, i8** %1)
ret i64 %2
}
declare i64 @_ZN3std2rt10lang_start17h8d51a6012f37187dE(i8*, i64, i8**) unnamed_addr
; Function Attrs: argmemonly nounwind
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i32, i1) #3
attributes #0 = { noinline uwtable }
attributes #1 = { uwtable }
attributes #2 = { nounwind }
attributes #3 = { argmemonly nounwind }
!llvm.module.flags = !{!0}
!0 = !{i32 1, !"PIE Level", i32 2}
!1 = !{i32 211}
!2 = !{!3, !5}
!3 = distinct !{!3, !4, !"_ZN4test9black_box17h7c9cdfed86950196E: argument 0"}
!4 = distinct !{!4, !"_ZN4test9black_box17h7c9cdfed86950196E"}
!5 = distinct !{!5, !4, !"_ZN4test9black_box17h7c9cdfed86950196E: argument 1"}
!6 = !{!3}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment