-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[Coroutines] fix coroutines + std::unique_ptr with async exceptions validation errors #149691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6ccbdcd
1d303ca
887bcb2
7f00eeb
5899a93
0b8e37a
428d6b4
ffe4587
c8b944c
8fa7b44
9ec807f
3c5929a
3551cc8
c4795ae
dbafc22
0e1afdf
380a643
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
; In coro-split, this coroutine code reduced IR, produced using clang with async-exceptions | ||
; crashed before fix because of the validation mismatch of Instruction does not dominate all uses! | ||
; RUN: opt < %s -passes='coro-split' -S | ||
|
||
; Function Attrs: presplitcoroutine | ||
define i8 @"?resuming_on_new_thread@@YA?AUtask@@Vunique_ptr@@@Z"(ptr %0) #0 personality ptr null { | ||
invoke void @llvm.seh.scope.begin() | ||
to label %2 unwind label %14 | ||
|
||
2: ; preds = %1 | ||
%3 = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null) | ||
%4 = load volatile ptr, ptr null, align 8 | ||
%5 = call ptr @llvm.coro.begin(token %3, ptr %4) | ||
%6 = call token @llvm.coro.save(ptr null) | ||
%7 = call i8 @llvm.coro.suspend(token none, i1 false) | ||
invoke void @llvm.seh.try.begin() | ||
to label %common.ret unwind label %8 | ||
|
||
common.ret: ; preds = %12, %10, %2 | ||
ret i8 0 | ||
|
||
8: ; preds = %2 | ||
%9 = catchswitch within none [label %10] unwind label %12 | ||
|
||
10: ; preds = %8 | ||
%11 = catchpad within %9 [ptr null, i32 0, ptr null] | ||
br label %common.ret | ||
|
||
12: ; preds = %8 | ||
%13 = cleanuppad within none [] | ||
invoke void @llvm.seh.scope.end() | ||
to label %common.ret unwind label %14 | ||
|
||
14: ; preds = %12, %1 | ||
%15 = cleanuppad within none [] | ||
store i32 0, ptr %0, align 4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems you are clearing pointer in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The pr148035_inst_does_not_dominate.ll is generated using llvm-reduce of a basic cpp file provided in the Issue. Anyway, I think that this
|
||
cleanupret from %15 unwind to caller | ||
} | ||
|
||
attributes #0 = { presplitcoroutine } | ||
|
||
!llvm.module.flags = !{!0} | ||
|
||
!0 = !{i32 2, !"eh-asynch", i32 1} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
; In coro-split, this coroutine code reduced IR, produced using clang with async-exceptions | ||
; crashed before fix because of the validation mismatch of Instruction does not dominate all uses! | ||
; RUN: opt < %s -passes='coro-split' -S | ||
|
||
; Function Attrs: presplitcoroutine | ||
define i8 @"?resuming_on_new_thread@@YA?AUtask@@Vunique_ptr@@@Z"(ptr %0) #0 personality ptr null { | ||
invoke void @llvm.seh.scope.begin() | ||
to label %2 unwind label %14 | ||
|
||
2: ; preds = %1 | ||
%3 = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null) | ||
%4 = load volatile ptr, ptr null, align 8 | ||
%5 = call ptr @llvm.coro.begin(token %3, ptr %4) | ||
%6 = call token @llvm.coro.save(ptr null) | ||
%7 = call i8 @llvm.coro.suspend(token none, i1 false) | ||
invoke void @llvm.seh.try.begin() | ||
to label %common.ret unwind label %8 | ||
|
||
common.ret: ; preds = %12, %10, %2 | ||
ret i8 0 | ||
|
||
8: ; preds = %2 | ||
%9 = catchswitch within none [label %10] unwind label %12 | ||
|
||
10: ; preds = %8 | ||
%11 = catchpad within %9 [ptr null, i32 0, ptr null] | ||
br label %common.ret | ||
|
||
12: ; preds = %8 | ||
%13 = cleanuppad within none [] | ||
invoke void @llvm.seh.scope.end() | ||
to label %common.ret unwind label %14 | ||
|
||
14: ; preds = %12, %1 | ||
%15 = cleanuppad within none [] | ||
store i32 0, ptr %0, align 4 | ||
br label %common.ret | ||
} | ||
|
||
attributes #0 = { presplitcoroutine } | ||
|
||
!llvm.module.flags = !{!0} | ||
|
||
!0 = !{i32 2, !"eh-asynch", i32 1} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
; In coro-split, this coroutine code reduced IR, produced using clang with async-exceptions | ||
; crashed after first phase of fix because the terminator cleanupret was not implemented on predecessor fixer at the time | ||
; RUN: opt < %s -passes='coro-split' -S | ||
|
||
; Function Attrs: presplitcoroutine | ||
define i8 @"?resuming_on_new_thread@@YA?AUtask@@V?$unique_ptr@HU?$default_delete@H@std@@@std@@0@Z"(ptr %0) #0 personality ptr null { | ||
invoke void @llvm.seh.scope.begin() | ||
to label %2 unwind label %15 | ||
|
||
2: ; preds = %1 | ||
%3 = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null) | ||
%4 = call ptr @llvm.coro.begin(token %3, ptr null) | ||
%5 = call token @llvm.coro.save(ptr null) | ||
%6 = call i8 @llvm.coro.suspend(token none, i1 false) | ||
invoke void @llvm.seh.try.begin() | ||
to label %7 unwind label %8 | ||
|
||
7: ; preds = %2 | ||
ret i8 0 | ||
|
||
8: ; preds = %2 | ||
%9 = catchswitch within none [label %10] unwind label %12 | ||
|
||
10: ; preds = %8 | ||
%11 = catchpad within %9 [ptr null, i32 0, ptr null] | ||
ret i8 0 | ||
|
||
12: ; preds = %8 | ||
%13 = cleanuppad within none [] | ||
invoke void @llvm.seh.scope.end() | ||
to label %14 unwind label %15 | ||
|
||
14: ; preds = %12 | ||
ret i8 0 | ||
|
||
15: ; preds = %12, %1 | ||
%16 = cleanuppad within none [] | ||
cleanupret from %16 unwind label %17 | ||
|
||
17: ; preds = %15 | ||
%18 = cleanuppad within none [] | ||
store i32 0, ptr %0, align 4 | ||
cleanupret from %18 unwind to caller | ||
} | ||
|
||
attributes #0 = { presplitcoroutine } | ||
|
||
!llvm.module.flags = !{!0} | ||
|
||
!0 = !{i32 2, !"eh-asynch", i32 1} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
; In coro-split, this coroutine standard code reduced IR, produced using clang with async-exceptions | ||
; crashed before fix because of the validation mismatch of Unwind edges out of a funclet pad must have the same unwind dest | ||
; RUN: opt < %s -passes='coro-split' -S | ||
|
||
; Function Attrs: presplitcoroutine | ||
define i8 @"?resuming_on_new_thread@@YA?AUtask@@AEAVjthread@std@@@Z"() #0 personality ptr null { | ||
%1 = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null) | ||
%2 = call ptr @llvm.coro.begin(token %1, ptr null) | ||
%3 = call token @llvm.coro.save(ptr null) | ||
%4 = call i8 @llvm.coro.suspend(token none, i1 false) | ||
invoke void @llvm.seh.try.begin() | ||
to label %common.ret unwind label %5 | ||
|
||
common.ret: ; preds = %13, %7, %0 | ||
ret i8 0 | ||
|
||
5: ; preds = %0 | ||
%6 = catchswitch within none [label %7] unwind label %9 | ||
|
||
7: ; preds = %5 | ||
%8 = catchpad within %6 [ptr null, i32 0, ptr null] | ||
br label %common.ret | ||
|
||
9: ; preds = %5 | ||
%10 = cleanuppad within none [] | ||
invoke void @llvm.seh.scope.end() [ "funclet"(token %10) ] | ||
to label %11 unwind label %13 | ||
|
||
11: ; preds = %9 | ||
%12 = call i1 @llvm.coro.end(ptr null, i1 true, token none) [ "funclet"(token %10) ] | ||
cleanupret from %10 unwind label %13 | ||
|
||
13: ; preds = %11, %9 | ||
%14 = cleanuppad within none [] | ||
br label %common.ret | ||
} | ||
|
||
attributes #0 = { presplitcoroutine } | ||
|
||
!llvm.module.flags = !{!0} | ||
|
||
!0 = !{i32 2, !"eh-asynch", i32 1} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
; In coro-split, this coroutine standard code reduced IR, produced using clang with async-exceptions | ||
; crashed before fix because of the validation mismatch of Unwind edges out of a funclet pad must have the same unwind dest | ||
; RUN: opt < %s -passes='coro-split' -S | ||
|
||
; Function Attrs: presplitcoroutine | ||
define i1 @"?resuming_on_new_thread@@YA?AUtask@@AEAVjthread@std@@@Z"() #0 personality ptr null { | ||
%1 = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null) | ||
%2 = call ptr @llvm.coro.begin(token %1, ptr null) | ||
%3 = call token @llvm.coro.save(ptr null) | ||
%4 = call i8 @llvm.coro.suspend(token none, i1 false) | ||
invoke void @llvm.seh.try.begin() | ||
to label %common.ret unwind label %5 | ||
|
||
common.ret: ; preds = %11, %13, %7, %0 | ||
%common.ret.op = phi i1 [ false, %11], [false, %13 ], [false, %7], [false, %0] | ||
ret i1 %common.ret.op | ||
|
||
5: ; preds = %0 | ||
%6 = catchswitch within none [label %7] unwind label %9 | ||
|
||
7: ; preds = %5 | ||
%8 = catchpad within %6 [ptr null, i32 0, ptr null] | ||
br label %common.ret | ||
|
||
9: ; preds = %5 | ||
%10 = cleanuppad within none [] | ||
invoke void @llvm.seh.scope.end() [ "funclet"(token %10) ] | ||
to label %11 unwind label %13 | ||
|
||
11: ; preds = %9 | ||
%12 = call i1 @llvm.coro.end(ptr null, i1 true, token none) [ "funclet"(token %10) ] | ||
br label %common.ret | ||
|
||
13: ; preds = %9 | ||
%14 = cleanuppad within none [] | ||
br label %common.ret | ||
} | ||
|
||
attributes #0 = { presplitcoroutine } | ||
|
||
!llvm.module.flags = !{!0} | ||
|
||
!0 = !{i32 2, !"eh-asynch", i32 1} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we clear
VMap
before reuse it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it's mandatory to keep it across traverse (when tested it previously), but I don't find an actual example to prove it, so I will clear it for now.