Skip to content

Instantly share code, notes, and snippets.

@ztlpn
Created November 14, 2021 13:52
Show Gist options
  • Save ztlpn/453b1f906e5f838fa6e47434b03c65e6 to your computer and use it in GitHub Desktop.
Save ztlpn/453b1f906e5f838fa6e47434b03c65e6 to your computer and use it in GitHub Desktop.
; ModuleID = 'test_coro.cc'
source_filename = "test_coro.cc"
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-unknown-linux-gnu"
%_Z6do_runv.Frame = type { void (%_Z6do_runv.Frame*)*, void (%_Z6do_runv.Frame*)*, %"struct.task::promise_type", i1, i32, [2 x i64] }
%"struct.task::promise_type" = type { i8 }
@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind readonly uwtable willreturn
define dso_local i32 @_Z4func4args([2 x i64] %0) local_unnamed_addr #0 {
%2 = extractvalue [2 x i64] %0, 0
%3 = inttoptr i64 %2 to i32*
%4 = load i32, i32* %3, align 4, !tbaa !8
ret i32 %4
}
; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1
; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1
; Function Attrs: noinline uwtable
define dso_local i64 @_Z6do_runv() #2 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
%1 = alloca i32, align 4
%2 = tail call noalias nonnull i8* @_Znwm(i64 40) #8
%3 = bitcast i8* %2 to void (%_Z6do_runv.Frame*)**
store void (%_Z6do_runv.Frame*)* @_Z6do_runv.resume, void (%_Z6do_runv.Frame*)** %3, align 8
%4 = getelementptr inbounds i8, i8* %2, i64 8
%5 = bitcast i8* %4 to void (%_Z6do_runv.Frame*)**
store void (%_Z6do_runv.Frame*)* @_Z6do_runv.destroy, void (%_Z6do_runv.Frame*)** %5, align 8
%6 = getelementptr inbounds i8, i8* %2, i64 16
%7 = ptrtoint i32* %1 to i64
%8 = getelementptr inbounds i8, i8* %2, i64 24
%9 = bitcast i8* %8 to i64*
store i64 %7, i64* %9, align 8
%10 = getelementptr inbounds i8, i8* %2, i64 32
%11 = bitcast i8* %10 to i64*
store i64 0, i64* %11, align 8
%12 = getelementptr inbounds i8, i8* %2, i64 20
%13 = bitcast i8* %12 to i32*
store i32 0, i32* %13, align 4
%14 = getelementptr inbounds i8, i8* %2, i64 17
%15 = bitcast i8* %14 to i1*
store i1 false, i1* %15, align 1
call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull %6) #9
%16 = ptrtoint i8* %2 to i64
ret i64 %16
}
; Function Attrs: nobuiltin allocsize(0)
declare dso_local nonnull i8* @_Znwm(i64) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare dso_local noundef i32 @printf(i8* nocapture noundef readonly, ...) local_unnamed_addr #4
declare dso_local i32 @__gxx_personality_v0(...)
; Function Attrs: noreturn nounwind
declare dso_local void @abort() local_unnamed_addr #5
; Function Attrs: nobuiltin nounwind
declare dso_local void @_ZdlPv(i8*) local_unnamed_addr #6
; Function Attrs: mustprogress norecurse uwtable
define dso_local i32 @main() local_unnamed_addr #7 {
%1 = tail call i64 @_Z6do_runv()
%2 = inttoptr i64 %1 to i8*
%3 = bitcast i8* %2 to { i8*, i8* }*
%4 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %3, i32 0, i32 0
%5 = load i8*, i8** %4, align 8
%6 = bitcast i8* %5 to void (i8*)*
tail call fastcc void %6(i8* %2)
%7 = bitcast i8* %2 to { i8*, i8* }*
%8 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %7, i32 0, i32 0
%9 = load i8*, i8** %8, align 8
%10 = bitcast i8* %9 to void (i8*)*
tail call fastcc void %10(i8* %2)
%11 = bitcast i8* %2 to { i8*, i8* }*
%12 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %11, i32 0, i32 0
%13 = load i8*, i8** %12, align 8
%14 = bitcast i8* %13 to void (i8*)*
tail call fastcc void %14(i8* %2)
%15 = bitcast i8* %2 to { i8*, i8* }*
%16 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %15, i32 0, i32 1
%17 = load i8*, i8** %16, align 8
%18 = bitcast i8* %17 to void (i8*)*
tail call fastcc void %18(i8* %2)
ret i32 0
}
; Function Attrs: noinline uwtable
define internal fastcc void @_Z6do_runv.resume(%_Z6do_runv.Frame* noalias nonnull align 8 dereferenceable(40) %0) #2 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
%2 = getelementptr inbounds %_Z6do_runv.Frame, %_Z6do_runv.Frame* %0, i64 0, i32 2, i32 0
call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull %2) #9
%3 = getelementptr inbounds %_Z6do_runv.Frame, %_Z6do_runv.Frame* %0, i64 0, i32 4
%4 = load i32, i32* %3, align 4
%5 = getelementptr inbounds %_Z6do_runv.Frame, %_Z6do_runv.Frame* %0, i64 0, i32 5, i64 0
%6 = load i64, i64* %5, align 8
%7 = insertvalue [2 x i64] undef, i64 %6, 0
%8 = getelementptr inbounds %_Z6do_runv.Frame, %_Z6do_runv.Frame* %0, i64 0, i32 5, i64 1
%9 = load i64, i64* %8, align 8
%10 = insertvalue [2 x i64] %7, i64 %9, 1
%11 = call i32 @_Z4func4args([2 x i64] %10)
%12 = call i32 (i8*, ...) @printf(i8* nonnull dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = icmp eq i32 %11, %4
br i1 %13, label %15, label %14
14: ; preds = %1
call void @abort() #10
unreachable
15: ; preds = %1
%16 = getelementptr inbounds %_Z6do_runv.Frame, %_Z6do_runv.Frame* %0, i64 0, i32 4
%17 = load i32, i32* %16, align 4
%18 = add nuw nsw i32 %17, 1
%19 = getelementptr inbounds %_Z6do_runv.Frame, %_Z6do_runv.Frame* %0, i64 0, i32 4
store i32 %18, i32* %19, align 4
%20 = getelementptr inbounds %_Z6do_runv.Frame, %_Z6do_runv.Frame* %0, i64 0, i32 3
store i1 false, i1* %20, align 1
%21 = getelementptr inbounds %_Z6do_runv.Frame, %_Z6do_runv.Frame* %0, i64 0, i32 2, i32 0
call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull %21) #9
ret void
}
; Function Attrs: noinline uwtable
define internal fastcc void @_Z6do_runv.destroy(%_Z6do_runv.Frame* noalias nonnull align 8 dereferenceable(40) %0) #2 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
%2 = getelementptr inbounds %_Z6do_runv.Frame, %_Z6do_runv.Frame* %0, i64 0, i32 2
%3 = getelementptr %"struct.task::promise_type", %"struct.task::promise_type"* %2, i64 0, i32 0
call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull %3) #9
%4 = bitcast %_Z6do_runv.Frame* %0 to i8*
%5 = getelementptr inbounds %"struct.task::promise_type", %"struct.task::promise_type"* %2, i64 0, i32 0
call void @llvm.lifetime.end.p0i8(i64 1, i8* nonnull %5) #9
call void @_ZdlPv(i8* nonnull %4) #9
ret void
}
attributes #0 = { mustprogress nofree noinline norecurse nosync nounwind readonly uwtable willreturn "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon" }
attributes #1 = { argmemonly mustprogress nofree nosync nounwind willreturn }
attributes #2 = { noinline uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon" }
attributes #3 = { nobuiltin allocsize(0) "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon" }
attributes #4 = { nofree nounwind "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon" }
attributes #5 = { noreturn nounwind "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon" }
attributes #6 = { nobuiltin nounwind "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon" }
attributes #7 = { mustprogress norecurse uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon" }
attributes #8 = { allocsize(0) }
attributes #9 = { nounwind }
attributes #10 = { noreturn nounwind }
!llvm.linker.options = !{}
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6}
!llvm.ident = !{!7}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 1, !"branch-target-enforcement", i32 0}
!2 = !{i32 1, !"sign-return-address", i32 0}
!3 = !{i32 1, !"sign-return-address-all", i32 0}
!4 = !{i32 1, !"sign-return-address-with-bkey", i32 0}
!5 = !{i32 7, !"uwtable", i32 1}
!6 = !{i32 7, !"frame-pointer", i32 1}
!7 = !{!"Ubuntu clang version 13.0.1-++20211110063012+9dc7d6d5e326-1~exp1~20211110183538.22"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment