Skip to content
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

[SR-6235] Compiler and runtime disagree about calling convention for swift_unexpectedError() and others #48787

Closed
gparker42 mannequin opened this issue Oct 27, 2017 · 6 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself IRGen LLVM IR generation runtime The Swift Runtime

Comments

@gparker42
Copy link
Mannequin

gparker42 mannequin commented Oct 27, 2017

Previous ID SR-6235
Radar rdar://problem/35222489
Original Reporter @gparker42
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, IRGen, Runtime
Assignee @aschwaighofer
Priority Medium

md5: cc56a0756fcb065286f647b1fc310da0

Issue Description:

In TOT swift, the compiler and runtime disagree about the calling convention of swift_unexpectedError() and other runtime functions.

The problem is that the description in RuntimeFunctions.def is incompatible with the definition.
RuntimeFunctions.def: swift_unexpectedError() is DefaultCC
ErrorType.swift: swift_unexpectedError() is a Swift function annotated with @_silgen_name and therefore uses the Swift calling convention.

This also applies to swift_willThrow and swift_errorInMain().

@belkadan
Copy link
Contributor

DefaultCC is SwiftCC on platforms that support it, I think, but we should still get this right. @rjmccall, aschwaighofer@apple.com (JIRA User)?

@aschwaighofer
Copy link
Member

No DefaultCC is the standard/c calling convention.

This could be a problem if the ABI's mismatch and we should fix this.

In the specific cases (passing one pointer and returning void)

// void swift_unexpectedError(SwiftError *object)
// void swift_willThrow(error *ptr);
// void swift_errorInMain(error *ptr);

the swift calling convention and the c calling convention happen to be ABI compatible.

The callee-saved register set of llvm::cc and llvm::swiftcc happens to be the same. And argument passing only differs if we are dealing with swiftself/swifterror annotations (they are passed in a CSR)

@aschwaighofer
Copy link
Member

@swift-ci create

@aschwaighofer
Copy link
Member

@gparker42 swift_willThrow is not declared as a @_silgen_name function in swift.

@aschwaighofer
Copy link
Member

#12659

@gparker42
Copy link
Mannequin Author

gparker42 mannequin commented Dec 6, 2017

Arnold fixed this a while ago.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself IRGen LLVM IR generation runtime The Swift Runtime
Projects
None yet
Development

No branches or pull requests

2 participants