[llvm-branch-commits] [llvm] fa49b51 - Revert "[X86] Respect code models more when determining if a global reference can fit in 32 bits (#75386)"
Author: Arthur Eubanks Date: 2023-12-14T09:32:29-08:00 New Revision: fa49b518fa504a6808d6c76f529bfda5f907495c URL: https://github.com/llvm/llvm-project/commit/fa49b518fa504a6808d6c76f529bfda5f907495c DIFF: https://github.com/llvm/llvm-project/commit/fa49b518fa504a6808d6c76f529bfda5f907495c.diff LOG: Revert "[X86] Respect code models more when determining if a global reference can fit in 32 bits (#75386)" This reverts commit 5e38ba26d2189267a95b4dde4d7b4ae85260eaf3. Added: Modified: llvm/include/llvm/Target/TargetMachine.h llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp llvm/lib/Target/TargetMachine.cpp llvm/lib/Target/X86/X86FastISel.cpp llvm/lib/Target/X86/X86ISelDAGToDAG.cpp llvm/lib/Target/X86/X86Subtarget.cpp llvm/test/CodeGen/X86/code-model-elf.ll Removed: diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h index 4c29f25bedf419..4830ecbe1cd634 100644 --- a/llvm/include/llvm/Target/TargetMachine.h +++ b/llvm/include/llvm/Target/TargetMachine.h @@ -239,7 +239,7 @@ class TargetMachine { void setCodeModel(CodeModel::Model CM) { CMModel = CM; } void setLargeDataThreshold(uint64_t LDT) { LargeDataThreshold = LDT; } - bool isLargeGlobalValue(const GlobalValue *GV) const; + bool isLargeGlobalObject(const GlobalObject *GO) const; bool isPositionIndependent() const; diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 18f4d546aa82d7..27d47aab4b6838 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -645,7 +645,7 @@ getELFSectionNameForGlobal(const GlobalObject *GO, SectionKind Kind, Name = ".rodata.cst"; Name += utostr(EntrySize); } else { -Name = getSectionPrefixForGlobal(Kind, TM.isLargeGlobalValue(GO)); +Name = getSectionPrefixForGlobal(Kind, TM.isLargeGlobalObject(GO)); } bool HasPrefix = false; @@ -765,7 +765,7 @@ getGlobalObjectInfo(const GlobalObject *GO, const TargetMachine &TM) { Group = C->getName(); IsComdat = C->getSelectionKind() == Comdat::Any; } - if (TM.isLargeGlobalValue(GO)) + if (TM.isLargeGlobalObject(GO)) Flags |= ELF::SHF_X86_64_LARGE; return {Group, IsComdat, Flags}; } diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp index 3f96bd37755e58..5428e14eca5f8d 100644 --- a/llvm/lib/Target/TargetMachine.cpp +++ b/llvm/lib/Target/TargetMachine.cpp @@ -39,16 +39,10 @@ TargetMachine::TargetMachine(const Target &T, StringRef DataLayoutString, TargetMachine::~TargetMachine() = default; -bool TargetMachine::isLargeGlobalValue(const GlobalValue *GVal) const { +bool TargetMachine::isLargeGlobalObject(const GlobalObject *GO) const { if (getTargetTriple().getArch() != Triple::x86_64) return false; - auto *GO = GVal->getAliaseeObject(); - - // Be conservative if we can't find an underlying GlobalObject. - if (!GO) -return true; - auto *GV = dyn_cast(GO); // Functions/GlobalIFuncs are only large under the large code model. diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp index fd14a8a7dc2a9e..425c52dbe7b104 100644 --- a/llvm/lib/Target/X86/X86FastISel.cpp +++ b/llvm/lib/Target/X86/X86FastISel.cpp @@ -716,8 +716,10 @@ bool X86FastISel::handleConstantAddresses(const Value *V, X86AddressMode &AM) { return false; // Can't handle large objects yet. -if (TM.isLargeGlobalValue(GV)) - return false; +if (auto *GO = dyn_cast(GV)) { + if (TM.isLargeGlobalObject(GO)) +return false; +} // Can't handle TLS yet. if (GV->isThreadLocal()) diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp index ce4fbfe88739df..545039b79f1616 100644 --- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -2927,10 +2927,6 @@ bool X86DAGToDAGISel::selectAddr(SDNode *Parent, SDValue N, SDValue &Base, } bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue &Imm) { - // Cannot use 32 bit constants to reference objects in kernel code model. - if (TM.getCodeModel() == CodeModel::Kernel) -return false; - // In static codegen with small code model, we can get the address of a label // into a register with 'movl' if (N->getOpcode() != X86ISD::Wrapper) @@ -2944,18 +2940,15 @@ bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue &Imm) { return false; Imm = N; - // Small/medium code model can reference non-TargetGlobalAddress objects with - // 32 bit constants. - if (N->getOpcode() != ISD::TargetGlobalAddress) { -return TM.getCodeModel() == CodeModel::Small || - TM.getCodeModel() == CodeModel::Medium; - } + if (N->getOpcode() != ISD::TargetGlobalAddress) +r
[llvm-branch-commits] [llvm] [libcxx] [flang] [compiler-rt] [openmp] [lld] [clang-tools-extra] [libc] [libcxxabi] [clang] [mlir] [lldb] [clang] Support __attribute__((ifunc(...))) on Darwin platforms
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73687 >From aeb39b92bbd7670fb8c6b9e76a456a92199691b3 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Wed, 29 Nov 2023 12:23:46 -0800 Subject: [PATCH] adjust tests per review feedback Created using spr 1.3.4 --- clang/test/CodeGen/attr-ifunc.c | 20 +++ clang/test/CodeGen/attr-ifunc.cpp | 4 .../CodeGenCXX/externc-ifunc-resolver.cpp | 2 ++ clang/test/SemaCXX/externc-ifunc-resolver.cpp | 4 4 files changed, 30 insertions(+) diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c index 4f8fe13530fdb7..2ad41edf20dfa0 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 5b5b2c14b4074b..b6e342df46eb58 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 0518a8dcc831dd..be4453ae7eb08c 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 aa44525bde2cae..6c6c262c5f09d8 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; } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [llvm] [clang] [libcxxabi] [compiler-rt] [clang-tools-extra] [libcxx] [lld] [lldb] [openmp] [libc] [mlir] [clang] Support __attribute__((ifunc(...))) on Darwin platforms
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73687 >From aeb39b92bbd7670fb8c6b9e76a456a92199691b3 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Wed, 29 Nov 2023 12:23:46 -0800 Subject: [PATCH] adjust tests per review feedback Created using spr 1.3.4 --- clang/test/CodeGen/attr-ifunc.c | 20 +++ clang/test/CodeGen/attr-ifunc.cpp | 4 .../CodeGenCXX/externc-ifunc-resolver.cpp | 2 ++ clang/test/SemaCXX/externc-ifunc-resolver.cpp | 4 4 files changed, 30 insertions(+) diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c index 4f8fe13530fdb7..2ad41edf20dfa0 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 5b5b2c14b4074b..b6e342df46eb58 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 0518a8dcc831dd..be4453ae7eb08c 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 aa44525bde2cae..6c6c262c5f09d8 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; } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] [mlir] [clang-tools-extra] [libcxxabi] [openmp] [clang] [flang] [libcxx] [lld] [llvm] [libc] [lldb] [clang] Function Multi Versioning supports IFunc lowerings on Da
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73688 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] [libcxx] [lldb] [libc] [openmp] [clang-tools-extra] [compiler-rt] [flang] [libcxxabi] [lld] [mlir] [clang] Function Multi Versioning supports IFunc lowerings on Da
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73688 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [compiler-rt] [flang] [libc] [llvm] [clang-tools-extra] [GlobalISel] Always direct-call IFuncs and Aliases (PR #74902)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/74902 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [flang] [clang] [clang-tools-extra] [compiler-rt] [libc] [GlobalISel] Always direct-call IFuncs and Aliases (PR #74902)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/74902 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [libcxx] [flang] [compiler-rt] [openmp] [lld] [clang-tools-extra] [libc] [libcxxabi] [clang] [mlir] [lldb] [builtins][arm64] Build __init_cpu_features_resolver on Apple pl
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73685 >From 603983e237e73b2d939bf9ee12e39ecc7983f7f1 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Wed, 29 Nov 2023 14:21:54 -0800 Subject: [PATCH] add a note about the dispatch_once block Created using spr 1.3.4 --- compiler-rt/lib/builtins/cpu_model.c | 8 1 file changed, 8 insertions(+) diff --git a/compiler-rt/lib/builtins/cpu_model.c b/compiler-rt/lib/builtins/cpu_model.c index 5f5182859080c4..001467a9f7ff51 100644 --- a/compiler-rt/lib/builtins/cpu_model.c +++ b/compiler-rt/lib/builtins/cpu_model.c @@ -1285,6 +1285,14 @@ static bool isKnownAndSupported(const char *name) { } void __init_cpu_features_resolver(void) { + // On Darwin platforms, this may be called concurrently by multiple threads + // because the resolvers that use it are called lazily at runtime (unlike on + // ELF platforms, where IFuncs are resolved serially at load time). This + // function's effect on __aarch64_cpu_features should be idempotent, but even + // so we need dispatch_once to resolve the race condition. Dispatch is + // available through libSystem, which we need anyway for the sysctl, so this + // does not add a new dependency. + static dispatch_once_t onceToken = 0; dispatch_once(&onceToken, ^{ // https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [llvm] [clang] [libcxxabi] [clang-tools-extra] [compiler-rt] [libcxx] [lld] [lldb] [openmp] [libc] [mlir] [builtins][arm64] Build __init_cpu_features_resolver on Apple pl
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73685 >From 603983e237e73b2d939bf9ee12e39ecc7983f7f1 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Wed, 29 Nov 2023 14:21:54 -0800 Subject: [PATCH] add a note about the dispatch_once block Created using spr 1.3.4 --- compiler-rt/lib/builtins/cpu_model.c | 8 1 file changed, 8 insertions(+) diff --git a/compiler-rt/lib/builtins/cpu_model.c b/compiler-rt/lib/builtins/cpu_model.c index 5f5182859080c4..001467a9f7ff51 100644 --- a/compiler-rt/lib/builtins/cpu_model.c +++ b/compiler-rt/lib/builtins/cpu_model.c @@ -1285,6 +1285,14 @@ static bool isKnownAndSupported(const char *name) { } void __init_cpu_features_resolver(void) { + // On Darwin platforms, this may be called concurrently by multiple threads + // because the resolvers that use it are called lazily at runtime (unlike on + // ELF platforms, where IFuncs are resolved serially at load time). This + // function's effect on __aarch64_cpu_features should be idempotent, but even + // so we need dispatch_once to resolve the race condition. Dispatch is + // available through libSystem, which we need anyway for the sysctl, so this + // does not add a new dependency. + static dispatch_once_t onceToken = 0; dispatch_once(&onceToken, ^{ // https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [openmp] [libcxxabi] [mlir] [flang] [clang-tools-extra] [libcxx] [lldb] [clang] [libc] [lld] [compiler-rt] [clang] Support __attribute__((ifunc(...))) on Darwin platforms
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73687 >From aeb39b92bbd7670fb8c6b9e76a456a92199691b3 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Wed, 29 Nov 2023 12:23:46 -0800 Subject: [PATCH] adjust tests per review feedback Created using spr 1.3.4 --- clang/test/CodeGen/attr-ifunc.c | 20 +++ clang/test/CodeGen/attr-ifunc.cpp | 4 .../CodeGenCXX/externc-ifunc-resolver.cpp | 2 ++ clang/test/SemaCXX/externc-ifunc-resolver.cpp | 4 4 files changed, 30 insertions(+) diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c index 4f8fe13530fdb7..2ad41edf20dfa0 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 5b5b2c14b4074b..b6e342df46eb58 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 0518a8dcc831dd..be4453ae7eb08c 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 aa44525bde2cae..6c6c262c5f09d8 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; } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lldb] [libc] [mlir] [llvm] [clang] [lld] [compiler-rt] [flang] [openmp] [clang-tools-extra] [libcxxabi] [libcxx] [clang] Support __attribute__((ifunc(...))) on Darwin platforms
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73687 >From aeb39b92bbd7670fb8c6b9e76a456a92199691b3 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Wed, 29 Nov 2023 12:23:46 -0800 Subject: [PATCH] adjust tests per review feedback Created using spr 1.3.4 --- clang/test/CodeGen/attr-ifunc.c | 20 +++ clang/test/CodeGen/attr-ifunc.cpp | 4 .../CodeGenCXX/externc-ifunc-resolver.cpp | 2 ++ clang/test/SemaCXX/externc-ifunc-resolver.cpp | 4 4 files changed, 30 insertions(+) diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c index 4f8fe13530fdb7..2ad41edf20dfa0 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 5b5b2c14b4074b..b6e342df46eb58 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 0518a8dcc831dd..be4453ae7eb08c 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 aa44525bde2cae..6c6c262c5f09d8 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; } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] [clang] [libcxx] [llvm] [libc] [mlir] [libcxxabi] [openmp] [lldb] [clang-tools-extra] [compiler-rt] [flang] [clang] Function Multi Versioning supports IFunc lowerings on Da
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73688 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [flang] [libc] [llvm] [clang] [compiler-rt] [GlobalISel] Always direct-call IFuncs and Aliases (PR #74902)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/74902 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [libc] [openmp] [lld] [compiler-rt] [libcxxabi] [clang] [libcxx] [lldb] [mlir] [flang] [llvm] [clang] Function Multi Versioning supports IFunc lowerings on Da
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73688 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] [clang] [clang-tools-extra] [llvm] [libc] [flang] [GlobalISel] Always direct-call IFuncs and Aliases (PR #74902)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/74902 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] [libc] [compiler-rt] [clang] [openmp] [clang-tools-extra] [lldb] [flang] [libcxxabi] [libcxx] [mlir] [llvm] [builtins][arm64] Build __init_cpu_features_resolver on Apple pl
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73685 >From 603983e237e73b2d939bf9ee12e39ecc7983f7f1 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Wed, 29 Nov 2023 14:21:54 -0800 Subject: [PATCH] add a note about the dispatch_once block Created using spr 1.3.4 --- compiler-rt/lib/builtins/cpu_model.c | 8 1 file changed, 8 insertions(+) diff --git a/compiler-rt/lib/builtins/cpu_model.c b/compiler-rt/lib/builtins/cpu_model.c index 5f5182859080c4..001467a9f7ff51 100644 --- a/compiler-rt/lib/builtins/cpu_model.c +++ b/compiler-rt/lib/builtins/cpu_model.c @@ -1285,6 +1285,14 @@ static bool isKnownAndSupported(const char *name) { } void __init_cpu_features_resolver(void) { + // On Darwin platforms, this may be called concurrently by multiple threads + // because the resolvers that use it are called lazily at runtime (unlike on + // ELF platforms, where IFuncs are resolved serially at load time). This + // function's effect on __aarch64_cpu_features should be idempotent, but even + // so we need dispatch_once to resolve the race condition. Dispatch is + // available through libSystem, which we need anyway for the sysctl, so this + // does not add a new dependency. + static dispatch_once_t onceToken = 0; dispatch_once(&onceToken, ^{ // https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libcxx] [lldb] [compiler-rt] [clang] [libcxxabi] [llvm] [mlir] [flang] [clang-tools-extra] [lld] [openmp] [builtins][arm64] Build __init_cpu_features_resolver on Apple pl
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73685 >From 603983e237e73b2d939bf9ee12e39ecc7983f7f1 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Wed, 29 Nov 2023 14:21:54 -0800 Subject: [PATCH] add a note about the dispatch_once block Created using spr 1.3.4 --- compiler-rt/lib/builtins/cpu_model.c | 8 1 file changed, 8 insertions(+) diff --git a/compiler-rt/lib/builtins/cpu_model.c b/compiler-rt/lib/builtins/cpu_model.c index 5f5182859080c4..001467a9f7ff51 100644 --- a/compiler-rt/lib/builtins/cpu_model.c +++ b/compiler-rt/lib/builtins/cpu_model.c @@ -1285,6 +1285,14 @@ static bool isKnownAndSupported(const char *name) { } void __init_cpu_features_resolver(void) { + // On Darwin platforms, this may be called concurrently by multiple threads + // because the resolvers that use it are called lazily at runtime (unlike on + // ELF platforms, where IFuncs are resolved serially at load time). This + // function's effect on __aarch64_cpu_features should be idempotent, but even + // so we need dispatch_once to resolve the race condition. Dispatch is + // available through libSystem, which we need anyway for the sysctl, so this + // does not add a new dependency. + static dispatch_once_t onceToken = 0; dispatch_once(&onceToken, ^{ // https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [lldb] [lld] [libcxxabi] [openmp] [libcxx] [llvm] [compiler-rt] [clang] [mlir] [clang-tools-extra] [libc] [clang] Support __attribute__((ifunc(...))) on Darwin platforms
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73687 >From aeb39b92bbd7670fb8c6b9e76a456a92199691b3 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Wed, 29 Nov 2023 12:23:46 -0800 Subject: [PATCH] adjust tests per review feedback Created using spr 1.3.4 --- clang/test/CodeGen/attr-ifunc.c | 20 +++ clang/test/CodeGen/attr-ifunc.cpp | 4 .../CodeGenCXX/externc-ifunc-resolver.cpp | 2 ++ clang/test/SemaCXX/externc-ifunc-resolver.cpp | 4 4 files changed, 30 insertions(+) diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c index 4f8fe13530fdb7..2ad41edf20dfa0 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 5b5b2c14b4074b..b6e342df46eb58 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 0518a8dcc831dd..be4453ae7eb08c 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 aa44525bde2cae..6c6c262c5f09d8 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; } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [llvm] [libc] [flang] [lldb] [compiler-rt] [clang] [mlir] [GlobalISel] Always direct-call IFuncs and Aliases (PR #74902)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/74902 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [llvm] [clang-tools-extra] [compiler-rt] [mlir] [libc] [clang] [lldb] [GlobalISel] Always direct-call IFuncs and Aliases (PR #74902)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/74902 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] [llvm] [libcxxabi] [lld] [libc] [libcxx] [lldb] [flang] [openmp] [clang-tools-extra] [mlir] [clang] [clang] Support __attribute__((ifunc(...))) on Darwin platforms
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73687 >From aeb39b92bbd7670fb8c6b9e76a456a92199691b3 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Wed, 29 Nov 2023 12:23:46 -0800 Subject: [PATCH] adjust tests per review feedback Created using spr 1.3.4 --- clang/test/CodeGen/attr-ifunc.c | 20 +++ clang/test/CodeGen/attr-ifunc.cpp | 4 .../CodeGenCXX/externc-ifunc-resolver.cpp | 2 ++ clang/test/SemaCXX/externc-ifunc-resolver.cpp | 4 4 files changed, 30 insertions(+) diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c index 4f8fe13530fdb7..2ad41edf20dfa0 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 5b5b2c14b4074b..b6e342df46eb58 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 0518a8dcc831dd..be4453ae7eb08c 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 aa44525bde2cae..6c6c262c5f09d8 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; } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [libc] [compiler-rt] [flang] [clang] [libcxx] [libcxxabi] [lld] [lldb] [openmp] [llvm] [mlir] [clang] Function Multi Versioning supports IFunc lowerings on Da
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73688 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [lld] [mlir] [llvm] [flang] [lldb] [openmp] [clang-tools-extra] [compiler-rt] [libcxxabi] [libcxx] [clang] [builtins][arm64] Build __init_cpu_features_resolver on Apple pl
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73685 >From 603983e237e73b2d939bf9ee12e39ecc7983f7f1 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Wed, 29 Nov 2023 14:21:54 -0800 Subject: [PATCH] add a note about the dispatch_once block Created using spr 1.3.4 --- compiler-rt/lib/builtins/cpu_model.c | 8 1 file changed, 8 insertions(+) diff --git a/compiler-rt/lib/builtins/cpu_model.c b/compiler-rt/lib/builtins/cpu_model.c index 5f5182859080c4..001467a9f7ff51 100644 --- a/compiler-rt/lib/builtins/cpu_model.c +++ b/compiler-rt/lib/builtins/cpu_model.c @@ -1285,6 +1285,14 @@ static bool isKnownAndSupported(const char *name) { } void __init_cpu_features_resolver(void) { + // On Darwin platforms, this may be called concurrently by multiple threads + // because the resolvers that use it are called lazily at runtime (unlike on + // ELF platforms, where IFuncs are resolved serially at load time). This + // function's effect on __aarch64_cpu_features should be idempotent, but even + // so we need dispatch_once to resolve the race condition. Dispatch is + // available through libSystem, which we need anyway for the sysctl, so this + // does not add a new dependency. + static dispatch_once_t onceToken = 0; dispatch_once(&onceToken, ^{ // https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [openmp] [libc] [flang] [lld] [compiler-rt] [lldb] [libcxx] [libcxxabi] [clang] [mlir] [clang-tools-extra] [llvm] [builtins][arm64] Build __init_cpu_features_resolver on Apple pl
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73685 >From 603983e237e73b2d939bf9ee12e39ecc7983f7f1 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Wed, 29 Nov 2023 14:21:54 -0800 Subject: [PATCH] add a note about the dispatch_once block Created using spr 1.3.4 --- compiler-rt/lib/builtins/cpu_model.c | 8 1 file changed, 8 insertions(+) diff --git a/compiler-rt/lib/builtins/cpu_model.c b/compiler-rt/lib/builtins/cpu_model.c index 5f5182859080c4..001467a9f7ff51 100644 --- a/compiler-rt/lib/builtins/cpu_model.c +++ b/compiler-rt/lib/builtins/cpu_model.c @@ -1285,6 +1285,14 @@ static bool isKnownAndSupported(const char *name) { } void __init_cpu_features_resolver(void) { + // On Darwin platforms, this may be called concurrently by multiple threads + // because the resolvers that use it are called lazily at runtime (unlike on + // ELF platforms, where IFuncs are resolved serially at load time). This + // function's effect on __aarch64_cpu_features should be idempotent, but even + // so we need dispatch_once to resolve the race condition. Dispatch is + // available through libSystem, which we need anyway for the sysctl, so this + // does not add a new dependency. + static dispatch_once_t onceToken = 0; dispatch_once(&onceToken, ^{ // https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lldb] [compiler-rt] [libcxx] [lld] [clang-tools-extra] [flang] [openmp] [llvm] [clang] [libc] [libcxxabi] [mlir] [clang] Function Multi Versioning supports IFunc lowerings on Da
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73688 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [LivePhysRegs] Add callee-saved regs from MFI in addLiveOutsNoPristines. (PR #73553)
fhahn wrote: Thanks for all the feedback. I created #75527 which uses the approach based on https://gist.github.com/fhahn/67937125b64440a8a414909c4a1b7973 with the tweak suggested by @efriedma-quic https://github.com/llvm/llvm-project/pull/73553 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [LivePhysRegs] Add callee-saved regs from MFI in addLiveOutsNoPristines. (PR #73553)
https://github.com/fhahn closed https://github.com/llvm/llvm-project/pull/73553 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [libc] [flang] [llvm] [clang-tools-extra] [openmp] [compiler-rt] [lldb] [mlir] [GlobalISel] Always direct-call IFuncs and Aliases (PR #74902)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/74902 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [lldb] [mlir] [flang] [openmp] [llvm] [clang-tools-extra] [clang] [compiler-rt] [GlobalISel] Always direct-call IFuncs and Aliases (PR #74902)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/74902 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [lldb] [llvm] [openmp] [libcxx] [mlir] [compiler-rt] [libcxxabi] [libc] [lld] [clang-tools-extra] [clang] [clang] Function Multi Versioning supports IFunc lowerings on Da
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73688 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxxabi] [compiler-rt] [flang] [libc] [openmp] [lld] [libcxx] [lldb] [clang] [mlir] [clang-tools-extra] [llvm] [builtins][arm64] Build __init_cpu_features_resolver on Apple pl
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73685 >From 603983e237e73b2d939bf9ee12e39ecc7983f7f1 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Wed, 29 Nov 2023 14:21:54 -0800 Subject: [PATCH] add a note about the dispatch_once block Created using spr 1.3.4 --- compiler-rt/lib/builtins/cpu_model.c | 8 1 file changed, 8 insertions(+) diff --git a/compiler-rt/lib/builtins/cpu_model.c b/compiler-rt/lib/builtins/cpu_model.c index 5f5182859080c4..001467a9f7ff51 100644 --- a/compiler-rt/lib/builtins/cpu_model.c +++ b/compiler-rt/lib/builtins/cpu_model.c @@ -1285,6 +1285,14 @@ static bool isKnownAndSupported(const char *name) { } void __init_cpu_features_resolver(void) { + // On Darwin platforms, this may be called concurrently by multiple threads + // because the resolvers that use it are called lazily at runtime (unlike on + // ELF platforms, where IFuncs are resolved serially at load time). This + // function's effect on __aarch64_cpu_features should be idempotent, but even + // so we need dispatch_once to resolve the race condition. Dispatch is + // available through libSystem, which we need anyway for the sysctl, so this + // does not add a new dependency. + static dispatch_once_t onceToken = 0; dispatch_once(&onceToken, ^{ // https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [libcxx] [clang-tools-extra] [libc] [lld] [lldb] [openmp] [mlir] [compiler-rt] [flang] [libcxxabi] [llvm] [builtins][arm64] Build __init_cpu_features_resolver on Apple pl
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73685 >From 603983e237e73b2d939bf9ee12e39ecc7983f7f1 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Wed, 29 Nov 2023 14:21:54 -0800 Subject: [PATCH] add a note about the dispatch_once block Created using spr 1.3.4 --- compiler-rt/lib/builtins/cpu_model.c | 8 1 file changed, 8 insertions(+) diff --git a/compiler-rt/lib/builtins/cpu_model.c b/compiler-rt/lib/builtins/cpu_model.c index 5f5182859080c4..001467a9f7ff51 100644 --- a/compiler-rt/lib/builtins/cpu_model.c +++ b/compiler-rt/lib/builtins/cpu_model.c @@ -1285,6 +1285,14 @@ static bool isKnownAndSupported(const char *name) { } void __init_cpu_features_resolver(void) { + // On Darwin platforms, this may be called concurrently by multiple threads + // because the resolvers that use it are called lazily at runtime (unlike on + // ELF platforms, where IFuncs are resolved serially at load time). This + // function's effect on __aarch64_cpu_features should be idempotent, but even + // so we need dispatch_once to resolve the race condition. Dispatch is + // available through libSystem, which we need anyway for the sysctl, so this + // does not add a new dependency. + static dispatch_once_t onceToken = 0; dispatch_once(&onceToken, ^{ // https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxxabi] [compiler-rt] [lld] [flang] [clang] [llvm] [lldb] [openmp] [mlir] [clang-tools-extra] [libc] [libcxx] [clang] Function Multi Versioning supports IFunc lowerings on Da
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/73688 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits