-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Function has token parameter but isn't an intrinsic #40056
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
Comments
assigned to @hiraditya |
The IR verifier might be too stringent on the token checking. The outlined filter funclet is given a token to tie it to the parent clause but is a "Function" in IR land. This triggers a verification failure. |
This is caused by the hot/cold splitting code path promoting the token to a formal argument. |
(pasting in stuff I said in IRC)
And, I think the verifier is working as intended here. You are not supposed to be able to pass a token as a regular parameter, it can't be passed through registers/memory/phis, etc, and I think arguments fit in there as well. It just so happens that you can look at the bundle type ("funclet" in this case) and reason about it, so it is possible to do what you want, but in the general case, I don't think tokens can be outlined. |
I only have a vague understanding of WinEH, so apologies for the naive question: is the funclet really the thing being split here? It looks like two blocks dominated by a cleanuppad are split, and afaik they aren't normally outlined?
Should splitting even be allowed on functions with WinEH personality? I don't think any run-time testing has been done with this. And as you point out, it may not be profitable.
This points to a separate bug. CodeExtractor shouldn't permit this. |
I think that we should still teach the Hot/Cold splitting to deal with the tokens. But, yes the funclets should not be split into the cold path since they are already outlined. |
When I compile this code with Found a cold block: ehcleanup: ; preds = %entry
%1 = cleanuppad within none []
%arraydestroy.element7 = getelementptr inbounds %struct.S, %struct.S* %this, i64 0, i32 1, i64 0
call void @"??1T@@UEAA@XZ"(%struct.T* nonnull %arraydestroy.element7) #​4 [ "funclet"(token %1) ]
call void @​__std_terminate() #​5 [ "funclet"(token %1) ]
unreachable Outlining in The blocks in the cleanuppad region constitute the funclet. They share a stack frame with the parent function, but the code is discontiguous from the parent function and has its own prologue/epilogue.
Up to you. I think if we update
Makes sense. |
The splitting pass will refuse to extract EH pads (see By 'cleanuppad region', can I assume you mean blocks which use a cleannuppad token?
I'll take a cut at this, but might need some help with the run-time testing bit.
|
BTW, I ended up with this reduction: ; RUN: opt -hotcoldsplit %s -S -o /dev/null
define void @"??1S@@UEAA@XZ"() personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
entry:
invoke void @"?f@@YAXXZ"()
to label %invoke.cont unwind label %ehcleanup
invoke.cont:
ret void
ehcleanup:
%0 = cleanuppad within none []
br label %ehcleanup.resume
ehcleanup.resume:
call void @"?f@@YAXXZ"() [ "funclet"(token %0) ]
br label %terminate
terminmate:
call void @"?terminate@@YAXXZ"() [ "funclet"(token %0) ]
unreachable
}
declare void @"?f@@YAXXZ"()
declare i32 @__CxxFrameHandler3(...)
declare void @"?terminate@@YAXXZ"() |
Thanks for providing the repro ; RUN: opt --hot-cold-split %s -S -o /dev/null
define void @"??1S@@UEAA@XZ"() personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
entry:
invoke void @"?f@@YAXXZ"()
to label %invoke.cont unwind label %ehcleanup
invoke.cont:
ret void
ehcleanup:
%0 = cleanuppad within none []
br label %ehcleanup.resume
ehcleanup.resume:
call void @"?f@@YAXXZ"() [ "funclet"(token %0) ]
br label %terminate
terminate:
call void @"?terminate@@YAXXZ"() [ "funclet"(token %0) ]
unreachable
}
declare void @"?f@@YAXXZ"()
declare i32 @__CxxFrameHandler3(...)
declare void @"?terminate@@YAXXZ"() the compilation aborts after hotcoldsplit with the following IR. *** IR Dump After Hot Cold Splitting ***
; ModuleID = '<stdin>'
source_filename = "<stdin>"
define void @"??1S@@UEAA@XZ"() personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
entry:
invoke void @"?f@@YAXXZ"()
to label %invoke.cont unwind label %ehcleanup
invoke.cont: ; preds = %entry
ret void
ehcleanup: ; preds = %entry
%0 = cleanuppad within none []
br label %codeRepl
codeRepl: ; preds = %ehcleanup
call void @"??1S@@[email protected]"(token %0) #1
ret void
}
declare void @"?f@@YAXXZ"()
declare i32 @__CxxFrameHandler3(...)
declare void @"?terminate@@YAXXZ"()
; Function Attrs: cold minsize noreturn
define internal void @"??1S@@[email protected]"(token %0) #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
newFuncRoot:
br label %ehcleanup.resume
ehcleanup.resume: ; preds = %newFuncRoot
call void @"?f@@YAXXZ"() [ "funclet"(token %0) ]
br label %terminate
terminate: ; preds = %ehcleanup.resume
call void @"?terminate@@YAXXZ"() [ "funclet"(token %0) ]
unreachable
}
attributes #0 = { cold minsize noreturn }
attributes #1 = { noinline }
Function has token parameter but isn't an intrinsic
call void @"??1S@@[email protected]"(token %0) #1
in function ??1S@@UEAA@XZ
LLVM ERROR: Broken function found, compilation aborted! |
Bug fix: D68192 |
Attaching the patch by @vedantk(#40056 (comment)) above. |
swift-inspect will fail to build in release mode after the dump-arrays PR (swiftlang/swift#66973) due to an llvm bug (llvm/llvm-project#40056). This is a workaround for it.
swift-inspect will fail to build in release mode after the dump-arrays PR (swiftlang/swift#66973) due to an llvm bug (llvm/llvm-project#40056). This is a workaround for it.
@Endilll - what exactly needs to be done in terms of triaging? This is an issue with the hot cold splitting implementation, which is done in LLVM. |
I think the fix is to disable outlining of basic blocks with token-type instructions |
…lvm#99759) Hot cold splitting should not outline: 1. Basic blocks with token type instructions 1. Functions with scoped EH personality (As suggested by Vedant in llvm#40056 (comment)) Fixes: llvm#40056 (cherry picked from commit c59ee7e)
…lvm#99759) Hot cold splitting should not outline: 1. Basic blocks with token type instructions 1. Functions with scoped EH personality (As suggested by Vedant in llvm#40056 (comment)) Fixes: llvm#40056 (cherry picked from commit c59ee7e) (cherry picked from commit 267c6ed)
…99759) Hot cold splitting should not outline: 1. Basic blocks with token type instructions 1. Functions with scoped EH personality (As suggested by Vedant in #40056 (comment)) Fixes: #40056
Adds some flags for Swift's LLVM compiler to succeed on Windows. Related: llvm/llvm-project#40056 Signed-off-by: kingbri <[email protected]>
Extended Description
Reduced from ICU 61:
The text was updated successfully, but these errors were encountered: