From 7f439638070e434e18792b22c8c51820cd5e313f Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Sat, 19 Feb 2022 23:10:52 -0300 Subject: [PATCH 1/3] Change macro --- src/ccall.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ccall.cpp b/src/ccall.cpp index 5f260d9178ffa..e7d9070e623f4 100644 --- a/src/ccall.cpp +++ b/src/ccall.cpp @@ -233,8 +233,8 @@ static GlobalVariable *emit_plt_thunk( else { // musttail support is very bad on ARM, PPC, PPC64 (as of LLVM 3.9) // Known failures includes vararg (not needed here) and sret. -#if (defined(_CPU_X86_) || defined(_CPU_X86_64_) || \ - defined(_CPU_AARCH64_)) + +#if (defined(_CPU_X86_) || defined(_CPU_X86_64_) || (defined(_CPU_AARCH64_) && !defined(__APPLE__))) // Ref https://bugs.llvm.org/show_bug.cgi?id=47058 // LLVM, as of 10.0.1 emits wrong/worse code when musttail is set if (!attrs.hasAttrSomewhere(Attribute::ByVal)) From 7565a52598a8b1d77a220cb0837a9b436ba5bc48 Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Sat, 19 Feb 2022 23:40:49 -0300 Subject: [PATCH 2/3] fix macro --- src/ccall.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ccall.cpp b/src/ccall.cpp index e7d9070e623f4..fdff8678595ae 100644 --- a/src/ccall.cpp +++ b/src/ccall.cpp @@ -234,9 +234,10 @@ static GlobalVariable *emit_plt_thunk( // musttail support is very bad on ARM, PPC, PPC64 (as of LLVM 3.9) // Known failures includes vararg (not needed here) and sret. -#if (defined(_CPU_X86_) || defined(_CPU_X86_64_) || (defined(_CPU_AARCH64_) && !defined(__APPLE__))) +#if (defined(_CPU_X86_) || defined(_CPU_X86_64_) || (defined(_CPU_AARCH64_) && !defined(_OS_DARWIN_))) // Ref https://bugs.llvm.org/show_bug.cgi?id=47058 // LLVM, as of 10.0.1 emits wrong/worse code when musttail is set + // Apple silicon macs give an LLVM ERROR if musttail is set here #44107. Purity PR if (!attrs.hasAttrSomewhere(Attribute::ByVal)) ret->setTailCallKind(CallInst::TCK_MustTail); #endif From e102b5caaf716554d83c8b34a9e2e70dd89e048a Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Sat, 19 Feb 2022 23:41:13 -0300 Subject: [PATCH 3/3] Fix comment --- src/ccall.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ccall.cpp b/src/ccall.cpp index fdff8678595ae..5357b3c6a533e 100644 --- a/src/ccall.cpp +++ b/src/ccall.cpp @@ -237,7 +237,7 @@ static GlobalVariable *emit_plt_thunk( #if (defined(_CPU_X86_) || defined(_CPU_X86_64_) || (defined(_CPU_AARCH64_) && !defined(_OS_DARWIN_))) // Ref https://bugs.llvm.org/show_bug.cgi?id=47058 // LLVM, as of 10.0.1 emits wrong/worse code when musttail is set - // Apple silicon macs give an LLVM ERROR if musttail is set here #44107. Purity PR + // Apple silicon macs give an LLVM ERROR if musttail is set here #44107. if (!attrs.hasAttrSomewhere(Attribute::ByVal)) ret->setTailCallKind(CallInst::TCK_MustTail); #endif