Skip to content

Instantly share code, notes, and snippets.

@jazzpi
Created August 12, 2020 12:12
Show Gist options
  • Save jazzpi/19b7a0d17a3176008be61e14c08484f3 to your computer and use it in GitHub Desktop.
Save jazzpi/19b7a0d17a3176008be61e14c08484f3 to your computer and use it in GitHub Desktop.
#include <stdexcept>
void may_throw() {
throw std::runtime_error("error");
}
int main(int argc, char** argv) {
try {
may_throw();
return 0;
} catch (std::runtime_error e) {
return 1;
}
}
; ModuleID = 'nosplit.cpp'
source_filename = "nosplit.cpp"
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"
%"class.std::runtime_error" = type { %"class.std::exception", %"struct.std::__cow_string" }
%"class.std::exception" = type { i32 (...)** }
%"struct.std::__cow_string" = type { %union.anon }
%union.anon = type { i8* }
@.str = private unnamed_addr constant [6 x i8] c"error\00", align 1
@_ZTISt13runtime_error = external dso_local constant i8*
; Function Attrs: noinline optnone uwtable
define dso_local void @_Z9may_throwv() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
%1 = alloca i8*
%2 = alloca i32
%3 = call i8* @__cxa_allocate_exception(i64 16) #5
%4 = bitcast i8* %3 to %"class.std::runtime_error"*
invoke void @_ZNSt13runtime_errorC1EPKc(%"class.std::runtime_error"* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
to label %5 unwind label %6
5: ; preds = %0
call void @__cxa_throw(i8* %3, i8* bitcast (i8** @_ZTISt13runtime_error to i8*), i8* bitcast (void (%"class.std::runtime_error"*)* @_ZNSt13runtime_errorD1Ev to i8*)) #6
unreachable
6: ; preds = %0
%7 = landingpad { i8*, i32 }
cleanup
%8 = extractvalue { i8*, i32 } %7, 0
store i8* %8, i8** %1, align 8
%9 = extractvalue { i8*, i32 } %7, 1
store i32 %9, i32* %2, align 4
call void @__cxa_free_exception(i8* %3) #5
br label %10
10: ; preds = %6
%11 = load i8*, i8** %1, align 8
%12 = load i32, i32* %2, align 4
%13 = insertvalue { i8*, i32 } undef, i8* %11, 0
%14 = insertvalue { i8*, i32 } %13, i32 %12, 1
resume { i8*, i32 } %14
}
declare dso_local i8* @__cxa_allocate_exception(i64)
declare dso_local void @_ZNSt13runtime_errorC1EPKc(%"class.std::runtime_error"*, i8*) unnamed_addr #1
declare dso_local i32 @__gxx_personality_v0(...)
declare dso_local void @__cxa_free_exception(i8*)
; Function Attrs: nounwind
declare dso_local void @_ZNSt13runtime_errorD1Ev(%"class.std::runtime_error"*) unnamed_addr #2
declare dso_local void @__cxa_throw(i8*, i8*, i8*)
; Function Attrs: noinline norecurse optnone uwtable
define dso_local i32 @main(i32 %0, i8** %1) #3 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
%3 = alloca i32, align 4
%4 = alloca i32, align 4
%5 = alloca i8**, align 8
%6 = alloca i8*
%7 = alloca i32
%8 = alloca %"class.std::runtime_error", align 8
store i32 0, i32* %3, align 4
store i32 %0, i32* %4, align 4
store i8** %1, i8*** %5, align 8
invoke void @_Z9may_throwv()
to label %9 unwind label %10
9: ; preds = %2
store i32 0, i32* %3, align 4
br label %23
10: ; preds = %2
%11 = landingpad { i8*, i32 }
catch i8* bitcast (i8** @_ZTISt13runtime_error to i8*)
%12 = extractvalue { i8*, i32 } %11, 0
store i8* %12, i8** %6, align 8
%13 = extractvalue { i8*, i32 } %11, 1
store i32 %13, i32* %7, align 4
br label %14
14: ; preds = %10
%15 = load i32, i32* %7, align 4
%16 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTISt13runtime_error to i8*)) #5
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %25
18: ; preds = %14
%19 = load i8*, i8** %6, align 8
%20 = call i8* @__cxa_get_exception_ptr(i8* %19) #5
%21 = bitcast i8* %20 to %"class.std::runtime_error"*
call void @_ZNSt13runtime_errorC1ERKS_(%"class.std::runtime_error"* %8, %"class.std::runtime_error"* dereferenceable(16) %21) #5
%22 = call i8* @__cxa_begin_catch(i8* %19) #5
store i32 1, i32* %3, align 4
call void @_ZNSt13runtime_errorD1Ev(%"class.std::runtime_error"* %8) #5
call void @__cxa_end_catch()
br label %23
23: ; preds = %9, %18
%24 = load i32, i32* %3, align 4
ret i32 %24
25: ; preds = %14
%26 = load i8*, i8** %6, align 8
%27 = load i32, i32* %7, align 4
%28 = insertvalue { i8*, i32 } undef, i8* %26, 0
%29 = insertvalue { i8*, i32 } %28, i32 %27, 1
resume { i8*, i32 } %29
}
; Function Attrs: nounwind readnone
declare i32 @llvm.eh.typeid.for(i8*) #4
declare dso_local i8* @__cxa_get_exception_ptr(i8*)
; Function Attrs: nounwind
declare dso_local void @_ZNSt13runtime_errorC1ERKS_(%"class.std::runtime_error"*, %"class.std::runtime_error"* dereferenceable(16)) unnamed_addr #2
declare dso_local i8* @__cxa_begin_catch(i8*)
declare dso_local void @__cxa_end_catch()
attributes #0 = { noinline optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #2 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #3 = { noinline norecurse optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #4 = { nounwind readnone }
attributes #5 = { nounwind }
attributes #6 = { noreturn }
!llvm.module.flags = !{!0}
!llvm.ident = !{!1}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git d32170dbd5b0d54436537b6b75beaf44324e0c28)"}
#include <stdexcept>
void may_throw() {
auto e = std::runtime_error("error");
throw e;
}
int main(int argc, char** argv) {
try {
may_throw();
return 0;
} catch (std::runtime_error e) {
return 1;
}
}
; ModuleID = 'split.cpp'
source_filename = "split.cpp"
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"
%"class.std::runtime_error" = type { %"class.std::exception", %"struct.std::__cow_string" }
%"class.std::exception" = type { i32 (...)** }
%"struct.std::__cow_string" = type { %union.anon }
%union.anon = type { i8* }
@.str = private unnamed_addr constant [6 x i8] c"error\00", align 1
@_ZTISt13runtime_error = external dso_local constant i8*
; Function Attrs: noinline optnone uwtable
define dso_local void @_Z9may_throwv() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
%1 = alloca %"class.std::runtime_error", align 8
%2 = alloca i8*
%3 = alloca i32
call void @_ZNSt13runtime_errorC1EPKc(%"class.std::runtime_error"* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = call i8* @__cxa_allocate_exception(i64 16) #5
%5 = bitcast i8* %4 to %"class.std::runtime_error"*
call void @_ZNSt13runtime_errorC1EOS_(%"class.std::runtime_error"* %5, %"class.std::runtime_error"* dereferenceable(16) %1) #5
invoke void @__cxa_throw(i8* %4, i8* bitcast (i8** @_ZTISt13runtime_error to i8*), i8* bitcast (void (%"class.std::runtime_error"*)* @_ZNSt13runtime_errorD1Ev to i8*)) #6
to label %15 unwind label %6
6: ; preds = %0
%7 = landingpad { i8*, i32 }
cleanup
%8 = extractvalue { i8*, i32 } %7, 0
store i8* %8, i8** %2, align 8
%9 = extractvalue { i8*, i32 } %7, 1
store i32 %9, i32* %3, align 4
call void @_ZNSt13runtime_errorD1Ev(%"class.std::runtime_error"* %1) #5
br label %10
10: ; preds = %6
%11 = load i8*, i8** %2, align 8
%12 = load i32, i32* %3, align 4
%13 = insertvalue { i8*, i32 } undef, i8* %11, 0
%14 = insertvalue { i8*, i32 } %13, i32 %12, 1
resume { i8*, i32 } %14
15: ; preds = %0
unreachable
}
declare dso_local void @_ZNSt13runtime_errorC1EPKc(%"class.std::runtime_error"*, i8*) unnamed_addr #1
declare dso_local i8* @__cxa_allocate_exception(i64)
; Function Attrs: nounwind
declare dso_local void @_ZNSt13runtime_errorC1EOS_(%"class.std::runtime_error"*, %"class.std::runtime_error"* dereferenceable(16)) unnamed_addr #2
; Function Attrs: nounwind
declare dso_local void @_ZNSt13runtime_errorD1Ev(%"class.std::runtime_error"*) unnamed_addr #2
declare dso_local void @__cxa_throw(i8*, i8*, i8*)
declare dso_local i32 @__gxx_personality_v0(...)
; Function Attrs: noinline norecurse optnone uwtable
define dso_local i32 @main(i32 %0, i8** %1) #3 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
%3 = alloca i32, align 4
%4 = alloca i32, align 4
%5 = alloca i8**, align 8
%6 = alloca i8*
%7 = alloca i32
%8 = alloca %"class.std::runtime_error", align 8
store i32 0, i32* %3, align 4
store i32 %0, i32* %4, align 4
store i8** %1, i8*** %5, align 8
invoke void @_Z9may_throwv()
to label %9 unwind label %10
9: ; preds = %2
store i32 0, i32* %3, align 4
br label %23
10: ; preds = %2
%11 = landingpad { i8*, i32 }
catch i8* bitcast (i8** @_ZTISt13runtime_error to i8*)
%12 = extractvalue { i8*, i32 } %11, 0
store i8* %12, i8** %6, align 8
%13 = extractvalue { i8*, i32 } %11, 1
store i32 %13, i32* %7, align 4
br label %14
14: ; preds = %10
%15 = load i32, i32* %7, align 4
%16 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTISt13runtime_error to i8*)) #5
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %25
18: ; preds = %14
%19 = load i8*, i8** %6, align 8
%20 = call i8* @__cxa_get_exception_ptr(i8* %19) #5
%21 = bitcast i8* %20 to %"class.std::runtime_error"*
call void @_ZNSt13runtime_errorC1ERKS_(%"class.std::runtime_error"* %8, %"class.std::runtime_error"* dereferenceable(16) %21) #5
%22 = call i8* @__cxa_begin_catch(i8* %19) #5
store i32 1, i32* %3, align 4
call void @_ZNSt13runtime_errorD1Ev(%"class.std::runtime_error"* %8) #5
call void @__cxa_end_catch()
br label %23
23: ; preds = %9, %18
%24 = load i32, i32* %3, align 4
ret i32 %24
25: ; preds = %14
%26 = load i8*, i8** %6, align 8
%27 = load i32, i32* %7, align 4
%28 = insertvalue { i8*, i32 } undef, i8* %26, 0
%29 = insertvalue { i8*, i32 } %28, i32 %27, 1
resume { i8*, i32 } %29
}
; Function Attrs: nounwind readnone
declare i32 @llvm.eh.typeid.for(i8*) #4
declare dso_local i8* @__cxa_get_exception_ptr(i8*)
; Function Attrs: nounwind
declare dso_local void @_ZNSt13runtime_errorC1ERKS_(%"class.std::runtime_error"*, %"class.std::runtime_error"* dereferenceable(16)) unnamed_addr #2
declare dso_local i8* @__cxa_begin_catch(i8*)
declare dso_local void @__cxa_end_catch()
attributes #0 = { noinline optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #2 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #3 = { noinline norecurse optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #4 = { nounwind readnone }
attributes #5 = { nounwind }
attributes #6 = { noreturn }
!llvm.module.flags = !{!0}
!llvm.ident = !{!1}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git d32170dbd5b0d54436537b6b75beaf44324e0c28)"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment