forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Coro][WebAssembly] Add tail-call check for async lowering (llvm#81481)
This patch fixes a verifier error when async lowering is used for WebAssembly target without tail-call feature. This missing check was revealed by b1ac052, which removed inlining of the musttail'ed call and it started leaving the invalid call at the verification stage. Additionally, `TTI::supportsTailCallFor` did not respect the concrete TTI's `supportsTailCalls` implementation, so it always returned true even though `supportsTailCalls` returned false, so this patch also fixes the wrong CRTP base class implementation.
- Loading branch information
1 parent
8ac7c4f
commit 8c5c4d9
Showing
5 changed files
with
50 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
; RUN: opt < %s -O0 -S -mtriple=wasm32-unknown-unknown | FileCheck %s | ||
; REQUIRES: webassembly-registered-target | ||
|
||
%swift.async_func_pointer = type <{ i32, i32 }> | ||
@checkTu = global %swift.async_func_pointer <{ i32 ptrtoint (ptr @check to i32), i32 8 }> | ||
|
||
define swiftcc void @check(ptr %0) { | ||
entry: | ||
%1 = call token @llvm.coro.id.async(i32 0, i32 0, i32 0, ptr @checkTu) | ||
%2 = call ptr @llvm.coro.begin(token %1, ptr null) | ||
%3 = call ptr @llvm.coro.async.resume() | ||
store ptr %3, ptr %0, align 4 | ||
%4 = call { ptr, i32 } (i32, ptr, ptr, ...) @llvm.coro.suspend.async.sl_p0i32s(i32 0, ptr %3, ptr @__swift_async_resume_project_context, ptr @check.0, ptr null, ptr null) | ||
ret void | ||
} | ||
|
||
declare swiftcc void @check.0() | ||
declare { ptr, i32 } @llvm.coro.suspend.async.sl_p0i32s(i32, ptr, ptr, ...) | ||
declare token @llvm.coro.id.async(i32, i32, i32, ptr) | ||
declare ptr @llvm.coro.begin(token, ptr writeonly) | ||
declare ptr @llvm.coro.async.resume() | ||
|
||
define ptr @__swift_async_resume_project_context(ptr %0) { | ||
entry: | ||
ret ptr null | ||
} | ||
|
||
; Verify that the resume call is not marked as musttail. | ||
; CHECK-LABEL: define swiftcc void @check( | ||
; CHECK-NOT: musttail call swiftcc void @check.0() | ||
; CHECK: call swiftcc void @check.0() |