Re: [PATCH] D49898: Make test/Driver/baremetal.cpp work with linkers other than lld
LGTM Jon On Thu, Jul 26, 2018 at 10:12 PM David Greene via Phabricator < revi...@reviews.llvm.org> wrote: > greened created this revision. > greened added reviewers: jroelofs, hans, probinson, ismail, rtrieu. > Herald added a subscriber: cfe-commits. > > This test fails if clang is configure with, for example, gold as the > default linker. It does not appear that this test really relies on lld so > make the checks accept ld, ld.gold and ld.bfd too. > > > Repository: > rC Clang > > https://reviews.llvm.org/D49898 > > Files: > test/Driver/baremetal.cpp > > > Index: test/Driver/baremetal.cpp > === > --- test/Driver/baremetal.cpp > +++ test/Driver/baremetal.cpp > @@ -10,7 +10,7 @@ > // CHECK-V6M-C-SAME: "-internal-isystem" > "[[SYSROOT]]{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1" > // CHECk-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include" > // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp" > -// CHECK-V6M-C-NEXT: "{{[^"]*}}ld.lld{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" > +// CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" > "{{.*}}.o" "-Bstatic" > // CHECK-V6M-C-SAME: > "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal" > // CHECK-V6M-C-SAME: "-T" "semihosted.lds" > "-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for" > // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" > @@ -32,7 +32,7 @@ > // RUN: -target armv6m-none-eabi \ > // RUN: --sysroot=%S/Inputs/baremetal_arm \ > // RUN: | FileCheck --check-prefix=CHECK-V6M-DEFAULTCXX %s > -// CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld.lld{{(\.exe)?}}" "{{.*}}.o" > "-Bstatic" > +// CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" > "{{.*}}.o" "-Bstatic" > // CHECK-V6M-DEFAULTCXX-SAME: > "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal" > // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind" > // CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" > @@ -45,7 +45,7 @@ > // RUN: | FileCheck --check-prefix=CHECK-V6M-LIBCXX %s > // CHECK-V6M-LIBCXX-NOT: "-internal-isystem" > "{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}{{[^v].*}}" > // CHECK-V6M-LIBCXX: "-internal-isystem" > "{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1" > -// CHECK-V6M-LIBCXX: "{{[^"]*}}ld.lld{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" > +// CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" > "{{.*}}.o" "-Bstatic" > // CHECK-V6M-LIBCXX-SAME: > "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal" > // CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind" > // CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" > @@ -58,7 +58,7 @@ > // RUN: | FileCheck --check-prefix=CHECK-V6M-LIBSTDCXX %s > // CHECK-V6M-LIBSTDCXX-NOT: "-internal-isystem" > "{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1" > // CHECK-V6M-LIBSTDCXX: "-internal-isystem" > "{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}6.0.0" > -// CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld.lld{{(\.exe)?}}" "{{.*}}.o" > "-Bstatic" > +// CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" > "{{.*}}.o" "-Bstatic" > // CHECK-V6M-LIBSTDCXX-SAME: > "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal" > // CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind" > // CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" > @@ -69,7 +69,7 @@ > // RUN: --sysroot=%S/Inputs/baremetal_arm \ > // RUN: -nodefaultlibs \ > // RUN: | FileCheck --check-prefix=CHECK-V6M-NDL %s > -// CHECK-V6M-NDL: "{{[^"]*}}ld.lld{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" > +// CHECK-V6M-NDL: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" > "{{.*}}.o" "-Bstatic" > // CHECK-V6M-NDL-SAME: > "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal" > "-o" "{{.*}}.o" > > // RUN: %clangxx -target arm-none-eabi -v 2>&1 \ > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D43442: libunwind: when building without threads, pass this to libcxx as well
I’ll have a look this week. -jroelofs On Sun, Feb 18, 2018 at 9:27 AM Rink via Phabricator < revi...@reviews.llvm.org> wrote: > zhmu added a comment. > > I've added jroelofs to the reviewer list as we spoke about this in #llvm > quite some time ago. > > > Repository: > rUNW libunwind > > https://reviews.llvm.org/D43442 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D60990: [Driver] Support priority for multilibs
LGTM On Mon, Apr 22, 2019 at 8:34 PM Petr Hosek via Phabricator < revi...@reviews.llvm.org> wrote: > phosek created this revision. > phosek added reviewers: jroelofs, bkramer. > Herald added subscribers: cfe-commits, mgrang. > Herald added a project: clang. > > When more than one multilib flag matches, try to select the best > possible match based on priority. When two different multilibs with > the same same priority match, we still throw an error matching the > existing behavior. > > > Repository: > rC Clang > > https://reviews.llvm.org/D60990 > > Files: > clang/include/clang/Driver/Multilib.h > clang/lib/Driver/Multilib.cpp > > > Index: clang/lib/Driver/Multilib.cpp > === > --- clang/lib/Driver/Multilib.cpp > +++ clang/lib/Driver/Multilib.cpp > @@ -19,6 +19,7 @@ > #include "llvm/Support/raw_ostream.h" > #include > #include > +#include > #include > > using namespace clang; > @@ -51,8 +52,9 @@ > } > > Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix, > - StringRef IncludeSuffix) > -: GCCSuffix(GCCSuffix), OSSuffix(OSSuffix), > IncludeSuffix(IncludeSuffix) { > + StringRef IncludeSuffix, int Priority) > +: GCCSuffix(GCCSuffix), OSSuffix(OSSuffix), > IncludeSuffix(IncludeSuffix), > + Priority(Priority) { >normalizePathSegment(this->GCCSuffix); >normalizePathSegment(this->OSSuffix); >normalizePathSegment(this->IncludeSuffix); > @@ -265,8 +267,19 @@ > return true; >} > > - // TODO: pick the "best" multlib when more than one is suitable > - assert(false); > + // Sort multilibs by priority and select the one with the highest > priority. > + std::sort(Filtered.begin(), Filtered.end(), > +[](const Multilib &a, const Multilib &b) -> bool { > + return a.priority() > b.priority(); > +}); > + > + if (Filtered[0].priority() <= Filtered[1].priority()) { > +M = Filtered[0]; > +return true; > + } > + > + // TODO: We should consider returning llvm::Error rather than aborting. > + assert(false && "More than one multilib with the same priority"); >return false; > } > > Index: clang/include/clang/Driver/Multilib.h > === > --- clang/include/clang/Driver/Multilib.h > +++ clang/include/clang/Driver/Multilib.h > @@ -34,10 +34,11 @@ >std::string OSSuffix; >std::string IncludeSuffix; >flags_list Flags; > + int Priority; > > public: >Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {}, > - StringRef IncludeSuffix = {}); > + StringRef IncludeSuffix = {}, int Priority = 0); > >/// Get the detected GCC installation path suffix for the multi-arch >/// target variant. Always starts with a '/', unless empty > @@ -77,6 +78,9 @@ >const flags_list &flags() const { return Flags; } >flags_list &flags() { return Flags; } > > + /// Returns the multilib priority. > + int priority() const { return Priority; } > + >/// Add a flag to the flags list >/// \p Flag must be a flag accepted by the driver with its leading '-' > removed, >/// and replaced with either: > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D61040: [Fuchsia] Support multilib for -fsanitize=address and -fno-exceptions
On Tue, Apr 23, 2019 at 11:36 PM Petr Hosek via Phabricator < revi...@reviews.llvm.org> wrote: > phosek added inline comments. > > > > Comment at: clang/lib/Driver/ToolChains/CommonArgs.h:122 > + > +/// \p Flag must be a flag accepted by the driver with its leading '-' > removed, > +// otherwise '-print-multi-lib' will not emit them correctly. > > jroelofs wrote: > > Can we enforce this precondition with an assert? The > '-'-prefix-not-there part is easy, but what about the "it's a driver flag" > part? > We could, but we would need to pass in the reference to `Driver` so we can > use `getOpts().ParseOneArg` to parse the flag. However, we're not doing > that in `Multilib` either at the moment even though [the comment says it > has to be a valid flag]( > https://github.com/llvm/llvm-project/blob/master/clang/include/clang/Driver/Multilib.h#L80). > I'd prefer to keep this as a pure move and then add the additional checking > both here and to `Multilib` as a separate change, would that be fine with > you? Sure, that works. Jon > > > Repository: > rC Clang > > CHANGES SINCE LAST ACTION > https://reviews.llvm.org/D61040/new/ > > https://reviews.llvm.org/D61040 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D52151: Also manages clang-X as tool for scan-build
lgtm On Sun, Sep 16, 2018 at 12:47 PM Sylvestre Ledru via Phabricator < revi...@reviews.llvm.org> wrote: > sylvestre.ledru created this revision. > sylvestre.ledru added a reviewer: jroelofs. > > This will make > scan-build-7 clang-7 -c foo.c &> /dev/null > > > Repository: > rC Clang > > https://reviews.llvm.org/D52151 > > Files: > tools/scan-build/bin/scan-build > > > Index: tools/scan-build/bin/scan-build > === > --- tools/scan-build/bin/scan-build > +++ tools/scan-build/bin/scan-build > @@ -1079,7 +1079,7 @@ >if ($Cmd =~ /(.*\/?gcc[^\/]*$)/ or >$Cmd =~ /(.*\/?cc[^\/]*$)/ or >$Cmd =~ /(.*\/?llvm-gcc[^\/]*$)/ or > - $Cmd =~ /(.*\/?clang$)/ or > + $Cmd =~ /(.*\/?clang[^\/]*$)/ or >$Cmd =~ /(.*\/?ccc-analyzer[^\/]*$)/) { > > if (!($Cmd =~ /ccc-analyzer/) and !defined $ENV{"CCC_CC"}) { > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1e06b16 - [clang][docs] Document additional bits of libc that -ffreestanding envs must provide
Author: Jon Roelofs Date: 2020-05-26T15:42:32-06:00 New Revision: 1e06b169be3e59799b8dcaf16d1d03bd4c12da42 URL: https://github.com/llvm/llvm-project/commit/1e06b169be3e59799b8dcaf16d1d03bd4c12da42 DIFF: https://github.com/llvm/llvm-project/commit/1e06b169be3e59799b8dcaf16d1d03bd4c12da42.diff LOG: [clang][docs] Document additional bits of libc that -ffreestanding envs must provide Differential Revision: https://reviews.llvm.org/D80436 Added: Modified: clang/docs/CommandGuide/clang.rst Removed: diff --git a/clang/docs/CommandGuide/clang.rst b/clang/docs/CommandGuide/clang.rst index 6947450beb43..de0e0eda9097 100644 --- a/clang/docs/CommandGuide/clang.rst +++ b/clang/docs/CommandGuide/clang.rst @@ -246,7 +246,9 @@ Language Selection and Mode Options .. option:: -ffreestanding Indicate that the file should be compiled for a freestanding, not a hosted, - environment. + environment. Note that it is assumed that a freestanding environment will + additionally provide `memcpy`, `memmove`, `memset` and `memcmp` + implementations, as these are needed for efficient codegen for many programs. .. option:: -fno-builtin ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 38b39c3 - [clang] Add missing FileCheck colons
Author: Jon Roelofs Date: 2020-04-14T12:32:48-06:00 New Revision: 38b39c34ab0c860410e4ac7dc1b033ef14200be8 URL: https://github.com/llvm/llvm-project/commit/38b39c34ab0c860410e4ac7dc1b033ef14200be8 DIFF: https://github.com/llvm/llvm-project/commit/38b39c34ab0c860410e4ac7dc1b033ef14200be8.diff LOG: [clang] Add missing FileCheck colons Added: Modified: clang/test/CodeGen/bittest-intrin.c clang/test/CodeGenCXX/auto-var-init.cpp clang/test/CodeGenCXX/ms-thunks-ehspec.cpp clang/test/CodeGenObjC/fragile-arc.m clang/test/Driver/debug-options.c clang/test/Driver/hexagon-toolchain-elf.c clang/test/Driver/netbsd.c clang/test/Driver/riscv64-toolchain.c clang/test/Preprocessor/init.c clang/test/Sema/objc-bool-constant-conversion-fixit.m Removed: diff --git a/clang/test/CodeGen/bittest-intrin.c b/clang/test/CodeGen/bittest-intrin.c index f89a8267b0c7..edbae4ab9172 100644 --- a/clang/test/CodeGen/bittest-intrin.c +++ b/clang/test/CodeGen/bittest-intrin.c @@ -68,7 +68,7 @@ void test_arm(long *base, long idx) { // ARM: %[[MASK:[^ ]*]] = shl i8 1, %[[IDXLO]] // ARM: %[[BYTE:[^ ]*]] = load i8, i8* %[[BYTEADDR]], align 1 // ARM: %[[NEWBYTE:[^ ]*]] = xor i8 %[[BYTE]], %[[MASK]] -// ARM store i8 %[[NEWBYTE]], i8* %[[BYTEADDR]], align 1 +// ARM: store i8 %[[NEWBYTE]], i8* %[[BYTEADDR]], align 1 // ARM: %[[BYTESHR:[^ ]*]] = lshr i8 %[[BYTE]], %[[IDXLO]] // ARM: %[[RES:[^ ]*]] = and i8 %[[BYTESHR]], 1 // ARM: store volatile i8 %[[RES]], i8* @sink, align 1 @@ -82,7 +82,7 @@ void test_arm(long *base, long idx) { // ARM: %[[BYTE:[^ ]*]] = load i8, i8* %[[BYTEADDR]], align 1 // ARM: %[[NOTMASK:[^ ]*]] = xor i8 %[[MASK]], -1 // ARM: %[[NEWBYTE:[^ ]*]] = and i8 %[[BYTE]], %[[NOTMASK]] -// ARM store i8 %[[NEWBYTE]], i8* %[[BYTEADDR]], align 1 +// ARM: store i8 %[[NEWBYTE]], i8* %[[BYTEADDR]], align 1 // ARM: %[[BYTESHR:[^ ]*]] = lshr i8 %[[BYTE]], %[[IDXLO]] // ARM: %[[RES:[^ ]*]] = and i8 %[[BYTESHR]], 1 // ARM: store volatile i8 %[[RES]], i8* @sink, align 1 @@ -95,7 +95,7 @@ void test_arm(long *base, long idx) { // ARM: %[[MASK:[^ ]*]] = shl i8 1, %[[IDXLO]] // ARM: %[[BYTE:[^ ]*]] = load i8, i8* %[[BYTEADDR]], align 1 // ARM: %[[NEWBYTE:[^ ]*]] = or i8 %[[BYTE]], %[[MASK]] -// ARM store i8 %[[NEWBYTE]], i8* %[[BYTEADDR]], align 1 +// ARM: store i8 %[[NEWBYTE]], i8* %[[BYTEADDR]], align 1 // ARM: %[[BYTESHR:[^ ]*]] = lshr i8 %[[BYTE]], %[[IDXLO]] // ARM: %[[RES:[^ ]*]] = and i8 %[[BYTESHR]], 1 // ARM: store volatile i8 %[[RES]], i8* @sink, align 1 diff --git a/clang/test/CodeGenCXX/auto-var-init.cpp b/clang/test/CodeGenCXX/auto-var-init.cpp index 9399ec4eca08..773d70a0f456 100644 --- a/clang/test/CodeGenCXX/auto-var-init.cpp +++ b/clang/test/CodeGenCXX/auto-var-init.cpp @@ -748,7 +748,7 @@ TEST_UNINIT(paddedpacked, paddedpacked); // PATTERN-LABEL: @test_paddedpacked_uninit() // PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_paddedpacked_uninit.uninit // PATTERN-O1: %[[C:[^ ]*]] = getelementptr inbounds {{.*}}%uninit, i64 0, i32 0 -// PATTERN-O1 store i8 [[I8]], i8* %[[C]], align +// PATTERN-O1: store i8 [[I8]], i8* %[[C]], align // PATTERN-O1: %[[I:[^ ]*]] = getelementptr inbounds {{.*}}%uninit, i64 0, i32 1 // PATTERN-O1: store i32 [[I32]], i32* %[[I]], align @@ -1175,7 +1175,7 @@ TEST_UNINIT(complexfloat, _Complex float); // PATTERN-LABEL: @test_complexfloat_uninit() // PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_complexfloat_uninit.uninit // PATTERN-O1: %[[F1:[^ ]*]] = getelementptr inbounds {{.*}}%uninit, i64 0, i32 0 -// PATTERN-O1 store float 0xE000, float* %[[F1]], align +// PATTERN-O1: store float 0xE000, float* %[[F1]], align // PATTERN-O1: %[[F2:[^ ]*]] = getelementptr inbounds {{.*}}%uninit, i64 0, i32 1 // PATTERN-O1: store float 0xE000, float* %[[F2]], align diff --git a/clang/test/CodeGenCXX/ms-thunks-ehspec.cpp b/clang/test/CodeGenCXX/ms-thunks-ehspec.cpp index f72100d5078b..256f7123ee51 100644 --- a/clang/test/CodeGenCXX/ms-thunks-ehspec.cpp +++ b/clang/test/CodeGenCXX/ms-thunks-ehspec.cpp @@ -23,5 +23,5 @@ C c; // CHECK-LABEL: define linkonce_odr dso_local x86_thiscallcc void @"?f@C@@G3AEXUNonTrivial@@@Z"(%class.C* %this, <{ %struct.NonTrivial }>* inalloca %0) // CHECK-NOT: invoke // CHECK: musttail call x86_thiscallcc void @"?f@C@@EAEXUNonTrivial@@@Z"(%class.C* %{{.*}}, <{ %struct.NonTrivial }>* inalloca %0) -// CHECK-NEXT ret void +// CHECK-NEXT: ret void diff --git a/clang/test/CodeGenObjC/fragile-arc.m b/clang/test/CodeGenObjC/fragile-arc.m index 1320a147bbca..8b2d04ce92b9 100644 --- a/clang/test/CodeGenObjC/fragile-arc.m +++ b/clang/test/CodeGenObjC/fragile-arc.m @@ -14,7 +14,7 @@ @interface A : Root { } @end -// GLOBALS-LABEL @OBJC_METACLASS_A +// GLOBALS-LABEL: @OBJC_METACLASS_A // Strong layout: scan the first word. // GLOBALS: @OBJC_CLASS_
Re: [PATCH] D15528: Teach clang-tidy how to -Werror checks.
Oh, yeah, that should probably be clamped. I didn’t have a specific use case in mind, but in general I find that tools that emit “richer” information can be used for more things, hence returning the count, and not some fixed value. On Sat, Jun 13, 2020 at 12:58 AM Nathan James via Phabricator < revi...@reviews.llvm.org> wrote: > njames93 added inline comments. > Herald added a subscriber: arphaman. > > > > Comment at: clang-tidy/tool/ClangTidyMain.cpp:362 > + << Plural << "\n"; > +return WErrorCount; > + } > > Was there any specific reason for returning the error count instead of > returning 1. It results in undefined behaviour on POSIX shells if a value > is returned outside the range of 0<=n<=255. See > https://bugs.llvm.org/show_bug.cgi?id=46305 > > > CHANGES SINCE LAST ACTION > https://reviews.llvm.org/D15528/new/ > > https://reviews.llvm.org/D15528 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D81953: [clang-tidy] warnings-as-error no longer exits with ErrorCount
I didn’t have a specific use case in mind for it, so no preference either way. LGTM as well On Tue, Jun 16, 2020 at 1:05 PM Aaron Ballman via Phabricator < revi...@reviews.llvm.org> wrote: > aaron.ballman accepted this revision. > aaron.ballman added a comment. > This revision is now accepted and ready to land. > > LGTM unless @jroelofs has a reason why the code was originally written > that way, but can you add test coverage for it? > > > Repository: > rG LLVM Github Monorepo > > CHANGES SINCE LAST ACTION > https://reviews.llvm.org/D81953/new/ > > https://reviews.llvm.org/D81953 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 30414fc - Reland "[Intrinsics][ObjC] Mark objc_retain and friends as thisreturn."
Author: Jon Roelofs Date: 2023-11-06T08:47:05-08:00 New Revision: 30414fc614d80a45bad4c89763a353f50d3e04d6 URL: https://github.com/llvm/llvm-project/commit/30414fc614d80a45bad4c89763a353f50d3e04d6 DIFF: https://github.com/llvm/llvm-project/commit/30414fc614d80a45bad4c89763a353f50d3e04d6.diff LOG: Reland "[Intrinsics][ObjC] Mark objc_retain and friends as thisreturn." This reverts commit cb62f67088aaf79493350547f74870318b71acc5. Fixes: https://github.com/llvm/llvm-project/issues/69658 Added: Modified: clang/lib/CodeGen/CGCall.cpp clang/test/CodeGenObjC/arc.m clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m llvm/include/llvm/IR/Intrinsics.td llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp llvm/test/Transforms/PreISelIntrinsicLowering/X86/objc-arc.ll Removed: diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 230a6c3dbebadd1..e7951b3a3f4d855 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -3448,9 +3448,9 @@ static llvm::Value *tryRemoveRetainOfSelf(CodeGenFunction &CGF, const VarDecl *self = method->getSelfDecl(); if (!self->getType().isConstQualified()) return nullptr; - // Look for a retain call. - llvm::CallInst *retainCall = -dyn_cast(result->stripPointerCasts()); + // Look for a retain call. Note: stripPointerCasts looks through returned arg + // functions, which would cause us to miss the retain. + llvm::CallInst *retainCall = dyn_cast(result); if (!retainCall || retainCall->getCalledOperand() != CGF.CGM.getObjCEntrypoints().objc_retain) return nullptr; diff --git a/clang/test/CodeGenObjC/arc.m b/clang/test/CodeGenObjC/arc.m index 754c339cb2b31e6..fb4eb3452318df5 100644 --- a/clang/test/CodeGenObjC/arc.m +++ b/clang/test/CodeGenObjC/arc.m @@ -7,30 +7,30 @@ // RUN: %clang_cc1 -fobjc-runtime=macosx-10.7.0 -triple x86_64-apple-darwin11 -Wno-objc-root-class -Wno-incompatible-pointer-types -Wno-arc-unsafe-retained-assign -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -o - %s | FileCheck -check-prefix=ARC-NATIVE %s // ARC-ALIEN: declare extern_weak void @llvm.objc.storeStrong(ptr, ptr) -// ARC-ALIEN: declare extern_weak ptr @llvm.objc.retain(ptr) -// ARC-ALIEN: declare extern_weak ptr @llvm.objc.autoreleaseReturnValue(ptr) +// ARC-ALIEN: declare extern_weak ptr @llvm.objc.retain(ptr returned) +// ARC-ALIEN: declare extern_weak ptr @llvm.objc.autoreleaseReturnValue(ptr returned) // ARC-ALIEN: declare ptr @objc_msgSend(ptr, ptr, ...) [[NLB:#[0-9]+]] // ARC-ALIEN: declare extern_weak void @llvm.objc.release(ptr) -// ARC-ALIEN: declare extern_weak ptr @llvm.objc.retainAutoreleasedReturnValue(ptr) +// ARC-ALIEN: declare extern_weak ptr @llvm.objc.retainAutoreleasedReturnValue(ptr returned) // ARC-ALIEN: declare extern_weak ptr @llvm.objc.initWeak(ptr, ptr) // ARC-ALIEN: declare extern_weak ptr @llvm.objc.storeWeak(ptr, ptr) // ARC-ALIEN: declare extern_weak ptr @llvm.objc.loadWeakRetained(ptr) // ARC-ALIEN: declare extern_weak void @llvm.objc.destroyWeak(ptr) -// ARC-ALIEN: declare extern_weak ptr @llvm.objc.autorelease(ptr) -// ARC-ALIEN: declare extern_weak ptr @llvm.objc.retainAutorelease(ptr) +// ARC-ALIEN: declare extern_weak ptr @llvm.objc.autorelease(ptr returned) +// ARC-ALIEN: declare extern_weak ptr @llvm.objc.retainAutorelease(ptr returned) // ARC-NATIVE: declare void @llvm.objc.storeStrong(ptr, ptr) -// ARC-NATIVE: declare ptr @llvm.objc.retain(ptr) -// ARC-NATIVE: declare ptr @llvm.objc.autoreleaseReturnValue(ptr) +// ARC-NATIVE: declare ptr @llvm.objc.retain(ptr returned) +// ARC-NATIVE: declare ptr @llvm.objc.autoreleaseReturnValue(ptr returned) // ARC-NATIVE: declare ptr @objc_msgSend(ptr, ptr, ...) [[NLB:#[0-9]+]] // ARC-NATIVE: declare void @llvm.objc.release(ptr) -// ARC-NATIVE: declare ptr @llvm.objc.retainAutoreleasedReturnValue(ptr) +// ARC-NATIVE: declare ptr @llvm.objc.retainAutoreleasedReturnValue(ptr returned) // ARC-NATIVE: declare ptr @llvm.objc.initWeak(ptr, ptr) // ARC-NATIVE: declare ptr @llvm.objc.storeWeak(ptr, ptr) // ARC-NATIVE: declare ptr @llvm.objc.loadWeakRetained(ptr) // ARC-NATIVE: declare void @llvm.objc.destroyWeak(ptr) -// ARC-NATIVE: declare ptr @llvm.objc.autorelease(ptr) -// ARC-NATIVE: declare ptr @llvm.objc.retainAutorelease(ptr) +// ARC-NATIVE: declare ptr @llvm.objc.autorelease(ptr returned) +// ARC-NATIVE: declare ptr @llvm.objc.retainAutorelease(ptr returned) // CHECK-LABEL: define{{.*}} void @test0 void test0(id x) { diff --git a/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m b/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m index 9a5ecbc03d8ae6e..a60c9b0feb801f5 100644 --- a/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m +++ b/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m @@ -28,6 +28,11 @@ void test1(id x) { // MSGS: {{
[clang] d9ccace - Revert "Reland "[Intrinsics][ObjC] Mark objc_retain and friends as thisreturn.""
Author: Jon Roelofs Date: 2023-11-06T10:04:22-08:00 New Revision: d9ccacee13dbe12e2037c4694b6801a87411a1e7 URL: https://github.com/llvm/llvm-project/commit/d9ccacee13dbe12e2037c4694b6801a87411a1e7 DIFF: https://github.com/llvm/llvm-project/commit/d9ccacee13dbe12e2037c4694b6801a87411a1e7.diff LOG: Revert "Reland "[Intrinsics][ObjC] Mark objc_retain and friends as thisreturn."" This reverts commit 30414fc614d80a45bad4c89763a353f50d3e04d6. Broke some buildbots. Added: Modified: clang/lib/CodeGen/CGCall.cpp clang/test/CodeGenObjC/arc.m clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m llvm/include/llvm/IR/Intrinsics.td llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp llvm/test/Transforms/PreISelIntrinsicLowering/X86/objc-arc.ll Removed: diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index e7951b3a3f4d855..230a6c3dbebadd1 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -3448,9 +3448,9 @@ static llvm::Value *tryRemoveRetainOfSelf(CodeGenFunction &CGF, const VarDecl *self = method->getSelfDecl(); if (!self->getType().isConstQualified()) return nullptr; - // Look for a retain call. Note: stripPointerCasts looks through returned arg - // functions, which would cause us to miss the retain. - llvm::CallInst *retainCall = dyn_cast(result); + // Look for a retain call. + llvm::CallInst *retainCall = +dyn_cast(result->stripPointerCasts()); if (!retainCall || retainCall->getCalledOperand() != CGF.CGM.getObjCEntrypoints().objc_retain) return nullptr; diff --git a/clang/test/CodeGenObjC/arc.m b/clang/test/CodeGenObjC/arc.m index fb4eb3452318df5..754c339cb2b31e6 100644 --- a/clang/test/CodeGenObjC/arc.m +++ b/clang/test/CodeGenObjC/arc.m @@ -7,30 +7,30 @@ // RUN: %clang_cc1 -fobjc-runtime=macosx-10.7.0 -triple x86_64-apple-darwin11 -Wno-objc-root-class -Wno-incompatible-pointer-types -Wno-arc-unsafe-retained-assign -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -o - %s | FileCheck -check-prefix=ARC-NATIVE %s // ARC-ALIEN: declare extern_weak void @llvm.objc.storeStrong(ptr, ptr) -// ARC-ALIEN: declare extern_weak ptr @llvm.objc.retain(ptr returned) -// ARC-ALIEN: declare extern_weak ptr @llvm.objc.autoreleaseReturnValue(ptr returned) +// ARC-ALIEN: declare extern_weak ptr @llvm.objc.retain(ptr) +// ARC-ALIEN: declare extern_weak ptr @llvm.objc.autoreleaseReturnValue(ptr) // ARC-ALIEN: declare ptr @objc_msgSend(ptr, ptr, ...) [[NLB:#[0-9]+]] // ARC-ALIEN: declare extern_weak void @llvm.objc.release(ptr) -// ARC-ALIEN: declare extern_weak ptr @llvm.objc.retainAutoreleasedReturnValue(ptr returned) +// ARC-ALIEN: declare extern_weak ptr @llvm.objc.retainAutoreleasedReturnValue(ptr) // ARC-ALIEN: declare extern_weak ptr @llvm.objc.initWeak(ptr, ptr) // ARC-ALIEN: declare extern_weak ptr @llvm.objc.storeWeak(ptr, ptr) // ARC-ALIEN: declare extern_weak ptr @llvm.objc.loadWeakRetained(ptr) // ARC-ALIEN: declare extern_weak void @llvm.objc.destroyWeak(ptr) -// ARC-ALIEN: declare extern_weak ptr @llvm.objc.autorelease(ptr returned) -// ARC-ALIEN: declare extern_weak ptr @llvm.objc.retainAutorelease(ptr returned) +// ARC-ALIEN: declare extern_weak ptr @llvm.objc.autorelease(ptr) +// ARC-ALIEN: declare extern_weak ptr @llvm.objc.retainAutorelease(ptr) // ARC-NATIVE: declare void @llvm.objc.storeStrong(ptr, ptr) -// ARC-NATIVE: declare ptr @llvm.objc.retain(ptr returned) -// ARC-NATIVE: declare ptr @llvm.objc.autoreleaseReturnValue(ptr returned) +// ARC-NATIVE: declare ptr @llvm.objc.retain(ptr) +// ARC-NATIVE: declare ptr @llvm.objc.autoreleaseReturnValue(ptr) // ARC-NATIVE: declare ptr @objc_msgSend(ptr, ptr, ...) [[NLB:#[0-9]+]] // ARC-NATIVE: declare void @llvm.objc.release(ptr) -// ARC-NATIVE: declare ptr @llvm.objc.retainAutoreleasedReturnValue(ptr returned) +// ARC-NATIVE: declare ptr @llvm.objc.retainAutoreleasedReturnValue(ptr) // ARC-NATIVE: declare ptr @llvm.objc.initWeak(ptr, ptr) // ARC-NATIVE: declare ptr @llvm.objc.storeWeak(ptr, ptr) // ARC-NATIVE: declare ptr @llvm.objc.loadWeakRetained(ptr) // ARC-NATIVE: declare void @llvm.objc.destroyWeak(ptr) -// ARC-NATIVE: declare ptr @llvm.objc.autorelease(ptr returned) -// ARC-NATIVE: declare ptr @llvm.objc.retainAutorelease(ptr returned) +// ARC-NATIVE: declare ptr @llvm.objc.autorelease(ptr) +// ARC-NATIVE: declare ptr @llvm.objc.retainAutorelease(ptr) // CHECK-LABEL: define{{.*}} void @test0 void test0(id x) { diff --git a/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m b/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m index a60c9b0feb801f5..9a5ecbc03d8ae6e 100644 --- a/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m +++ b/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m @@ -28,11 +28,6 @@ void test1(id x) { // MSGS: {{call.*@objc_msgSend}}
[clang] fa71f9e - Reland "[Intrinsics][ObjC] Mark objc_retain and friends as thisreturn."
Author: Jon Roelofs Date: 2023-11-06T11:10:59-08:00 New Revision: fa71f9e87aee87c899a6ed600c1748aeb1c1a05d URL: https://github.com/llvm/llvm-project/commit/fa71f9e87aee87c899a6ed600c1748aeb1c1a05d DIFF: https://github.com/llvm/llvm-project/commit/fa71f9e87aee87c899a6ed600c1748aeb1c1a05d.diff LOG: Reland "[Intrinsics][ObjC] Mark objc_retain and friends as thisreturn." This reverts commit cb62f67088aaf79493350547f74870318b71acc5. Fixes: https://github.com/llvm/llvm-project/issues/69658 Added: Modified: clang/lib/CodeGen/CGCall.cpp clang/test/CodeGenObjC/arc.m clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m llvm/include/llvm/IR/Intrinsics.td llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp llvm/test/Transforms/PreISelIntrinsicLowering/X86/objc-arc.ll Removed: diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 230a6c3dbebadd1..e7951b3a3f4d855 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -3448,9 +3448,9 @@ static llvm::Value *tryRemoveRetainOfSelf(CodeGenFunction &CGF, const VarDecl *self = method->getSelfDecl(); if (!self->getType().isConstQualified()) return nullptr; - // Look for a retain call. - llvm::CallInst *retainCall = -dyn_cast(result->stripPointerCasts()); + // Look for a retain call. Note: stripPointerCasts looks through returned arg + // functions, which would cause us to miss the retain. + llvm::CallInst *retainCall = dyn_cast(result); if (!retainCall || retainCall->getCalledOperand() != CGF.CGM.getObjCEntrypoints().objc_retain) return nullptr; diff --git a/clang/test/CodeGenObjC/arc.m b/clang/test/CodeGenObjC/arc.m index 754c339cb2b31e6..74356d8895d144a 100644 --- a/clang/test/CodeGenObjC/arc.m +++ b/clang/test/CodeGenObjC/arc.m @@ -7,8 +7,8 @@ // RUN: %clang_cc1 -fobjc-runtime=macosx-10.7.0 -triple x86_64-apple-darwin11 -Wno-objc-root-class -Wno-incompatible-pointer-types -Wno-arc-unsafe-retained-assign -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -o - %s | FileCheck -check-prefix=ARC-NATIVE %s // ARC-ALIEN: declare extern_weak void @llvm.objc.storeStrong(ptr, ptr) -// ARC-ALIEN: declare extern_weak ptr @llvm.objc.retain(ptr) -// ARC-ALIEN: declare extern_weak ptr @llvm.objc.autoreleaseReturnValue(ptr) +// ARC-ALIEN: declare extern_weak ptr @llvm.objc.retain(ptr returned) +// ARC-ALIEN: declare extern_weak ptr @llvm.objc.autoreleaseReturnValue(ptr returned) // ARC-ALIEN: declare ptr @objc_msgSend(ptr, ptr, ...) [[NLB:#[0-9]+]] // ARC-ALIEN: declare extern_weak void @llvm.objc.release(ptr) // ARC-ALIEN: declare extern_weak ptr @llvm.objc.retainAutoreleasedReturnValue(ptr) @@ -16,12 +16,12 @@ // ARC-ALIEN: declare extern_weak ptr @llvm.objc.storeWeak(ptr, ptr) // ARC-ALIEN: declare extern_weak ptr @llvm.objc.loadWeakRetained(ptr) // ARC-ALIEN: declare extern_weak void @llvm.objc.destroyWeak(ptr) -// ARC-ALIEN: declare extern_weak ptr @llvm.objc.autorelease(ptr) -// ARC-ALIEN: declare extern_weak ptr @llvm.objc.retainAutorelease(ptr) +// ARC-ALIEN: declare extern_weak ptr @llvm.objc.autorelease(ptr returned) +// ARC-ALIEN: declare extern_weak ptr @llvm.objc.retainAutorelease(ptr returned) // ARC-NATIVE: declare void @llvm.objc.storeStrong(ptr, ptr) -// ARC-NATIVE: declare ptr @llvm.objc.retain(ptr) -// ARC-NATIVE: declare ptr @llvm.objc.autoreleaseReturnValue(ptr) +// ARC-NATIVE: declare ptr @llvm.objc.retain(ptr returned) +// ARC-NATIVE: declare ptr @llvm.objc.autoreleaseReturnValue(ptr returned) // ARC-NATIVE: declare ptr @objc_msgSend(ptr, ptr, ...) [[NLB:#[0-9]+]] // ARC-NATIVE: declare void @llvm.objc.release(ptr) // ARC-NATIVE: declare ptr @llvm.objc.retainAutoreleasedReturnValue(ptr) @@ -29,8 +29,8 @@ // ARC-NATIVE: declare ptr @llvm.objc.storeWeak(ptr, ptr) // ARC-NATIVE: declare ptr @llvm.objc.loadWeakRetained(ptr) // ARC-NATIVE: declare void @llvm.objc.destroyWeak(ptr) -// ARC-NATIVE: declare ptr @llvm.objc.autorelease(ptr) -// ARC-NATIVE: declare ptr @llvm.objc.retainAutorelease(ptr) +// ARC-NATIVE: declare ptr @llvm.objc.autorelease(ptr returned) +// ARC-NATIVE: declare ptr @llvm.objc.retainAutorelease(ptr returned) // CHECK-LABEL: define{{.*}} void @test0 void test0(id x) { diff --git a/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m b/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m index 9a5ecbc03d8ae6e..a60c9b0feb801f5 100644 --- a/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m +++ b/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m @@ -28,6 +28,11 @@ void test1(id x) { // MSGS: {{call.*@objc_msgSend}} // CALLS: {{call.*@objc_alloc}} // CALLS: {{call.*@objc_allocWithZone}} + + // Note that calls to the intrinsics are not allowed for + // retain/release/autorelease they're marked `thisreturn`, which isn't + // guaranteed to be true for cl
[clang] [clang][driver] Add \/../include/c++/v1 to include path on Darwin (PR #70817)
@@ -2494,6 +2494,19 @@ void DarwinClang::AddClangCXXStdlibIncludeArgs( << "\"\n"; } +// Check for the folder where the executable is located, if different. +if (getDriver().getInstalledDir() != getDriver().Dir) { + InstallBin = llvm::StringRef(getDriver().Dir.c_str()); jroelofs wrote: `StringRef` has a `const std::string&` constructor, so the `.c_str()` part is unnecessary. https://github.com/llvm/llvm-project/pull/70817 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][driver] Add \/../include/c++/v1 to include path on Darwin (PR #70817)
@@ -172,3 +172,20 @@ // RUN: --check-prefix=CHECK-LIBCXX-STDLIB-UNSPECIFIED %s // CHECK-LIBCXX-STDLIB-UNSPECIFIED: "-cc1" // CHECK-LIBCXX-STDLIB-UNSPECIFIED: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1" + +// Reproduce the xPack use case; there must be no include here, +// to select the executable folder. +// RUN: rm -rf %t/xpacks +// RUN: mkdir -pv %t/xpacks/.bin +// RUN: ln -svf %clang %t/xpacks/.bin/clang +// The build folders do not include this include; create it. +// RUN: mkdir -pv $(dirname $(which %clang))/../include/c++/v1 jroelofs wrote: I think it would be better to create a new temporary folder with the appropriate structure, and copy the clang binary into it, then make the symlink and FileCheck the resulting cc1 paths. Also, I don't think `ln` will work on Windows buildbots. You may need to put this test in its own file so you can add this at the top: ``` // REQUIRES: shell // UNSUPPORTED: system-windows ``` https://github.com/llvm/llvm-project/pull/70817 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][driver] Add \/../include/c++/v1 to include path on Darwin (PR #70817)
@@ -172,3 +172,20 @@ // RUN: --check-prefix=CHECK-LIBCXX-STDLIB-UNSPECIFIED %s // CHECK-LIBCXX-STDLIB-UNSPECIFIED: "-cc1" // CHECK-LIBCXX-STDLIB-UNSPECIFIED: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1" + +// Reproduce the xPack use case; there must be no include here, +// to select the executable folder. +// RUN: rm -rf %t/xpacks +// RUN: mkdir -pv %t/xpacks/.bin +// RUN: ln -svf %clang %t/xpacks/.bin/clang +// The build folders do not include this include; create it. +// RUN: mkdir -pv $(dirname $(which %clang))/../include/c++/v1 jroelofs wrote: > Isn't this enough? Sorry, missed that. Yes, it is. > Is this solution used by other tests? Not that I'm aware of. I don't know of any other tests that need Dir != InstalledDir either. > What if the binary is built with weird RPATH definitions? Good point. https://github.com/llvm/llvm-project/pull/70817 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [llvm] [AArch64][Clang] Fix linker error for function multiversioning (PR #74358)
@@ -4178,8 +4184,22 @@ void CodeGenModule::emitMultiVersionFunctions() { } llvm::Constant *ResolverConstant = GetOrCreateMultiVersionResolver(GD); -if (auto *IFunc = dyn_cast(ResolverConstant)) +if (auto *IFunc = dyn_cast(ResolverConstant)) { ResolverConstant = IFunc->getResolver(); + if (FD->isTargetClonesMultiVersion()) { +const CGFunctionInfo &FI = getTypes().arrangeGlobalDeclaration(GD); +llvm::FunctionType *DeclTy = getTypes().GetFunctionType(FI); +std::string MangledName = getMangledNameImpl( +*this, GD, FD, /*OmitMultiVersionMangling=*/true); +// In prior versions of Clang, the mangling for ifuncs incorrectly +// included an .ifunc suffix. This alias is generated for backward +// compatibility and should be deprecated in the future. jroelofs wrote: ```suggestion // included an .ifunc suffix. This alias is generated for backward // compatibility. It is deprecated, and may be removed in the future. ``` https://github.com/llvm/llvm-project/pull/74358 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Mark -arch as TargetSpecific (PR #74365)
https://github.com/jroelofs approved this pull request. https://github.com/llvm/llvm-project/pull/74365 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang-tools-extra] [clang] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 1/9] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d9..cb222e979db29 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79c..48fa6c478464c 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b14312896..e0080b145d4f9 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee..94e76a43bf38d 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector arguments re
[clang-tools-extra] [llvm] [clang] [llvm] Support IFuncs on Darwin platforms (PR #73686)
jroelofs wrote: ping https://github.com/llvm/llvm-project/pull/73686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [clang-tools-extra] [llvm] Support IFuncs on Darwin platforms (PR #73686)
@@ -1809,6 +1814,255 @@ void AArch64AsmPrinter::emitInstruction(const MachineInstr *MI) { EmitToStreamer(*OutStreamer, TmpInst); } +void AArch64AsmPrinter::emitGlobalIFunc(Module &M, const GlobalIFunc &GI) { + if (!TM.getTargetTriple().isOSBinFormatMachO()) +return AsmPrinter::emitGlobalIFunc(M, GI); jroelofs wrote: Sounds good, I like that. https://github.com/llvm/llvm-project/pull/73686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] [llvm] [clang] [clang-tools-extra] [compiler-rt] [mlir] [libc] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 1/9] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d9..cb222e979db29 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79c..48fa6c478464c 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b14312896..e0080b145d4f9 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee..94e76a43bf38d 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector arguments re
[compiler-rt] [lldb] [libcxxabi] [clang-tools-extra] [libcxx] [mlir] [libc] [llvm] [clang] [lld] [flang] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 1/9] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d9..cb222e979db29 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79c..48fa6c478464c 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b14312896..e0080b145d4f9 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee..94e76a43bf38d 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector arguments re
[libc] [lld] [libcxxabi] [clang-tools-extra] [llvm] [clang] [flang] [compiler-rt] [lldb] [libcxx] [mlir] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 1/9] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d9..cb222e979db29 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79c..48fa6c478464c 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b14312896..e0080b145d4f9 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee..94e76a43bf38d 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector arguments re
[compiler-rt] [lldb] [libc] [clang] [lld] [mlir] [llvm] [libcxxabi] [clang-tools-extra] [flang] [libcxx] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 1/9] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d9..cb222e979db29 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79c..48fa6c478464c 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b14312896..e0080b145d4f9 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee..94e76a43bf38d 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector arguments re
[clang] [lld] [clang-tools-extra] [lldb] [libcxxabi] [mlir] [compiler-rt] [libc] [openmp] [llvm] [libcxx] [flang] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 1/9] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d9..cb222e979db29 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79c..48fa6c478464c 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b14312896..e0080b145d4f9 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee..94e76a43bf38d 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector arguments re
[clang] [clang][PP] Add extension to predefine target OS macros (PR #74676)
@@ -1344,6 +1344,15 @@ static void InitializePredefinedMacros(const TargetInfo &TI, if (TI.getTriple().isOSBinFormatELF()) Builder.defineMacro("__ELF__"); + // Target OS macro definitions. + if (PPOpts.DefineTargetOSMacros) { +const llvm::Triple &Triple = TI.getTriple(); +#define TARGET_OS(Name, Predicate) \ + Builder.defineMacro(#Name, Predicate ? "1" : "0"); jroelofs wrote: `Predicate` should be in parens to make the precedence explicit in the face of preprocessor expansion. https://github.com/llvm/llvm-project/pull/74676 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][PP] Add extension to predefine target OS macros (PR #74676)
@@ -0,0 +1,131 @@ +// RUN: %clang -### --target=arm64-apple-darwin %s 2>&1 | FileCheck %s --check-prefix=DEFAULT-OPTION + +// RUN: %clang -dM -E --target=arm64-apple-macos %s 2>&1 \ +// RUN: | FileCheck %s -DMAC=1 \ +// RUN:-DOSX=1 \ +// RUN:-DIPHONE=0 \ +// RUN:-DIOS=0 \ +// RUN:-DTV=0 \ +// RUN:-DWATCH=0 \ +// RUN:-DDRIVERKIT=0 \ +// RUN:-DMACCATALYST=0 \ +// RUN:-DEMBEDDED=0\ +// RUN:-DSIMULATOR=0 + +// RUN: %clang -dM -E --target=arm64-apple-ios %s 2>&1 \ +// RUN: | FileCheck %s -DMAC=1 \ +// RUN:-DOSX=0 \ +// RUN:-DIPHONE=1 \ +// RUN:-DIOS=1 \ +// RUN:-DTV=0 \ +// RUN:-DWATCH=0 \ +// RUN:-DDRIVERKIT=0 \ +// RUN:-DMACCATALYST=0 \ +// RUN:-DEMBEDDED=1\ +// RUN:-DSIMULATOR=0 + +// RUN: %clang -dM -E --target=arm64-apple-ios-macabi %s 2>&1 \ +// RUN: | FileCheck %s -DMAC=1 \ +// RUN:-DOSX=0 \ +// RUN:-DIPHONE=1 \ +// RUN:-DIOS=1 \ +// RUN:-DTV=0 \ +// RUN:-DWATCH=0 \ +// RUN:-DDRIVERKIT=0 \ +// RUN:-DMACCATALYST=1 \ +// RUN:-DEMBEDDED=0\ +// RUN:-DSIMULATOR=0 + +// RUN: %clang -dM -E --target=arm64-apple-ios-simulator %s 2>&1 \ +// RUN: | FileCheck %s -DMAC=1 \ +// RUN:-DOSX=0 \ +// RUN:-DIPHONE=1 \ +// RUN:-DIOS=1 \ +// RUN:-DTV=0 \ +// RUN:-DWATCH=0 \ +// RUN:-DDRIVERKIT=0 \ +// RUN:-DMACCATALYST=0 \ +// RUN:-DEMBEDDED=0\ +// RUN:-DSIMULATOR=1 + +// RUN: %clang -dM -E --target=arm64-apple-tvos %s 2>&1 \ +// RUN: | FileCheck %s -DMAC=1 \ +// RUN:-DOSX=0 \ +// RUN:-DIPHONE=1 \ +// RUN:-DIOS=0 \ +// RUN:-DTV=1 \ +// RUN:-DWATCH=0 \ +// RUN:-DDRIVERKIT=0 \ +// RUN:-DMACCATALYST=0 \ +// RUN:-DEMBEDDED=1\ +// RUN:-DSIMULATOR=0 + +// RUN: %clang -dM -E --target=arm64-apple-tvos-simulator %s 2>&1 \ +// RUN: | FileCheck %s -DMAC=1 \ +// RUN:-DOSX=0 \ +// RUN:-DIPHONE=1 \ +// RUN:-DIOS=0 \ +// RUN:-DTV=1 \ +// RUN:-DWATCH=0 \ +// RUN:-DDRIVERKIT=0 \ +// RUN:-DMACCATALYST=0 \ +// RUN:-DEMBEDDED=0\ +// RUN:-DSIMULATOR=1 + +// RUN: %clang -dM -E --target=arm64-apple-watchos %s 2>&1 \ +// RUN: | FileCheck %s -DMAC=1 \ +// RUN:-DOSX=0 \ +// RUN:-DIPHONE=1 \ +// RUN:-DIOS=0 \ +// RUN:-DTV=0 \ +// RUN:-DWATCH=1 \ +// RUN:-DDRIVERKIT=0 \ +// RUN:-DMACCATALYST=0 \ +// RUN:-DEMBEDDED=1\ +// RUN:-DSIMULATOR=0 + +// RUN: %clang -dM -E --target=arm64-apple-watchos-simulator %s 2>&1 \ +// RUN: | FileCheck %s -DMAC=1 \ +// RUN:-DOSX=0 \ +// RUN:-DIPHONE=1 \ +// RUN:-DIOS=0 \ +// RUN:-DTV=0 \ +// RUN:-DWATCH=1 \ +// RUN:-DDRIVERKIT=0 \ +// RUN:-DMACCATALYST=0 \ +// RUN:-DEMBEDDED=0\ +// RUN:-DSIMULATOR=1 + +// RUN: %clang -dM -E --target=arm64-apple-driverkit %s 2>&1 \ +// RUN: | FileCheck %s -DMAC=1 \ +// RUN:-DOSX=0 \ +// RUN:-DIPHONE=0 \ +// RUN:-DIOS=0 \ +// RUN:-DTV=0 \ +// RUN:-DWATCH=0 \ +// RUN:-DDRIVERKIT=1 \ +// RUN:-DMACCATALYST=0 \ +// RUN:-DEMBEDDED=0\ +// RUN:-DSIMULATOR=0 jroelofs wrote: TIL FileCheck can do `-D`... neat! https://github.com/llvm/llvm-project/pull/74676 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][PP] Add extension to predefine target OS macros (PR #74676)
@@ -0,0 +1,131 @@ +// RUN: %clang -### --target=arm64-apple-darwin %s 2>&1 | FileCheck %s --check-prefix=DEFAULT-OPTION + +// RUN: %clang -dM -E --target=arm64-apple-macos %s 2>&1 \ +// RUN: | FileCheck %s -DMAC=1 \ +// RUN:-DOSX=1 \ +// RUN:-DIPHONE=0 \ +// RUN:-DIOS=0 \ +// RUN:-DTV=0 \ +// RUN:-DWATCH=0 \ +// RUN:-DDRIVERKIT=0 \ +// RUN:-DMACCATALYST=0 \ +// RUN:-DEMBEDDED=0\ +// RUN:-DSIMULATOR=0 + +// RUN: %clang -dM -E --target=arm64-apple-ios %s 2>&1 \ +// RUN: | FileCheck %s -DMAC=1 \ +// RUN:-DOSX=0 \ +// RUN:-DIPHONE=1 \ +// RUN:-DIOS=1 \ +// RUN:-DTV=0 \ +// RUN:-DWATCH=0 \ +// RUN:-DDRIVERKIT=0 \ +// RUN:-DMACCATALYST=0 \ +// RUN:-DEMBEDDED=1\ +// RUN:-DSIMULATOR=0 + +// RUN: %clang -dM -E --target=arm64-apple-ios-macabi %s 2>&1 \ +// RUN: | FileCheck %s -DMAC=1 \ +// RUN:-DOSX=0 \ +// RUN:-DIPHONE=1 \ +// RUN:-DIOS=1 \ +// RUN:-DTV=0 \ +// RUN:-DWATCH=0 \ +// RUN:-DDRIVERKIT=0 \ +// RUN:-DMACCATALYST=1 \ +// RUN:-DEMBEDDED=0\ +// RUN:-DSIMULATOR=0 + +// RUN: %clang -dM -E --target=arm64-apple-ios-simulator %s 2>&1 \ +// RUN: | FileCheck %s -DMAC=1 \ +// RUN:-DOSX=0 \ +// RUN:-DIPHONE=1 \ +// RUN:-DIOS=1 \ +// RUN:-DTV=0 \ +// RUN:-DWATCH=0 \ +// RUN:-DDRIVERKIT=0 \ +// RUN:-DMACCATALYST=0 \ +// RUN:-DEMBEDDED=0\ +// RUN:-DSIMULATOR=1 + +// RUN: %clang -dM -E --target=arm64-apple-tvos %s 2>&1 \ +// RUN: | FileCheck %s -DMAC=1 \ +// RUN:-DOSX=0 \ +// RUN:-DIPHONE=1 \ +// RUN:-DIOS=0 \ +// RUN:-DTV=1 \ +// RUN:-DWATCH=0 \ +// RUN:-DDRIVERKIT=0 \ +// RUN:-DMACCATALYST=0 \ +// RUN:-DEMBEDDED=1\ +// RUN:-DSIMULATOR=0 + +// RUN: %clang -dM -E --target=arm64-apple-tvos-simulator %s 2>&1 \ +// RUN: | FileCheck %s -DMAC=1 \ +// RUN:-DOSX=0 \ +// RUN:-DIPHONE=1 \ +// RUN:-DIOS=0 \ +// RUN:-DTV=1 \ +// RUN:-DWATCH=0 \ +// RUN:-DDRIVERKIT=0 \ +// RUN:-DMACCATALYST=0 \ +// RUN:-DEMBEDDED=0\ +// RUN:-DSIMULATOR=1 + +// RUN: %clang -dM -E --target=arm64-apple-watchos %s 2>&1 \ +// RUN: | FileCheck %s -DMAC=1 \ +// RUN:-DOSX=0 \ +// RUN:-DIPHONE=1 \ +// RUN:-DIOS=0 \ +// RUN:-DTV=0 \ +// RUN:-DWATCH=1 \ +// RUN:-DDRIVERKIT=0 \ +// RUN:-DMACCATALYST=0 \ +// RUN:-DEMBEDDED=1\ +// RUN:-DSIMULATOR=0 + +// RUN: %clang -dM -E --target=arm64-apple-watchos-simulator %s 2>&1 \ +// RUN: | FileCheck %s -DMAC=1 \ +// RUN:-DOSX=0 \ +// RUN:-DIPHONE=1 \ +// RUN:-DIOS=0 \ +// RUN:-DTV=0 \ +// RUN:-DWATCH=1 \ +// RUN:-DDRIVERKIT=0 \ +// RUN:-DMACCATALYST=0 \ +// RUN:-DEMBEDDED=0\ +// RUN:-DSIMULATOR=1 + +// RUN: %clang -dM -E --target=arm64-apple-driverkit %s 2>&1 \ +// RUN: | FileCheck %s -DMAC=1 \ +// RUN:-DOSX=0 \ +// RUN:-DIPHONE=0 \ +// RUN:-DIOS=0 \ +// RUN:-DTV=0 \ +// RUN:-DWATCH=0 \ +// RUN:-DDRIVERKIT=1 \ +// RUN:-DMACCATALYST=0 \ +// RUN:-DEMBEDDED=0\ +// RUN:-DSIMULATOR=0 + +// DEFAULT-OPTION: "-fdefine-target-os-macros" + +// CHECK-DAG: #define TARGET_OS_MAC [[MAC]] +// CHECK-DAG: #define TARGET_OS_OSX [[OSX]] +// CHECK-DAG: #define TARGET_OS_IPHONE [[IPHONE]] +// CHECK-DAG: #define TARGET_OS_IOS [[IOS]] +// CHECK-DAG: #define TARGET_OS_TV [[TV]] +// CHECK-DAG: #define TARGET_OS_WATCH [[WATCH]] +// CHECK-DAG: #define TARGET_OS_DRIVERKIT [[DRIVERKIT]] +// CHECK-DAG: #define TARGET_OS_MACCATALYST [[MACCATALYST]] +// CHECK-DAG: #define TARGET_OS_SIMULATOR [[SIMULATOR]] +// Deprecated +
[clang] [NFC] Remove unneeded nullptr checks after cast<> (PR #74674)
https://github.com/jroelofs approved this pull request. https://github.com/llvm/llvm-project/pull/74674 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][PP] Add extension to predefine target OS macros (PR #74676)
https://github.com/jroelofs approved this pull request. https://github.com/llvm/llvm-project/pull/74676 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Fix] Disable fdefine-target-os-macros for now (PR #74886)
https://github.com/jroelofs approved this pull request. https://github.com/llvm/llvm-project/pull/74886 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [llvm] [lld] [libcxxabi] [libc] [lldb] [openmp] [compiler-rt] [libcxx] [clang-tools-extra] [mlir] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 01/10] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?= =?UTF-8?q?initial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d9..cb222e979db29 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79c..48fa6c478464c 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b14312896..e0080b145d4f9 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee..94e76a43bf38d 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector arguments
[clang-tools-extra] [compiler-rt] [clang] [flang] [libc] [lld] [openmp] [mlir] [lldb] [libcxxabi] [llvm] [libcxx] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 01/10] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?= =?UTF-8?q?initial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d9..cb222e979db29 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79c..48fa6c478464c 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b14312896..e0080b145d4f9 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee..94e76a43bf38d 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector arguments
[lld] [llvm] [mlir] [lldb] [flang] [clang] [openmp] [clang-tools-extra] [libcxx] [libcxxabi] [compiler-rt] [libc] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 01/11] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?= =?UTF-8?q?initial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d94..cb222e979db29d 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79cb..48fa6c478464c7 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b143128967..e0080b145d4f99 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee6..94e76a43bf38d6 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector ar
[llvm] [clang-tools-extra] [libcxx] [flang] [lld] [openmp] [lldb] [libcxxabi] [compiler-rt] [mlir] [clang] [libc] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 01/11] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?= =?UTF-8?q?initial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d94..cb222e979db29d 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79cb..48fa6c478464c7 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b143128967..e0080b145d4f99 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee6..94e76a43bf38d6 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector ar
[clang] [clang][NFC] Assert not llvm_unreachable (PR #70149)
https://github.com/jroelofs approved this pull request. https://github.com/llvm/llvm-project/pull/70149 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [LLVM][AArch64] Add ASM constraints for reduced GPR register ranges. (PR #70970)
@@ -1306,6 +1306,12 @@ bool AArch64TargetInfo::validateAsmConstraint( Name += 2; return true; } +if (Name[1] == 'c' && (Name[2] == 'i' || Name[2] == 'j')) { + // Gpr registers ("Uci"=w8-11, "Upj"=w12-15) jroelofs wrote: `s/Upj/Ucj/` ? https://github.com/llvm/llvm-project/pull/70970 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][driver] Add \/../include/c++/v1 to include path on Darwin (PR #70817)
jroelofs wrote: > In my use case, and probably in most use cases, the location where the link > comes from is a plain folder, not a hierarchy specific to a toolchain. I would have expected the opposite. Most non-windows clang toolchains that I know of typically ship `clang` and `clang++` as symlinks to a single binary named `clang-${version}`, all of which are located in the typical bin-next-to-lib toolchain folder structure. Darwin toolchains are a _little_ weird, since we don't ship libc++ & co. in `bin/../{lib,include}`, and instead those go in an "SDK" (much like a "sysroot" on other platforms). As an aside, there is also driver mode selection logic that depends heavily on the specific names of these symlinks, e.g. for C vs C++ mode, clang-cl mode, and/or cross-compiling to a specific target when prefixed with the target triple e.g. `arm-none-eabi-clang -> clang`. Don't consider this an objection, but: for your use case, can you stick symlinks in to preserve that toolchain folder structure relative to the `~/tmp/clang++` symlink? i.e. make that `~/tmp/bin/clang++ -> /Users/ilg/Library/xPacks/@xpack-dev-tools/clang/15.0.7-3.1/.content/bin/clang-15` and add `~/tmp/lib -> /Users/ilg/Library/xPacks/@xpack-dev-tools/clang/15.0.7-3.1/.content/lib` (and same for `include`). https://github.com/llvm/llvm-project/pull/70817 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][driver] Add \/../include/c++/v1 to include path on Darwin (PR #70817)
jroelofs wrote: > changing the structure of the symlinks is not possible, it is done > automatically by a tool. To be fair: tools can be changed, and in fact you're proposing to change one ;) But that said, now I see what you're up against. https://github.com/llvm/llvm-project/pull/70817 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][driver] Add \/../include/c++/v1 to include path on Darwin (PR #70817)
jroelofs wrote: > Can you clearly state why you are against this PR? You don't consider the > current behaviour of silently using the wrong headers a bug, or the proposed > solution is not correct? >> Don't consider this an objection I am not against it; I just wanted to talk through all the options. https://github.com/llvm/llvm-project/pull/70817 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][AArch64] Add ASM constraints for reduced GPR register ranges. (PR #70970)
https://github.com/jroelofs approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/70970 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[mlir] [openmp] [flang] [libc] [clang-tools-extra] [llvm] [lldb] [lld] [libcxxabi] [compiler-rt] [libcxx] [clang] [llvm] Support IFuncs on Darwin platforms (PR #73686)
jroelofs wrote: ping https://github.com/llvm/llvm-project/pull/73686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [libcxx] [lldb] [libc] [openmp] [clang-tools-extra] [compiler-rt] [flang] [libcxxabi] [lld] [mlir] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 01/11] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?= =?UTF-8?q?initial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d94..cb222e979db29d 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79cb..48fa6c478464c7 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b143128967..e0080b145d4f99 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee6..94e76a43bf38d6 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector ar
[lldb] [libc] [mlir] [llvm] [clang] [lld] [compiler-rt] [flang] [openmp] [clang-tools-extra] [libcxxabi] [libcxx] [llvm] Support IFuncs on Darwin platforms (PR #73686)
@@ -2169,8 +2169,11 @@ void AsmPrinter::emitGlobalIFunc(Module &M, const GlobalIFunc &GI) { MCSymbol *LocalAlias = getSymbolPreferLocal(GI); if (LocalAlias != Name) OutStreamer->emitAssignment(LocalAlias, Expr); - } else if (TM.getTargetTriple().isOSBinFormatMachO() && - getIFuncMCSubtargetInfo()) { + +return; + } + + if (TM.getTargetTriple().isOSBinFormatMachO() && getIFuncMCSubtargetInfo()) { jroelofs wrote: oh, I see. sure. https://github.com/llvm/llvm-project/pull/73686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[mlir] [compiler-rt] [clang] [lld] [lldb] [clang-tools-extra] [llvm] [libcxx] [openmp] [libcxxabi] [libc] [flang] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 01/11] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?= =?UTF-8?q?initial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d94..cb222e979db29d 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79cb..48fa6c478464c7 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b143128967..e0080b145d4f99 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee6..94e76a43bf38d6 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector ar
[flang] [libcxxabi] [libcxx] [clang-tools-extra] [llvm] [lld] [compiler-rt] [mlir] [openmp] [libc] [clang] [lldb] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73686 >From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 28 Nov 2023 10:39:44 -0800 Subject: [PATCH 01/11] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?= =?UTF-8?q?initial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- llvm/docs/LangRef.rst | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h| 6 +- llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 7 +- llvm/lib/IR/Verifier.cpp | 12 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 28 ++ llvm/lib/Target/X86/X86AsmPrinter.h | 1 + .../AArch64/GlobalISel/call-lowering-ifunc.ll | 37 +++ llvm/test/CodeGen/AArch64/addrsig-macho.ll| 4 +- llvm/test/CodeGen/AArch64/ifunc-asm.ll| 82 + llvm/test/CodeGen/X86/ifunc-asm.ll| 28 +- llvm/test/Verifier/ifunc-macho.ll | 42 +++ 12 files changed, 539 insertions(+), 23 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll create mode 100644 llvm/test/Verifier/ifunc-macho.ll diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index e448c5ed5c5d94..cb222e979db29d 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -934,10 +934,11 @@ IFuncs --- IFuncs, like as aliases, don't create any new data or func. They are just a new -symbol that dynamic linker resolves at runtime by calling a resolver function. +symbol that is resolved at runtime by calling a resolver function. -IFuncs have a name and a resolver that is a function called by dynamic linker -that returns address of another function associated with the name. +On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On +MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional :ref:`visibility style `. diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 2731ef452c79cb..48fa6c478464c7 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass { GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S); void emitGlobalAlias(Module &M, const GlobalAlias &GA); - void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +protected: + virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI); + +private: /// This method decides whether the specified basic block requires a label. bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const; diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 2527b143128967..e0080b145d4f99 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB, // Try looking through a bitcast from one function type to another. // Commonly happens with calls to objc_msgSend(). const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts(); - if (const Function *F = dyn_cast(CalleeV)) + if (const GlobalIFunc *IF = dyn_cast(CalleeV); + IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) { +// ld64 requires that .symbol_resolvers to be called via a stub, so these +// must always be a diret call. +Info.Callee = MachineOperand::CreateGA(IF, 0); + } else if (const Function *F = dyn_cast(CalleeV)) Info.Callee = MachineOperand::CreateGA(F, 0); else Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5560c037aa3ee6..94e76a43bf38d6 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { GlobalIFunc::getResolverFunctionType(GI.getValueType()); Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()), "IFunc resolver has incorrect type", &GI); + } void Verifier::visitNamedMDNode(const NamedMDNode &NMD) { @@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs, } // Check EVEX512 feature. - if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) { -Triple T(M.getTargetTriple()); -if (T.isX86()) { - StringRef TF = Attrs.getFnAttr("target-features").getValueAsString(); - Check(!TF.contains("+avx512f") || !TF.contains("-evex512"), -"512-bit vector ar
[lldb] [clang-tools-extra] [mlir] [lld] [libcxxabi] [libc] [libcxx] [compiler-rt] [openmp] [flang] [clang] [llvm] [llvm] Support IFuncs on Darwin platforms (PR #73686)
https://github.com/jroelofs closed https://github.com/llvm/llvm-project/pull/73686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[lldb] [clang-tools-extra] [mlir] [lld] [libcxxabi] [libc] [libcxx] [compiler-rt] [openmp] [flang] [clang] [llvm] [clang] Support __attribute__((ifunc(...))) on Darwin platforms (PR #73687)
https://github.com/jroelofs edited https://github.com/llvm/llvm-project/pull/73687 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [lldb] [llvm] [openmp] [libcxx] [mlir] [compiler-rt] [libcxxabi] [libc] [lld] [clang-tools-extra] [clang] [clang] Support __attribute__((ifunc(...))) on Darwin platforms (PR #73687)
https://github.com/jroelofs closed https://github.com/llvm/llvm-project/pull/73687 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[lldb] [clang-tools-extra] [mlir] [lld] [libcxxabi] [libc] [libcxx] [compiler-rt] [openmp] [flang] [clang] [llvm] [clang] Function Multi Versioning supports IFunc lowerings on Darwin platforms (PR #73
https://github.com/jroelofs edited https://github.com/llvm/llvm-project/pull/73688 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [libcxxabi] [libc] [mlir] [lld] [openmp] [lldb] [clang-tools-extra] [compiler-rt] [clang] [flang] [libcxx] [clang] Function Multi Versioning supports IFunc lowerings on Darwin platforms (PR #73
https://github.com/jroelofs closed https://github.com/llvm/llvm-project/pull/73688 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[compiler-rt] [flang] [clang] [llvm] [lldb] [openmp] [mlir] [clang-tools-extra] [libc] [GlobalISel] Always direct-call IFuncs and Aliases (PR #74902)
https://github.com/jroelofs edited https://github.com/llvm/llvm-project/pull/74902 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[compiler-rt] [flang] [llvm] [clang-tools-extra] [lld] [clang] [libcxx] [lldb] [openmp] [libcxxabi] [mlir] [libc] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms (PR #73685)
https://github.com/jroelofs edited https://github.com/llvm/llvm-project/pull/73685 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [libcxxabi] [libc] [mlir] [lld] [openmp] [lldb] [clang-tools-extra] [compiler-rt] [clang] [flang] [libcxx] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms (PR #73685)
https://github.com/jroelofs closed https://github.com/llvm/llvm-project/pull/73685 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [libc] [mlir] [openmp] [lldb] [clang-tools-extra] [compiler-rt] [clang] [flang] [GlobalISel] Always direct-call IFuncs and Aliases (PR #74902)
https://github.com/jroelofs closed https://github.com/llvm/llvm-project/pull/74902 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] [libcxxabi] [lldb] [openmp] [clang] [mlir] [lld] [llvm] [clang-tools-extra] [compiler-rt] [flang] [libc] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms (PR #73685)
jroelofs wrote: Sorry about that... thanks! https://github.com/llvm/llvm-project/pull/73685 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[lld] [llvm] [libcxxabi] [compiler-rt] [libc] [openmp] [mlir] [clang-tools-extra] [clang] [lldb] [libcxx] [flang] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms (PR #73685)
jroelofs wrote: > BTW, when compiling the file I also get a bunch of warnings in this style: @mstorsjo maybe `unsigned long` is 32 bits on that platform... what's the target triple? https://github.com/llvm/llvm-project/pull/73685 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [libcxxabi] [llvm] [flang] [clang-tools-extra] [openmp] [compiler-rt] [lldb] [libc] [libcxx] [mlir] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms (PR #73685)
jroelofs wrote: > this file suffers from a pretty deep ifdef nesting jungle, so I'm not sure if > that's the best solution I'll refactor, and put up a new PR. https://github.com/llvm/llvm-project/pull/73685 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang-tools-extra] [clang] [flang] [compiler-rt] [lld] [libcxxabi] [libc] [lldb] [openmp] [mlir] [libcxx] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms (PR #73685)
jroelofs wrote: https://github.com/llvm/llvm-project/pull/75635 https://github.com/llvm/llvm-project/pull/73685 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [lldb] [clang-tools-extra] [lld] [libcxx] [libcxxabi] [mlir] [flang] [clang] [openmp] [libc] [compiler-rt] [builtins][arm64] Build __init_cpu_features_resolver on Apple platforms (PR #73685)
jroelofs wrote: Refactor here: https://github.com/llvm/llvm-project/pull/75635 https://github.com/llvm/llvm-project/pull/73685 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[compiler-rt] [libcxx] [flang] [clang] [lld] [lldb] [mlir] [llvm] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/75635 >From 336d1629f38a8681038f026c599a256761b522dc Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Fri, 15 Dec 2023 11:13:30 -0700 Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- compiler-rt/lib/builtins/CMakeLists.txt | 4 +- compiler-rt/lib/builtins/cpu_model/aarch64.c | 142 + .../cpu_model/aarch64/fmv/android.inc | 35 + .../cpu_model/aarch64/fmv/freebsd.inc | 27 + .../builtins/cpu_model/aarch64/fmv/fucsia.inc | 19 + .../builtins/cpu_model/aarch64/fmv/mrs.inc| 375 +++ .../cpu_model/aarch64/fmv/sysauxv.inc | 17 + .../cpu_model/aarch64/fmv/unimplemented.inc | 11 + .../cpu_model/aarch64/lse_atomics/android.inc | 28 + .../cpu_model/aarch64/lse_atomics/freebsd.inc | 5 + .../cpu_model/aarch64/lse_atomics/fucsia.inc | 12 + .../cpu_model/aarch64/lse_atomics/sysauxv.inc | 6 + .../lib/builtins/cpu_model/cpu_model.h| 41 ++ .../builtins/{cpu_model.c => cpu_model/x86.c} | 600 +- 14 files changed, 729 insertions(+), 593 deletions(-) create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64.c create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/mrs.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/unimplemented.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/cpu_model.h rename compiler-rt/lib/builtins/{cpu_model.c => cpu_model/x86.c} (60%) diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index ea72c595a9b807..e5b52db175d960 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -271,7 +271,7 @@ endif() # These files are used on 32-bit and 64-bit x86. set(x86_ARCH_SOURCES - cpu_model.c + cpu_model/x86.c ) if (NOT MSVC) @@ -556,7 +556,7 @@ endif() set(aarch64_SOURCES ${GENERIC_TF_SOURCES} ${GENERIC_SOURCES} - cpu_model.c + cpu_model/aarch64.c aarch64/fp_mode.c ) diff --git a/compiler-rt/lib/builtins/cpu_model/aarch64.c b/compiler-rt/lib/builtins/cpu_model/aarch64.c new file mode 100644 index 00..98b0c4433d01a1 --- /dev/null +++ b/compiler-rt/lib/builtins/cpu_model/aarch64.c @@ -0,0 +1,142 @@ +//===-- cpu_model_aarch64.c - Support for __cpu_model builtin *- C -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file is based on LLVM's lib/Support/Host.cpp. +// It implements __aarch64_have_lse_atomics, __aarch64_cpu_features for AArch64. +// +//===--===// + +#include "cpu_model.h" + +#if !defined(__aarch64__) +# error This file is intended only for aarch64-based targets +#endif + + +#if __has_include() +#include +#else +typedef struct __ifunc_arg_t { + unsigned long _size; + unsigned long _hwcap; + unsigned long _hwcap2; +} __ifunc_arg_t; +#endif // __has_include() + + +// LSE support detection for out-of-line atomics +// using HWCAP and Auxiliary vector +_Bool __aarch64_have_lse_atomics +__attribute__((visibility("hidden"), nocommon)) = false; + +#if defined(__FreeBSD__) +# include "lse_atomics/freebsd.inc" +#elif defined(__Fucsia__) +# include "lse_atomics/fucsia.inc" +#elif defined(__ANDROID__) +# include "lse_atomics/android.inc" +#elif __has_include() +# include "lse_atomics/sysauxv.inc" +#else +// When unimplemented, we leave __aarch64_have_lse_atomics initialized to false. +#endif + + +#if !defined(DISABLE_AARCH64_FMV) +// CPUFeatures must correspond to the same AArch64 features in +// AArch64TargetParser.h +enum CPUFeatures { + FEAT_RNG, + FEAT_FLAGM, + FEAT_FLAGM2, + FEAT_FP16FML, + FEAT_DOTPROD, + FEAT_SM4, + FEAT_RDM, + FEAT_LSE, + FEAT_FP, + FEAT_SIMD, + FEAT_CRC, + FEAT_SHA1, + FEAT_SHA2, + FEAT_SHA3, + FEAT_AES, + FEAT_PMULL, + FEAT_FP16, + FEAT_DIT
[compiler-rt] [lldb] [llvm] [mlir] [lld] [flang] [clang] [libcxx] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/75635 >From 336d1629f38a8681038f026c599a256761b522dc Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Fri, 15 Dec 2023 11:13:30 -0700 Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- compiler-rt/lib/builtins/CMakeLists.txt | 4 +- compiler-rt/lib/builtins/cpu_model/aarch64.c | 142 + .../cpu_model/aarch64/fmv/android.inc | 35 + .../cpu_model/aarch64/fmv/freebsd.inc | 27 + .../builtins/cpu_model/aarch64/fmv/fucsia.inc | 19 + .../builtins/cpu_model/aarch64/fmv/mrs.inc| 375 +++ .../cpu_model/aarch64/fmv/sysauxv.inc | 17 + .../cpu_model/aarch64/fmv/unimplemented.inc | 11 + .../cpu_model/aarch64/lse_atomics/android.inc | 28 + .../cpu_model/aarch64/lse_atomics/freebsd.inc | 5 + .../cpu_model/aarch64/lse_atomics/fucsia.inc | 12 + .../cpu_model/aarch64/lse_atomics/sysauxv.inc | 6 + .../lib/builtins/cpu_model/cpu_model.h| 41 ++ .../builtins/{cpu_model.c => cpu_model/x86.c} | 600 +- 14 files changed, 729 insertions(+), 593 deletions(-) create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64.c create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/mrs.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/unimplemented.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/cpu_model.h rename compiler-rt/lib/builtins/{cpu_model.c => cpu_model/x86.c} (60%) diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index ea72c595a9b807..e5b52db175d960 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -271,7 +271,7 @@ endif() # These files are used on 32-bit and 64-bit x86. set(x86_ARCH_SOURCES - cpu_model.c + cpu_model/x86.c ) if (NOT MSVC) @@ -556,7 +556,7 @@ endif() set(aarch64_SOURCES ${GENERIC_TF_SOURCES} ${GENERIC_SOURCES} - cpu_model.c + cpu_model/aarch64.c aarch64/fp_mode.c ) diff --git a/compiler-rt/lib/builtins/cpu_model/aarch64.c b/compiler-rt/lib/builtins/cpu_model/aarch64.c new file mode 100644 index 00..98b0c4433d01a1 --- /dev/null +++ b/compiler-rt/lib/builtins/cpu_model/aarch64.c @@ -0,0 +1,142 @@ +//===-- cpu_model_aarch64.c - Support for __cpu_model builtin *- C -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file is based on LLVM's lib/Support/Host.cpp. +// It implements __aarch64_have_lse_atomics, __aarch64_cpu_features for AArch64. +// +//===--===// + +#include "cpu_model.h" + +#if !defined(__aarch64__) +# error This file is intended only for aarch64-based targets +#endif + + +#if __has_include() +#include +#else +typedef struct __ifunc_arg_t { + unsigned long _size; + unsigned long _hwcap; + unsigned long _hwcap2; +} __ifunc_arg_t; +#endif // __has_include() + + +// LSE support detection for out-of-line atomics +// using HWCAP and Auxiliary vector +_Bool __aarch64_have_lse_atomics +__attribute__((visibility("hidden"), nocommon)) = false; + +#if defined(__FreeBSD__) +# include "lse_atomics/freebsd.inc" +#elif defined(__Fucsia__) +# include "lse_atomics/fucsia.inc" +#elif defined(__ANDROID__) +# include "lse_atomics/android.inc" +#elif __has_include() +# include "lse_atomics/sysauxv.inc" +#else +// When unimplemented, we leave __aarch64_have_lse_atomics initialized to false. +#endif + + +#if !defined(DISABLE_AARCH64_FMV) +// CPUFeatures must correspond to the same AArch64 features in +// AArch64TargetParser.h +enum CPUFeatures { + FEAT_RNG, + FEAT_FLAGM, + FEAT_FLAGM2, + FEAT_FP16FML, + FEAT_DOTPROD, + FEAT_SM4, + FEAT_RDM, + FEAT_LSE, + FEAT_FP, + FEAT_SIMD, + FEAT_CRC, + FEAT_SHA1, + FEAT_SHA2, + FEAT_SHA3, + FEAT_AES, + FEAT_PMULL, + FEAT_FP16, + FEAT_DIT
[compiler-rt] [libcxx] [flang] [clang] [lld] [lldb] [mlir] [llvm] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/75635 >From 336d1629f38a8681038f026c599a256761b522dc Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Fri, 15 Dec 2023 11:13:30 -0700 Subject: [PATCH 1/4] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- compiler-rt/lib/builtins/CMakeLists.txt | 4 +- compiler-rt/lib/builtins/cpu_model/aarch64.c | 142 + .../cpu_model/aarch64/fmv/android.inc | 35 + .../cpu_model/aarch64/fmv/freebsd.inc | 27 + .../builtins/cpu_model/aarch64/fmv/fucsia.inc | 19 + .../builtins/cpu_model/aarch64/fmv/mrs.inc| 375 +++ .../cpu_model/aarch64/fmv/sysauxv.inc | 17 + .../cpu_model/aarch64/fmv/unimplemented.inc | 11 + .../cpu_model/aarch64/lse_atomics/android.inc | 28 + .../cpu_model/aarch64/lse_atomics/freebsd.inc | 5 + .../cpu_model/aarch64/lse_atomics/fucsia.inc | 12 + .../cpu_model/aarch64/lse_atomics/sysauxv.inc | 6 + .../lib/builtins/cpu_model/cpu_model.h| 41 ++ .../builtins/{cpu_model.c => cpu_model/x86.c} | 600 +- 14 files changed, 729 insertions(+), 593 deletions(-) create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64.c create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/mrs.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/unimplemented.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/cpu_model.h rename compiler-rt/lib/builtins/{cpu_model.c => cpu_model/x86.c} (60%) diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index ea72c595a9b807..e5b52db175d960 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -271,7 +271,7 @@ endif() # These files are used on 32-bit and 64-bit x86. set(x86_ARCH_SOURCES - cpu_model.c + cpu_model/x86.c ) if (NOT MSVC) @@ -556,7 +556,7 @@ endif() set(aarch64_SOURCES ${GENERIC_TF_SOURCES} ${GENERIC_SOURCES} - cpu_model.c + cpu_model/aarch64.c aarch64/fp_mode.c ) diff --git a/compiler-rt/lib/builtins/cpu_model/aarch64.c b/compiler-rt/lib/builtins/cpu_model/aarch64.c new file mode 100644 index 00..98b0c4433d01a1 --- /dev/null +++ b/compiler-rt/lib/builtins/cpu_model/aarch64.c @@ -0,0 +1,142 @@ +//===-- cpu_model_aarch64.c - Support for __cpu_model builtin *- C -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file is based on LLVM's lib/Support/Host.cpp. +// It implements __aarch64_have_lse_atomics, __aarch64_cpu_features for AArch64. +// +//===--===// + +#include "cpu_model.h" + +#if !defined(__aarch64__) +# error This file is intended only for aarch64-based targets +#endif + + +#if __has_include() +#include +#else +typedef struct __ifunc_arg_t { + unsigned long _size; + unsigned long _hwcap; + unsigned long _hwcap2; +} __ifunc_arg_t; +#endif // __has_include() + + +// LSE support detection for out-of-line atomics +// using HWCAP and Auxiliary vector +_Bool __aarch64_have_lse_atomics +__attribute__((visibility("hidden"), nocommon)) = false; + +#if defined(__FreeBSD__) +# include "lse_atomics/freebsd.inc" +#elif defined(__Fucsia__) +# include "lse_atomics/fucsia.inc" +#elif defined(__ANDROID__) +# include "lse_atomics/android.inc" +#elif __has_include() +# include "lse_atomics/sysauxv.inc" +#else +// When unimplemented, we leave __aarch64_have_lse_atomics initialized to false. +#endif + + +#if !defined(DISABLE_AARCH64_FMV) +// CPUFeatures must correspond to the same AArch64 features in +// AArch64TargetParser.h +enum CPUFeatures { + FEAT_RNG, + FEAT_FLAGM, + FEAT_FLAGM2, + FEAT_FP16FML, + FEAT_DOTPROD, + FEAT_SM4, + FEAT_RDM, + FEAT_LSE, + FEAT_FP, + FEAT_SIMD, + FEAT_CRC, + FEAT_SHA1, + FEAT_SHA2, + FEAT_SHA3, + FEAT_AES, + FEAT_PMULL, + FEAT_FP16, + FEAT_DIT
[mlir] [llvm] [libcxx] [lld] [compiler-rt] [flang] [lldb] [clang] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/75635 >From 336d1629f38a8681038f026c599a256761b522dc Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Fri, 15 Dec 2023 11:13:30 -0700 Subject: [PATCH 1/5] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- compiler-rt/lib/builtins/CMakeLists.txt | 4 +- compiler-rt/lib/builtins/cpu_model/aarch64.c | 142 + .../cpu_model/aarch64/fmv/android.inc | 35 + .../cpu_model/aarch64/fmv/freebsd.inc | 27 + .../builtins/cpu_model/aarch64/fmv/fucsia.inc | 19 + .../builtins/cpu_model/aarch64/fmv/mrs.inc| 375 +++ .../cpu_model/aarch64/fmv/sysauxv.inc | 17 + .../cpu_model/aarch64/fmv/unimplemented.inc | 11 + .../cpu_model/aarch64/lse_atomics/android.inc | 28 + .../cpu_model/aarch64/lse_atomics/freebsd.inc | 5 + .../cpu_model/aarch64/lse_atomics/fucsia.inc | 12 + .../cpu_model/aarch64/lse_atomics/sysauxv.inc | 6 + .../lib/builtins/cpu_model/cpu_model.h| 41 ++ .../builtins/{cpu_model.c => cpu_model/x86.c} | 600 +- 14 files changed, 729 insertions(+), 593 deletions(-) create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64.c create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/mrs.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/unimplemented.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/cpu_model.h rename compiler-rt/lib/builtins/{cpu_model.c => cpu_model/x86.c} (60%) diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index ea72c595a9b807..e5b52db175d960 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -271,7 +271,7 @@ endif() # These files are used on 32-bit and 64-bit x86. set(x86_ARCH_SOURCES - cpu_model.c + cpu_model/x86.c ) if (NOT MSVC) @@ -556,7 +556,7 @@ endif() set(aarch64_SOURCES ${GENERIC_TF_SOURCES} ${GENERIC_SOURCES} - cpu_model.c + cpu_model/aarch64.c aarch64/fp_mode.c ) diff --git a/compiler-rt/lib/builtins/cpu_model/aarch64.c b/compiler-rt/lib/builtins/cpu_model/aarch64.c new file mode 100644 index 00..98b0c4433d01a1 --- /dev/null +++ b/compiler-rt/lib/builtins/cpu_model/aarch64.c @@ -0,0 +1,142 @@ +//===-- cpu_model_aarch64.c - Support for __cpu_model builtin *- C -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file is based on LLVM's lib/Support/Host.cpp. +// It implements __aarch64_have_lse_atomics, __aarch64_cpu_features for AArch64. +// +//===--===// + +#include "cpu_model.h" + +#if !defined(__aarch64__) +# error This file is intended only for aarch64-based targets +#endif + + +#if __has_include() +#include +#else +typedef struct __ifunc_arg_t { + unsigned long _size; + unsigned long _hwcap; + unsigned long _hwcap2; +} __ifunc_arg_t; +#endif // __has_include() + + +// LSE support detection for out-of-line atomics +// using HWCAP and Auxiliary vector +_Bool __aarch64_have_lse_atomics +__attribute__((visibility("hidden"), nocommon)) = false; + +#if defined(__FreeBSD__) +# include "lse_atomics/freebsd.inc" +#elif defined(__Fucsia__) +# include "lse_atomics/fucsia.inc" +#elif defined(__ANDROID__) +# include "lse_atomics/android.inc" +#elif __has_include() +# include "lse_atomics/sysauxv.inc" +#else +// When unimplemented, we leave __aarch64_have_lse_atomics initialized to false. +#endif + + +#if !defined(DISABLE_AARCH64_FMV) +// CPUFeatures must correspond to the same AArch64 features in +// AArch64TargetParser.h +enum CPUFeatures { + FEAT_RNG, + FEAT_FLAGM, + FEAT_FLAGM2, + FEAT_FP16FML, + FEAT_DOTPROD, + FEAT_SM4, + FEAT_RDM, + FEAT_LSE, + FEAT_FP, + FEAT_SIMD, + FEAT_CRC, + FEAT_SHA1, + FEAT_SHA2, + FEAT_SHA3, + FEAT_AES, + FEAT_PMULL, + FEAT_FP16, + FEAT_DIT
[llvm] [lldb] [compiler-rt] [mlir] [libcxx] [clang] [flang] [lld] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/75635 >From 336d1629f38a8681038f026c599a256761b522dc Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Fri, 15 Dec 2023 11:13:30 -0700 Subject: [PATCH 1/6] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- compiler-rt/lib/builtins/CMakeLists.txt | 4 +- compiler-rt/lib/builtins/cpu_model/aarch64.c | 142 + .../cpu_model/aarch64/fmv/android.inc | 35 + .../cpu_model/aarch64/fmv/freebsd.inc | 27 + .../builtins/cpu_model/aarch64/fmv/fucsia.inc | 19 + .../builtins/cpu_model/aarch64/fmv/mrs.inc| 375 +++ .../cpu_model/aarch64/fmv/sysauxv.inc | 17 + .../cpu_model/aarch64/fmv/unimplemented.inc | 11 + .../cpu_model/aarch64/lse_atomics/android.inc | 28 + .../cpu_model/aarch64/lse_atomics/freebsd.inc | 5 + .../cpu_model/aarch64/lse_atomics/fucsia.inc | 12 + .../cpu_model/aarch64/lse_atomics/sysauxv.inc | 6 + .../lib/builtins/cpu_model/cpu_model.h| 41 ++ .../builtins/{cpu_model.c => cpu_model/x86.c} | 600 +- 14 files changed, 729 insertions(+), 593 deletions(-) create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64.c create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/mrs.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/unimplemented.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/android.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/freebsd.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/fucsia.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/sysauxv.inc create mode 100644 compiler-rt/lib/builtins/cpu_model/cpu_model.h rename compiler-rt/lib/builtins/{cpu_model.c => cpu_model/x86.c} (60%) diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index ea72c595a9b807..e5b52db175d960 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -271,7 +271,7 @@ endif() # These files are used on 32-bit and 64-bit x86. set(x86_ARCH_SOURCES - cpu_model.c + cpu_model/x86.c ) if (NOT MSVC) @@ -556,7 +556,7 @@ endif() set(aarch64_SOURCES ${GENERIC_TF_SOURCES} ${GENERIC_SOURCES} - cpu_model.c + cpu_model/aarch64.c aarch64/fp_mode.c ) diff --git a/compiler-rt/lib/builtins/cpu_model/aarch64.c b/compiler-rt/lib/builtins/cpu_model/aarch64.c new file mode 100644 index 00..98b0c4433d01a1 --- /dev/null +++ b/compiler-rt/lib/builtins/cpu_model/aarch64.c @@ -0,0 +1,142 @@ +//===-- cpu_model_aarch64.c - Support for __cpu_model builtin *- C -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file is based on LLVM's lib/Support/Host.cpp. +// It implements __aarch64_have_lse_atomics, __aarch64_cpu_features for AArch64. +// +//===--===// + +#include "cpu_model.h" + +#if !defined(__aarch64__) +# error This file is intended only for aarch64-based targets +#endif + + +#if __has_include() +#include +#else +typedef struct __ifunc_arg_t { + unsigned long _size; + unsigned long _hwcap; + unsigned long _hwcap2; +} __ifunc_arg_t; +#endif // __has_include() + + +// LSE support detection for out-of-line atomics +// using HWCAP and Auxiliary vector +_Bool __aarch64_have_lse_atomics +__attribute__((visibility("hidden"), nocommon)) = false; + +#if defined(__FreeBSD__) +# include "lse_atomics/freebsd.inc" +#elif defined(__Fucsia__) +# include "lse_atomics/fucsia.inc" +#elif defined(__ANDROID__) +# include "lse_atomics/android.inc" +#elif __has_include() +# include "lse_atomics/sysauxv.inc" +#else +// When unimplemented, we leave __aarch64_have_lse_atomics initialized to false. +#endif + + +#if !defined(DISABLE_AARCH64_FMV) +// CPUFeatures must correspond to the same AArch64 features in +// AArch64TargetParser.h +enum CPUFeatures { + FEAT_RNG, + FEAT_FLAGM, + FEAT_FLAGM2, + FEAT_FP16FML, + FEAT_DOTPROD, + FEAT_SM4, + FEAT_RDM, + FEAT_LSE, + FEAT_FP, + FEAT_SIMD, + FEAT_CRC, + FEAT_SHA1, + FEAT_SHA2, + FEAT_SHA3, + FEAT_AES, + FEAT_PMULL, + FEAT_FP16, + FEAT_DIT
[clang] Avoid printing overly large integer. (PR #75902)
@@ -17132,6 +17132,9 @@ static bool ConvertAPValueToString(const APValue &V, QualType T, case BuiltinType::WChar_U: { unsigned TyWidth = Context.getIntWidth(T); assert(8 <= TyWidth && TyWidth <= 32 && "Unexpected integer width"); + if (V.getInt() >= (1 << 64)) { jroelofs wrote: > 1<<64 is results 0 Shifting beyond the width of the type is Undefined Behavior. https://github.com/llvm/llvm-project/pull/75902 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Avoid printing overly large integer. (PR #75902)
jroelofs wrote: This also needs a test case. https://github.com/llvm/llvm-project/pull/75902 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[lld] [compiler-rt] [llvm] [lldb] [flang] [mlir] [libcxx] [clang] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
https://github.com/jroelofs closed https://github.com/llvm/llvm-project/pull/75635 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[lldb] [clang-tools-extra] [libcxx] [flang] [llvm] [mlir] [clang] [lld] [compiler-rt] [builtins][arm64] Implement __init_cpu_features_resolver on Apple platforms (PR #75636)
https://github.com/jroelofs edited https://github.com/llvm/llvm-project/pull/75636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[lldb] [clang-tools-extra] [libcxx] [flang] [llvm] [mlir] [clang] [lld] [compiler-rt] [builtins][arm64] Implement __init_cpu_features_resolver on Apple platforms (PR #75636)
https://github.com/jroelofs closed https://github.com/llvm/llvm-project/pull/75636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] [lldb] [llvm] [clang] [compiler-rt] [flang] [mlir] [lld] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
jroelofs wrote: There were a few follow-ups to address that. Sorry. https://github.com/llvm/llvm-project/pull/75635 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [mlir] [llvm] [libcxx] [lldb] [lld] [flang] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
jroelofs wrote: * c88e74c26d5c - (31 minutes ago) fixup! fixup! [builtins] Refactor cpu_model support to reduce #if nesting. NFCI - Jon Roelofs * a5a17e8fadd4 - (39 minutes ago) fixup! [builtins] Refactor cpu_model support to reduce #if nesting. NFCI - Jon Roelofs * 256b214b6b0f - (66 minutes ago) [builtins][arm64] Implement __init_cpu_features_resolver on Apple platforms (#75636) - Jon Roelofs * 9237cfa65b6c - (68 minutes ago) [builtins] Refactor cpu_model support to reduce #if nesting. NFCI - Jon Roelofs * b72e1609146e - (61 minutes ago) Revert "[builtins] Refactor cpu_model support to reduce #if nesting. NFCI" - Jon Roelofs * b8b40e2fb988 - (61 minutes ago) Revert "[builtins][arm64] Implement __init_cpu_features_resolver on Apple platforms (#75636)" - Jon Roelofs * 17aa52017103 - (66 minutes ago) [builtins][arm64] Implement __init_cpu_features_resolver on Apple platforms (#75636) - Jon Roelofs * 025d048b1cac - (68 minutes ago) [builtins] Refactor cpu_model support to reduce #if nesting. NFCI - Jon Roelofs https://github.com/llvm/llvm-project/pull/75635 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] [lldb] [compiler-rt] [clang] [llvm] [lld] [mlir] [flang] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
jroelofs wrote: @petrhosek oh, I see what the problem is. I'll add another follow-up shortly. Sorry for the noise. https://github.com/llvm/llvm-project/pull/75635 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [mlir] [lldb] [compiler-rt] [llvm] [lld] [libcxx] [clang] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
jroelofs wrote: More follow-ups in 85d5ed81b1df, and 52e7b6f5c520 https://github.com/llvm/llvm-project/pull/75635 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[compiler-rt] [lld] [lldb] [llvm] [clang] [flang] [mlir] [libcxx] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
jroelofs wrote: I am surprised I haven't seen any complaints from buildbots about Andoid... anyway, thanks. 394e481a38c774f12c765fde7e9302d039a7cd94 https://github.com/llvm/llvm-project/pull/75635 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [lld] [libcxx] [clang] [lldb] [mlir] [llvm] [compiler-rt] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)
jroelofs wrote: @petrhosek I don't have a Fucshia sysroot to build this against, so I think it would help me a lot if you could grab the preprocessed version of the `cpu_model.c` before all these changes and stick it in a github gist... I feel a little bad for dragging this out in-tree. > These #if __has_include(...) conditionals would evaluate to false on Fuchsia > since we don't have those headers, but they have been moved in the refactored > version. In that case, if I'm reading it correctly, all of the `#if defined(__Fuchsia__)` support for both initializing the LSE atomics detection bool, and FMV in `cpu_model.c` are dead code, and we can drop those entries in the new `aarch64.c`. https://github.com/llvm/llvm-project/pull/75635 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [llvm] [Clang] Fix linker error for function multiversioning (PR #71706)
@@ -4114,8 +4114,26 @@ void CodeGenModule::emitMultiVersionFunctions() { } llvm::Constant *ResolverConstant = GetOrCreateMultiVersionResolver(GD); -if (auto *IFunc = dyn_cast(ResolverConstant)) +if (auto *IFunc = dyn_cast(ResolverConstant)) { ResolverConstant = IFunc->getResolver(); + // In Aarch64, default versions of multiversioned functions are mangled to + // their 'normal' assembly name. This deviates from other targets which + // append a '.default' string. As a result we need to continue appending + // .ifunc in Aarch64. + // FIXME: Should Aarch64 mangling for 'default' multiversion function and + // in turn ifunc function match that of other targets? jroelofs wrote: I have been meaning to file an issue about this. Not using a different mangling means you always get the default version when referencing a multi-versioned function outside of the TU. Consider e.g: ``` PublicHeader.h: int versioned(void); void *inside_TU(); void *outside_TU(); --- TUA.c: #include "PublicHeader.h" __attribute__((target_version("simd"))) int versioned(void) { return 1; } __attribute__((target_version("default"))) int versioned(void) { return 2; } void *inside_TU(void) { return versioned; } --- TUB.c: #include "PublicHeader.h" void *outside_TU(void) { return versioned; } --- Check.c: #include "PublicHeader.h" int main() { return inside_TU() == outside_TU(); } ``` @rsandifo-arm brought up a similar case on x86: ``` __attribute__((target("avx2"))) int versioned(void) { return 1; } __attribute__((target("default"))) int versioned(void) { return 2; } int (*inside_TU(void))(void) { return versioned; } ``` If we fix this, we should definitely make sure both the ACLE folks, and GCC are on board, and that the fix makes sense in the context of other targets. https://github.com/llvm/llvm-project/pull/71706 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 0041d6d - [𝘀𝗽𝗿] changes introduced through rebase
Author: Jon Roelofs Date: 2023-11-29T12:23:50-08:00 New Revision: 0041d6d015ae98b29820f649160c60a90c7c4220 URL: https://github.com/llvm/llvm-project/commit/0041d6d015ae98b29820f649160c60a90c7c4220 DIFF: https://github.com/llvm/llvm-project/commit/0041d6d015ae98b29820f649160c60a90c7c4220.diff LOG: [𝘀𝗽𝗿] changes introduced through rebase Created using spr 1.3.4 [skip ci] Added: Modified: clang/test/CodeGen/attr-ifunc.c clang/test/CodeGen/attr-ifunc.cpp clang/test/CodeGenCXX/externc-ifunc-resolver.cpp clang/test/SemaCXX/externc-ifunc-resolver.cpp Removed: diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c index 4f8fe13530fdb7b..2ad41edf20dfa01 100644 --- a/clang/test/CodeGen/attr-ifunc.c +++ b/clang/test/CodeGen/attr-ifunc.c @@ -1,6 +1,7 @@ // RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only -DCHECK_ALIASES %s // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify -emit-llvm-only %s #if defined(_WIN32) void foo(void) {} @@ -36,6 +37,25 @@ void *f6_resolver(void) __attribute__((ifunc("f6_resolver_resolver"))); void f6(void) __attribute__((ifunc("f6_resolver"))); // expected-error@-1 {{ifunc must point to a defined function}} +#elif defined(__APPLE__) + +// NOTE: aliases are not supported on Darwin, so the above tests are not relevant. + +#define STR2(X) #X +#define STR(X) STR2(X) +#define PREFIX STR(__USER_LABEL_PREFIX__) + +void f1a(void) __asm("f1"); +void f1a(void) {} +// expected-note@-1 {{previous definition is here}} +void f1(void) __attribute__((ifunc(PREFIX "f1_ifunc"))) __asm("f1"); +// expected-error@-1 {{definition with same mangled name 'f1' as another definition}} +void *f1_ifunc(void) { return 0; } + +void *f6_ifunc(int i); +void __attribute__((ifunc(PREFIX "f6_ifunc"))) f6(void) {} +// expected-error@-1 {{definition 'f6' cannot also be an ifunc}} + #else void f1a(void) __asm("f1"); void f1a(void) {} diff --git a/clang/test/CodeGen/attr-ifunc.cpp b/clang/test/CodeGen/attr-ifunc.cpp index 5b5b2c14b4074b7..b6e342df46eb583 100644 --- a/clang/test/CodeGen/attr-ifunc.cpp +++ b/clang/test/CodeGen/attr-ifunc.cpp @@ -1,5 +1,9 @@ // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify -emit-llvm-only %s +// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify -emit-llvm-only %s // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s void *f1_ifunc(void) { return nullptr; } void f1(void) __attribute__((ifunc("f1_ifunc"))); diff --git a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp index 0518a8dcc831dd4..be4453ae7eb08ce 100644 --- a/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp +++ b/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple arm64-apple-macosx -emit-llvm -o - %s | FileCheck %s extern "C" { __attribute__((used)) static void *resolve_foo() { return 0; } diff --git a/clang/test/SemaCXX/externc-ifunc-resolver.cpp b/clang/test/SemaCXX/externc-ifunc-resolver.cpp index aa44525bde2cae1..6c6c262c5f09d8e 100644 --- a/clang/test/SemaCXX/externc-ifunc-resolver.cpp +++ b/clang/test/SemaCXX/externc-ifunc-resolver.cpp @@ -1,5 +1,9 @@ // RUN: %clang_cc1 -emit-llvm-only -triple x86_64-linux-gnu -verify %s +// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-macosx -verify %s +// RUN: %clang_cc1 -emit-llvm-only -triple arm64-apple-macosx -verify %s // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s extern "C" { __attribute__((used)) static void *resolve_foo() { return 0; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] eafbe06 - [𝘀𝗽𝗿] changes introduced through rebase
Author: Jon Roelofs Date: 2023-11-29T12:23:57-08:00 New Revision: eafbe063de80818d4a9e2714bf317fa759550f39 URL: https://github.com/llvm/llvm-project/commit/eafbe063de80818d4a9e2714bf317fa759550f39 DIFF: https://github.com/llvm/llvm-project/commit/eafbe063de80818d4a9e2714bf317fa759550f39.diff LOG: [𝘀𝗽𝗿] changes introduced through rebase Created using spr 1.3.4 [skip ci] Added: Modified: clang/test/CodeGen/attr-cpuspecific.c clang/test/CodeGen/attr-ifunc.c clang/test/CodeGen/attr-ifunc.cpp clang/test/CodeGen/attr-target-clones.c clang/test/CodeGen/attr-target-mv-func-ptrs.c clang/test/CodeGen/attr-target-mv.c clang/test/CodeGenCXX/attr-cpuspecific.cpp clang/test/CodeGenCXX/attr-target-clones.cpp clang/test/CodeGenCXX/attr-target-mv-diff-ns.cpp clang/test/CodeGenCXX/attr-target-mv-func-ptrs.cpp clang/test/CodeGenCXX/attr-target-mv-inalloca.cpp clang/test/CodeGenCXX/attr-target-mv-member-funcs.cpp clang/test/CodeGenCXX/attr-target-mv-modules.cpp clang/test/CodeGenCXX/attr-target-mv-out-of-line-defs.cpp clang/test/CodeGenCXX/attr-target-mv-overloads.cpp clang/test/CodeGenCXX/externc-ifunc-resolver.cpp clang/test/SemaCXX/externc-ifunc-resolver.cpp Removed: diff --git a/clang/test/CodeGen/attr-cpuspecific.c b/clang/test/CodeGen/attr-cpuspecific.c index 9150597e8c5a847..5baa271b5240f0a 100644 --- a/clang/test/CodeGen/attr-cpuspecific.c +++ b/clang/test/CodeGen/attr-cpuspecific.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LINUX +// RUN: %clang_cc1 -triple x86_64-apple-macosx -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LINUX // RUN: %clang_cc1 -triple x86_64-windows-pc -fms-compatibility -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,WINDOWS #ifdef _WIN64 diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c index 4f8fe13530fdb7b..2ad41edf20dfa01 100644 --- a/clang/test/CodeGen/attr-ifunc.c +++ b/clang/test/CodeGen/attr-ifunc.c @@ -1,6 +1,7 @@ // RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only -DCHECK_ALIASES %s // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify -emit-llvm-only %s #if defined(_WIN32) void foo(void) {} @@ -36,6 +37,25 @@ void *f6_resolver(void) __attribute__((ifunc("f6_resolver_resolver"))); void f6(void) __attribute__((ifunc("f6_resolver"))); // expected-error@-1 {{ifunc must point to a defined function}} +#elif defined(__APPLE__) + +// NOTE: aliases are not supported on Darwin, so the above tests are not relevant. + +#define STR2(X) #X +#define STR(X) STR2(X) +#define PREFIX STR(__USER_LABEL_PREFIX__) + +void f1a(void) __asm("f1"); +void f1a(void) {} +// expected-note@-1 {{previous definition is here}} +void f1(void) __attribute__((ifunc(PREFIX "f1_ifunc"))) __asm("f1"); +// expected-error@-1 {{definition with same mangled name 'f1' as another definition}} +void *f1_ifunc(void) { return 0; } + +void *f6_ifunc(int i); +void __attribute__((ifunc(PREFIX "f6_ifunc"))) f6(void) {} +// expected-error@-1 {{definition 'f6' cannot also be an ifunc}} + #else void f1a(void) __asm("f1"); void f1a(void) {} diff --git a/clang/test/CodeGen/attr-ifunc.cpp b/clang/test/CodeGen/attr-ifunc.cpp index 5b5b2c14b4074b7..b6e342df46eb583 100644 --- a/clang/test/CodeGen/attr-ifunc.cpp +++ b/clang/test/CodeGen/attr-ifunc.cpp @@ -1,5 +1,9 @@ // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify -emit-llvm-only %s +// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify -emit-llvm-only %s // RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -triple x86_64-apple-macosx -emit-llvm-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -triple arm64-apple-macosx -emit-llvm-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s void *f1_ifunc(void) { return nullptr; } void f1(void) __attribute__((ifunc("f1_ifunc"))); diff --git a/clang/test/CodeGen/attr-target-clones.c b/clang/test/CodeGen/attr-target-clones.c index 98ffea40f56d887..32d4d6f32f68e56 100644 --- a/clang/test/CodeGen/attr-target-clones.c +++ b/clang/test/CodeGen/attr-target-clones.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefixes=LINUX,CHECK +// RUN: %clang_cc1 -triple x86_64-apple-macosx -emit-llvm %s -o - | FileCheck %s --check-prefixes=DARWIN,CHECK // RUN: %clang_cc1 -triple x86_64-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefixes=WIND
[clang] ecbfa04 - [𝘀𝗽𝗿] changes introduced through rebase
Author: Jon Roelofs Date: 2023-11-29T13:57:04-08:00 New Revision: ecbfa0495147d255964d8beeb89c8d8d80ec74a1 URL: https://github.com/llvm/llvm-project/commit/ecbfa0495147d255964d8beeb89c8d8d80ec74a1 DIFF: https://github.com/llvm/llvm-project/commit/ecbfa0495147d255964d8beeb89c8d8d80ec74a1.diff LOG: [𝘀𝗽𝗿] changes introduced through rebase Created using spr 1.3.4 [skip ci] Added: Modified: clang/include/clang/Basic/AttrDocs.td clang/test/CodeGen/ifunc.c llvm/docs/LangRef.rst llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Removed: diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 4c4c4eb606fb0dc..5e85ec52a4634e5 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -5408,9 +5408,9 @@ considered inline. Not all targets support this attribute. ELF target support depends on both the linker and runtime linker, and is available in at least lld 4.0 and later, binutils 2.20.1 and later, glibc v2.11.1 and later, and FreeBSD 9.1 and later. -MachO targets support it, but with slightly diff erent semantics: the resolver is -run at first call, instead of at load time by the runtime linker. Targets other -than ELF and MachO currently do not support this attribute. +Mach-O targets support it, but with slightly diff erent semantics: the resolver +is run at first call, instead of at load time by the runtime linker. Targets +other than ELF and Mach-O currently do not support this attribute. }]; } diff --git a/clang/test/CodeGen/ifunc.c b/clang/test/CodeGen/ifunc.c index 99d60dc0ea85dbd..a29b500e80bd50b 100644 --- a/clang/test/CodeGen/ifunc.c +++ b/clang/test/CodeGen/ifunc.c @@ -3,9 +3,13 @@ // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fsanitize=thread -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fsanitize=address -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fsanitize=memory -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN +// RUN: %clang_cc1 -triple arm64-apple-macosx -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -triple x86_64-apple-macosx -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple arm64-apple-macosx -O2 -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -triple x86_64-apple-macosx -O2 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple arm64-apple-macosx -fsanitize=thread -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=MACSAN // RUN: %clang_cc1 -triple x86_64-apple-macosx -fsanitize=thread -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=MACSAN +// RUN: %clang_cc1 -triple arm64-apple-macosx -fsanitize=address -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=MACSAN // RUN: %clang_cc1 -triple x86_64-apple-macosx -fsanitize=address -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=MACSAN int foo(int) __attribute__ ((ifunc("foo_ifunc"))); diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index cb222e979db29d4..fece4ac7f127d6b 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -937,7 +937,7 @@ IFuncs, like as aliases, don't create any new data or func. They are just a new symbol that is resolved at runtime by calling a resolver function. On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On -MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +Mach-O platforms, they are lowered in terms of ``.symbol_resolver``s, which lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index b4ac0a70e7fde9c..aaa7693c61f0e85 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -2321,7 +2321,7 @@ bool AsmPrinter::doFinalization(Module &M) { } // IFuncs must come before deubginfo in case the backend decides to emit them - // as actual functions, since on MachO targets, we cannot create regular + // as actual functions, since on Mach-O targets, we cannot create regular // sections after DWARF. for (const auto &IFunc : M.ifuncs()) emitGlobalIFunc(M, IFunc); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 97e7926 - [𝘀𝗽𝗿] changes introduced through rebase
Author: Jon Roelofs Date: 2023-11-29T13:57:10-08:00 New Revision: 97e7926f25d81fb6c6d87202f721c2e2cf6198f5 URL: https://github.com/llvm/llvm-project/commit/97e7926f25d81fb6c6d87202f721c2e2cf6198f5 DIFF: https://github.com/llvm/llvm-project/commit/97e7926f25d81fb6c6d87202f721c2e2cf6198f5.diff LOG: [𝘀𝗽𝗿] changes introduced through rebase Created using spr 1.3.4 [skip ci] Added: Modified: clang/include/clang/Basic/AttrDocs.td clang/test/CodeGen/ifunc.c llvm/docs/LangRef.rst llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Removed: diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 4c4c4eb606fb0dc..5e85ec52a4634e5 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -5408,9 +5408,9 @@ considered inline. Not all targets support this attribute. ELF target support depends on both the linker and runtime linker, and is available in at least lld 4.0 and later, binutils 2.20.1 and later, glibc v2.11.1 and later, and FreeBSD 9.1 and later. -MachO targets support it, but with slightly diff erent semantics: the resolver is -run at first call, instead of at load time by the runtime linker. Targets other -than ELF and MachO currently do not support this attribute. +Mach-O targets support it, but with slightly diff erent semantics: the resolver +is run at first call, instead of at load time by the runtime linker. Targets +other than ELF and Mach-O currently do not support this attribute. }]; } diff --git a/clang/test/CodeGen/ifunc.c b/clang/test/CodeGen/ifunc.c index 99d60dc0ea85dbd..a29b500e80bd50b 100644 --- a/clang/test/CodeGen/ifunc.c +++ b/clang/test/CodeGen/ifunc.c @@ -3,9 +3,13 @@ // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fsanitize=thread -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fsanitize=address -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fsanitize=memory -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN +// RUN: %clang_cc1 -triple arm64-apple-macosx -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -triple x86_64-apple-macosx -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple arm64-apple-macosx -O2 -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -triple x86_64-apple-macosx -O2 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple arm64-apple-macosx -fsanitize=thread -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=MACSAN // RUN: %clang_cc1 -triple x86_64-apple-macosx -fsanitize=thread -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=MACSAN +// RUN: %clang_cc1 -triple arm64-apple-macosx -fsanitize=address -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=MACSAN // RUN: %clang_cc1 -triple x86_64-apple-macosx -fsanitize=address -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=MACSAN int foo(int) __attribute__ ((ifunc("foo_ifunc"))); diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index cb222e979db29d4..fece4ac7f127d6b 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -937,7 +937,7 @@ IFuncs, like as aliases, don't create any new data or func. They are just a new symbol that is resolved at runtime by calling a resolver function. On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On -MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which +Mach-O platforms, they are lowered in terms of ``.symbol_resolver``s, which lazily resolve the callee the first time they are called. IFunc may have an optional :ref:`linkage type ` and an optional diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index b4ac0a70e7fde9c..aaa7693c61f0e85 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -2321,7 +2321,7 @@ bool AsmPrinter::doFinalization(Module &M) { } // IFuncs must come before deubginfo in case the backend decides to emit them - // as actual functions, since on MachO targets, we cannot create regular + // as actual functions, since on Mach-O targets, we cannot create regular // sections after DWARF. for (const auto &IFunc : M.ifuncs()) emitGlobalIFunc(M, IFunc); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 8440ec6 - [docs] Document -ffinite-math-only, -fhonor-{infinities,infinites,nans}
Author: Jon Roelofs Date: 2022-02-08T18:10:17-08:00 New Revision: 8440ec66f4f0f2e4f49061262648809345952bf7 URL: https://github.com/llvm/llvm-project/commit/8440ec66f4f0f2e4f49061262648809345952bf7 DIFF: https://github.com/llvm/llvm-project/commit/8440ec66f4f0f2e4f49061262648809345952bf7.diff LOG: [docs] Document -ffinite-math-only, -fhonor-{infinities,infinites,nans} Added: Modified: clang/docs/ClangCommandLineReference.rst Removed: diff --git a/clang/docs/ClangCommandLineReference.rst b/clang/docs/ClangCommandLineReference.rst index 12ea688edc1a8..e4b5c1a780446 100644 --- a/clang/docs/ClangCommandLineReference.rst +++ b/clang/docs/ClangCommandLineReference.rst @@ -1725,6 +1725,8 @@ Assume all loops are finite. .. option:: -ffinite-math-only, -fno-finite-math-only +Allow floating-point optimizations that assume arguments and results are not NaNs or +-inf. This defines the \_\_FINITE\_MATH\_ONLY\_\_ preprocessor macro. + .. option:: -ffixed-point, -fno-fixed-point Enable fixed point types @@ -1805,10 +1807,14 @@ Specify that single precision floating-point divide and sqrt used in the program Use new kernel launching API for HIP -.. option:: -fhonor-infinities, -fhonor-infinites, -fno-honor-infinities +.. option:: -fhonor-infinities, -fhonor-infinites, -fno-honor-infinities, -fno-honor-infinites + +Specify that floating-point optimizations are not allowed that assume arguments and results are not +-inf. .. option:: -fhonor-nans, -fno-honor-nans +Specify that floating-point optimizations are not allowed that assume arguments and results are not NANs. + .. option:: -fhosted .. option:: -fignore-exceptions ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] AArch64: add __builtin_arm_trap (PR #85054)
https://github.com/jroelofs approved this pull request. https://github.com/llvm/llvm-project/pull/85054 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CodeGen][AArch64][FMV] PAC the stub_helper's frame on arm64e (PR #84704)
jroelofs wrote: > > Can the triple checks be generalized to checking about pauth-enabled > > subtarget feature? This way everything would work for ELF platforms > > eventually. These are admittedly a bit of a hack, since we don't have a Function to look at the attributes on when we're in that part of the AsmPrinter. But that said, the ones in the AsmPrinter are all Mach-O-specific (they "manually" implement what the dynamic linker would do on an ELF platform), so generalizing them won't help ELF platforms. > > @asl Since I'm not sure how particularly ifuncs should be handled, here are > two answers for two different cases. > > If we need just to check that pauth target feature is enabled, we can use > `TM.getTargetFeatureString()` and see if it contains `+pauth`. > > If the ifunc-related behavior is dependent on `-fptrauth-calls` (implicitly > enabled on apple arm64e) and should not be enabled when, say, only > `-fptrauth-returns` is used (in both cases the target feature string contains > `+pauth`), on ELF we can add a check against (platform,version) tuple > defining the ABI after #85236 is merged. The change to add the default attributes should cover whether the resolver gets `-fptrauth-returns`. For `-fptrauth-calls` on the other hand you will need some cooperation with the dynamic linker on ELF targets, since on those platforms you'll need to coordinate with the implementation of `.type global_ifunc,@gnu_indirect_function` to decide whether the resolver should sign the returned pointer and with what key. https://github.com/llvm/llvm-project/pull/84704 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CodeGen][AArch64][FMV] PAC the stub_helper's frame on arm64e (PR #84704)
@@ -0,0 +1,58 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals --include-generated-funcs +// RUN: %clang_cc1 -triple arm64e-apple-ios -target-feature +ls64 -target-feature +fullfp16 -S -emit-llvm -o - %s | FileCheck %s + +int __attribute__((target_version("sha1"))) fmv(void) { return 1; } +int __attribute__((target_version("default"))) fmv(void) { return 0; } +int foo() { + return fmv(); +} + +//. +// CHECK: @__aarch64_cpu_features = external dso_local global { i64 } +// CHECK: @fmv.ifunc = weak_odr alias i32 (), ptr @fmv +// CHECK: @fmv = weak_odr ifunc i32 (), ptr @fmv.resolver +//. +// CHECK: Function Attrs: noinline nounwind optnone +// CHECK-LABEL: define {{[^@]+}}@fmv._Msha1 +// CHECK-SAME: () #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:ret i32 1 +// +// +// CHECK: Function Attrs: noinline nounwind optnone +// CHECK-LABEL: define {{[^@]+}}@foo +// CHECK-SAME: () #[[ATTR1:[0-9]+]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:[[CALL:%.*]] = call i32 @fmv() +// CHECK-NEXT:ret i32 [[CALL]] +// +// +// CHECK-LABEL: define {{[^@]+}}@fmv.resolver +// CHECK-SAME: () #[[ATTR2:[0-9]+]] { +// CHECK-NEXT: resolver_entry: +// CHECK-NEXT:call void @__init_cpu_features_resolver() +// CHECK-NEXT:[[TMP0:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8 +// CHECK-NEXT:[[TMP1:%.*]] = and i64 [[TMP0]], 2048 +// CHECK-NEXT:[[TMP2:%.*]] = icmp eq i64 [[TMP1]], 2048 +// CHECK-NEXT:[[TMP3:%.*]] = and i1 true, [[TMP2]] +// CHECK-NEXT:br i1 [[TMP3]], label [[RESOLVER_RETURN:%.*]], label [[RESOLVER_ELSE:%.*]] +// CHECK: resolver_return: +// CHECK-NEXT:ret ptr @fmv._Msha1 +// CHECK: resolver_else: +// CHECK-NEXT:ret ptr @fmv.default jroelofs wrote: The thing that's missing is this: https://github.com/apple/llvm-project/blob/970b6231f607e211c23e15a582572e6f18f4e6b2/clang/include/clang/CodeGen/CodeGenABITypes.h#L122-L126 along with this hunk: ``` --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -2893,7 +2893,11 @@ static void CreateMultiVersionResolverReturn(CodeGenModule &CGM, llvm::Function *FuncToReturn, bool SupportsIFunc) { if (SupportsIFunc) { -Builder.CreateRet(FuncToReturn); +llvm::Constant *Fn = FuncToReturn; +if (CGM.getContext().getTargetInfo().getTriple().isArm64e()) + Fn = CGM.getConstantSignedPointer( + Fn, 0, nullptr, llvm::Constant::getNullValue(CGM.SizeTy)); +Builder.CreateRet(Fn); return; } ``` This arranges for the resolver to return signed function pointers. There is no difference for arm64(non-e). https://github.com/llvm/llvm-project/pull/84704 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CodeGen][AArch64][FMV] PAC the stub_helper's frame on arm64e (PR #84704)
@@ -0,0 +1,58 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals --include-generated-funcs +// RUN: %clang_cc1 -triple arm64e-apple-ios -target-feature +ls64 -target-feature +fullfp16 -S -emit-llvm -o - %s | FileCheck %s + +int __attribute__((target_version("sha1"))) fmv(void) { return 1; } +int __attribute__((target_version("default"))) fmv(void) { return 0; } +int foo() { + return fmv(); +} + +//. +// CHECK: @__aarch64_cpu_features = external dso_local global { i64 } +// CHECK: @fmv.ifunc = weak_odr alias i32 (), ptr @fmv +// CHECK: @fmv = weak_odr ifunc i32 (), ptr @fmv.resolver +//. +// CHECK: Function Attrs: noinline nounwind optnone +// CHECK-LABEL: define {{[^@]+}}@fmv._Msha1 +// CHECK-SAME: () #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:ret i32 1 +// +// +// CHECK: Function Attrs: noinline nounwind optnone +// CHECK-LABEL: define {{[^@]+}}@foo +// CHECK-SAME: () #[[ATTR1:[0-9]+]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:[[CALL:%.*]] = call i32 @fmv() +// CHECK-NEXT:ret i32 [[CALL]] +// +// +// CHECK-LABEL: define {{[^@]+}}@fmv.resolver +// CHECK-SAME: () #[[ATTR2:[0-9]+]] { +// CHECK-NEXT: resolver_entry: +// CHECK-NEXT:call void @__init_cpu_features_resolver() +// CHECK-NEXT:[[TMP0:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8 +// CHECK-NEXT:[[TMP1:%.*]] = and i64 [[TMP0]], 2048 +// CHECK-NEXT:[[TMP2:%.*]] = icmp eq i64 [[TMP1]], 2048 +// CHECK-NEXT:[[TMP3:%.*]] = and i1 true, [[TMP2]] +// CHECK-NEXT:br i1 [[TMP3]], label [[RESOLVER_RETURN:%.*]], label [[RESOLVER_ELSE:%.*]] +// CHECK: resolver_return: +// CHECK-NEXT:ret ptr @fmv._Msha1 +// CHECK: resolver_else: +// CHECK-NEXT:ret ptr @fmv.default jroelofs wrote: @asl the check in the hunk above should be generalized for ELF, and only turned on with `-fptrauth-calls`. I wasn't sure how to get a QualType here though, which would be needed to get the `CGPointerAuthInfo` that this would make the check on. Not sure if it's reasonable to "invent" one that's close enough, e.g. for `void (*fn_ptr)(void);` or something. https://github.com/llvm/llvm-project/pull/84704 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix Clang language extension documentation markup for __builtin_arm_trap. (PR #85310)
https://github.com/jroelofs approved this pull request. https://github.com/llvm/llvm-project/pull/85310 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV] Emit the resolver along with the default version definition. (PR #84405)
jroelofs wrote: Can you elaborate on that conversation a bit more? I want to make sure we cover all the corner cases. https://github.com/llvm/llvm-project/pull/84405 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV] Emit the resolver along with the default version definition. (PR #84405)
@@ -4120,6 +4127,9 @@ void CodeGenModule::emitMultiVersionFunctions() { TA->getArchitecture(), Feats); } else { const auto *TVA = CurFD->getAttr(); + if (TVA->isDefaultVersion() && + CurFD->doesThisDeclarationHaveABody()) +EmitResolver = true; llvm::SmallVector Feats; TVA->getFeatures(Feats); Options.emplace_back(cast(Func), jroelofs wrote: github won't let me put a comment on the line I want to, but should there be a `EmitResolver = true` down in `} else if (FD->isTargetClonesMultiVersion()) {` ? https://github.com/llvm/llvm-project/pull/84405 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV] Emit the resolver along with the default version definition. (PR #84405)
@@ -4347,6 +4362,19 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl GD) { } } +/// Adds a declaration to the list of multi version functions if not present. +void CodeGenModule::AddDeferredMultiVersionResolverToEmit(GlobalDecl GD) { + const auto *FD = cast(GD.getDecl()); + assert(FD && "Not a FunctionDecl?"); + + if (FD->isTargetVersionMultiVersion()) { +StringRef NamePrefix = getMangledName(GD).split('.').first; jroelofs wrote: ISTM you want `getMangledNameImpl` here instead, with `OmitMultiVersionMangling = true`. Trying to split this on the first `.` seems suspicious, and might not play well with `asm("foo.bar.baz._Mlse")` https://github.com/llvm/llvm-project/pull/84405 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV] Emit the resolver along with the default version definition. (PR #84405)
@@ -84,9 +84,33 @@ int hoo(void) { return fp1() + fp2(); } +// This should generate one target version but no resolver. +__attribute__((target_version("default"))) int unused_with_forward_default_decl(void); +__attribute__((target_version("mops"))) int unused_with_forward_default_decl(void) { return 0; } +// This should also generate one target version but no resolver. +extern int unused_with_implicit_extern_forward_default_decl(void); +__attribute__((target_version("dotprod"))) +int unused_with_implicit_extern_forward_default_decl(void) { return 0; } +// This should also generate one target version but no resolver. +__attribute__((target_version("aes"))) int unused_with_default_decl(void) { return 0; } +__attribute__((target_version("default"))) int unused_with_default_decl(void); +// This should generate two target versions and the resolver. +__attribute__((target_version("sve"))) int unused_with_default_def(void) { return 0; } +__attribute__((target_version("default"))) int unused_with_default_def(void) { return 1; } + +// This should also generate two target versions and the resolver. +__attribute__((target_version("fp16"))) int unused_with_implicit_default_def(void) { return 0; } +int unused_with_implicit_default_def(void) { return 1; } + +// This should also generate two target versions and the resolver. +int unused_with_implicit_forward_default_def(void) { return 0; } +__attribute__((target_version("lse"))) int unused_with_implicit_forward_default_def(void) { return 1; } + +// This should generate a normal function. +__attribute__((target_version("rdm"))) int unused_without_default(void) { return 0; } jroelofs wrote: IIUC this breaks a use case I am _very_ interested in: header.h: ``` int defined_in_separate_files(void); ``` feature_a.c: ``` #include __attribute__((target_version("featurea"))) int defined_in_separate_files(void) { return 1; } ``` feature_b.c: ``` #include __attribute__((target_version("featureb"))) int defined_in_separate_files(void) { return 2; } ``` default.c: ``` #include __attribute__((target_version("rdm"))) int defined_in_separate_files(void); __attribute__((target_version("lse"))) int defined_in_separate_files(void); __attribute__((target_version("default"))) int defined_in_separate_files(void) { return 0; } ``` In my experience, the functions that my users want to multi-version tend to be pretty large and live in separate files, organized per architectural feature that they want to take advantage of. At the very least it adds a sharp edge: they need to declare the default version in each TU, or put it in a private header shared between them. https://github.com/llvm/llvm-project/pull/84405 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV] Emit the resolver along with the default version definition. (PR #84405)
https://github.com/jroelofs edited https://github.com/llvm/llvm-project/pull/84405 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV] Emit the resolver along with the default version definition. (PR #84405)
@@ -4347,6 +4362,19 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl GD) { } } +/// Adds a declaration to the list of multi version functions if not present. +void CodeGenModule::AddDeferredMultiVersionResolverToEmit(GlobalDecl GD) { + const auto *FD = cast(GD.getDecl()); + assert(FD && "Not a FunctionDecl?"); + + if (FD->isTargetVersionMultiVersion()) { +StringRef NamePrefix = getMangledName(GD).split('.').first; jroelofs wrote: `asm`+multiversioning isn't really the point of that argument... sorry, bad example. My point is that the `.` inserted for multi versioning mangling might not be the only one. If you insist on string splitting, it should at least be `rsplit`. We shouldn't have to rely on string splitting though: `getMangledNameImpl(..., false)` returns the prefix that you need. It is used elsewhere in this multiversioning code to retrieve what the mangled name would be on the function if it did not have the attribute: https://github.com/llvm/llvm-project/blob/7337db72ed334f8389601f160b762e50c4e61c25/clang/lib/CodeGen/CodeGenModule.cpp#L1857-L1861 https://github.com/llvm/llvm-project/pull/84405 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV] Emit the resolver along with the default version definition. (PR #84405)
@@ -4120,6 +4127,9 @@ void CodeGenModule::emitMultiVersionFunctions() { TA->getArchitecture(), Feats); } else { const auto *TVA = CurFD->getAttr(); + if (TVA->isDefaultVersion() && + CurFD->doesThisDeclarationHaveABody()) +EmitResolver = true; llvm::SmallVector Feats; TVA->getFeatures(Feats); Options.emplace_back(cast(Func), jroelofs wrote: oh, ok. cool. https://github.com/llvm/llvm-project/pull/84405 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV] Emit the resolver along with the default version definition. (PR #84405)
@@ -4120,6 +4127,9 @@ void CodeGenModule::emitMultiVersionFunctions() { TA->getArchitecture(), Feats); } else { const auto *TVA = CurFD->getAttr(); + if (TVA->isDefaultVersion() && + CurFD->doesThisDeclarationHaveABody()) +EmitResolver = true; llvm::SmallVector Feats; TVA->getFeatures(Feats); Options.emplace_back(cast(Func), jroelofs wrote: I always get `isTargetMultiVersion` confused w/ TargetVersionMultiVersion. https://github.com/llvm/llvm-project/pull/84405 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV] Emit the resolver along with the default version definition. (PR #84405)
https://github.com/jroelofs edited https://github.com/llvm/llvm-project/pull/84405 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV] Emit the resolver along with the default version definition. (PR #84405)
@@ -4347,6 +4362,19 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl GD) { } } +/// Adds a declaration to the list of multi version functions if not present. +void CodeGenModule::AddDeferredMultiVersionResolverToEmit(GlobalDecl GD) { + const auto *FD = cast(GD.getDecl()); + assert(FD && "Not a FunctionDecl?"); + + if (FD->isTargetVersionMultiVersion()) { +StringRef NamePrefix = getMangledName(GD).split('.').first; jroelofs wrote: Hm. Is there somewhere convenient to stick an `llvm::StringSaver`? https://github.com/llvm/llvm-project/pull/84405 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CodeGen][AArch64][FMV] PAC the stub_helper's frame on arm64e (PR #84704)
@@ -2085,6 +2099,37 @@ void AArch64AsmPrinter::emitMachOIFuncStubHelperBody(Module &M, .addImm(2), *STI); + if (TM.getTargetTriple().isArm64e()) { +// autibsp jroelofs wrote: Is there a PR up for that that I should tack this bit onto the end of? https://github.com/llvm/llvm-project/pull/84704 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV] Emit the resolver along with the default version definition. (PR #84405)
jroelofs wrote: The current patch looks mostly good, but I'm still hung up on this: > I'd like to support FMV in existing codebases as lean as possible, so the > default version attribute would be optional to write as not all > version/toolchain will support it. smallest possible codebase change to > introduce multi versioning: > > ```c > int foo(void); > > + #ifdef __HAVE_FUNCTION_MULTI_VERSIONING > + int __attribute__((target_version("feature"))) foo(void); > + #endif > ``` Are you imagining this would multi-version between the un-decorated `int foo(void);` and the `int __attribute__((target_version("feature"))) foo(void);` decorated one? In the current patch, it just gets the non-mangled name. And the fact that we get a not-mangled function that uses `feature` without going through a resolver is concerning to me. https://github.com/llvm/llvm-project/pull/84405 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV] Emit the resolver along with the default version definition. (PR #84405)
jroelofs wrote: I'm referring to: ``` // This should generate a normal function. int __attribute__((target_version("rdm"))) unused_without_default(void); ``` and: ``` // CHECK: Function Attrs: noinline nounwind optnone + // CHECK-LABEL: define {{[^@]+}}@unused_without_default + // CHECK-SAME: () #[[ATTR17:[0-9]+]] { // CHECK-NEXT: entry: + // CHECK-NEXT:ret i32 0 ``` and am confused why `int __attribute__((target_version("rdm"))) unused_without_default(void)`'s mangling will be `_ unused_without_default` and not `_unused_without_default._Mrdm`. https://github.com/llvm/llvm-project/pull/84405 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits