-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[win][arm64ec] Handle available_externally
functions
#151610
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
Conversation
@llvm/pr-subscribers-backend-aarch64 @llvm/pr-subscribers-platform-windows Author: Daniel Paoliello (dpaoliello) ChangesWhile testing Arm64EC, I observed that LLVM crashes when an This the fix from #151409 plus a dedicated test. Full diff: https://github.com/llvm/llvm-project/pull/151610.diff 2 Files Affected:
diff --git a/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp b/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
index 509cbb092705d..8390c1f291365 100644
--- a/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
@@ -872,7 +872,7 @@ bool AArch64Arm64ECCallLowering::runOnModule(Module &Mod) {
if (!F.isDeclaration() && (!F.hasLocalLinkage() || F.hasAddressTaken()) &&
F.getCallingConv() != CallingConv::ARM64EC_Thunk_Native &&
F.getCallingConv() != CallingConv::ARM64EC_Thunk_X64) {
- if (!F.hasComdat())
+ if (!F.hasComdat() && !F.isDeclarationForLinker())
F.setComdat(Mod.getOrInsertComdat(F.getName()));
ThunkMapping.push_back(
{&F, buildEntryThunk(&F), Arm64ECThunkType::Entry});
diff --git a/llvm/test/CodeGen/AArch64/arm64ec-available-externally.ll b/llvm/test/CodeGen/AArch64/arm64ec-available-externally.ll
new file mode 100644
index 0000000000000..9457302403d4c
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/arm64ec-available-externally.ll
@@ -0,0 +1,9 @@
+; RUN: llc -mtriple arm64ec-windows-msvc < %s
+
+; Arm64EC Regression Test: The Arm64EC Call Lowering was placing "available
+; externally" items in COMDATs, which is not permitted by the module verifier.
+
+define available_externally i32 @f() {
+entry:
+ ret i32 0
+}
|
@@ -872,7 +872,7 @@ bool AArch64Arm64ECCallLowering::runOnModule(Module &Mod) { | |||
if (!F.isDeclaration() && (!F.hasLocalLinkage() || F.hasAddressTaken()) && | |||
F.getCallingConv() != CallingConv::ARM64EC_Thunk_Native && | |||
F.getCallingConv() != CallingConv::ARM64EC_Thunk_X64) { | |||
if (!F.hasComdat()) | |||
if (!F.hasComdat() && !F.isDeclarationForLinker()) | |||
F.setComdat(Mod.getOrInsertComdat(F.getName())); |
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.
We also want to skip creating an entry thunk for an available_externally function. The thunk should be provided by the translation unit that actually defines the function, and emitting an extra one could cause weird linker behavior.
We still may need a exit thunk, if the function is called.
I'd like to see the test show that we don't create an entry thunk, and do create an exit thunk.
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.
Good call: expanded the test and fixed other cases where we should be using isDeclarationForLinker
instead of isDeclaration
.
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.
LGTM
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/11/builds/20918 Here is the relevant piece of the build log for the reference
|
Seems unrelated: this change was to Arm64EC call lowering, which is not run at all for x86. Additionally, the crash is happening at link time (with non-LTO objects), not compilation time. |
While testing Arm64EC, I observed that LLVM crashes when an `available_externally` function is used as it tries to place it in a COMDAT, which is not permitted by the verifier. This the fix from llvm#151409 plus a dedicated test.
While testing Arm64EC, I observed that LLVM crashes when an
available_externally
function is used as it tries to place it in a COMDAT, which is not permitted by the verifier.This the fix from #151409 plus a dedicated test.