r367119 - [ARM] Set default alignment to 64bits
Author: simpal01 Date: Fri Jul 26 08:05:19 2019 New Revision: 367119 URL: http://llvm.org/viewvc/llvm-project?rev=367119&view=rev Log: [ARM] Set default alignment to 64bits The maximum alignment used by ARM arch is 64bits, not 128. This could cause overaligned memory access for 128 bit neon vector that have unpredictable behaviour. This fixes: https://bugs.llvm.org/show_bug.cgi?id=42668 Patch by: Diogo Sampaio(diogo.samp...@arm.com) Differential Revision: https://reviews.llvm.org/D65000 Change-Id: I5a62b766491f15dd51e4cfe6625929db897f67e3 Added: cfe/trunk/test/CodeGen/ARM/ cfe/trunk/test/CodeGen/ARM/exception-alignment.cpp Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp cfe/trunk/test/SemaCXX/warn-overaligned-type-thrown.cpp Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=367119&r1=367118&r2=367119&view=diff == --- cfe/trunk/lib/Basic/Targets/ARM.cpp (original) +++ cfe/trunk/lib/Basic/Targets/ARM.cpp Fri Jul 26 08:05:19 2019 @@ -309,8 +309,9 @@ ARMTargetInfo::ARMTargetInfo(const llvm: setAtomic(); // Maximum alignment for ARM NEON data types should be 64-bits (AAPCS) + // as well the default alignment if (IsAAPCS && (Triple.getEnvironment() != llvm::Triple::Android)) -MaxVectorAlign = 64; +DefaultAlignForAttributeAligned = MaxVectorAlign = 64; // Do force alignment of members that follow zero length bitfields. If // the alignment of the zero-length bitfield is greater than the member Added: cfe/trunk/test/CodeGen/ARM/exception-alignment.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ARM/exception-alignment.cpp?rev=367119&view=auto == --- cfe/trunk/test/CodeGen/ARM/exception-alignment.cpp (added) +++ cfe/trunk/test/CodeGen/ARM/exception-alignment.cpp Fri Jul 26 08:05:19 2019 @@ -0,0 +1,19 @@ +// Bug: https://bugs.llvm.org/show_bug.cgi?id=42668 +// REQUIRES: arm-registered-target +// RUN: %clang --target=arm-arm-none-eabi -march=armv8-a -S -emit-llvm -Os -o - %s | FileCheck --check-prefixes=CHECK,A8 %s +// RUN: %clang --target=arm-linux-androideabi -march=armv8-a -S -emit-llvm -Os -o - %s | FileCheck --check-prefixes=CHECK,A16 %s +// CHECK: [[E:%[A-z0-9]+]] = tail call i8* @__cxa_allocate_exception +// CHECK-NEXT: [[BC:%[A-z0-9]+]] = bitcast i8* [[E]] to <2 x i64>* +// A8-NEXT: store <2 x i64> , <2 x i64>* [[BC]], align 8 +// A16-NEXT: store <2 x i64> , <2 x i64>* [[BC]], align 16 +#include + +int main(void) { + try { +throw vld1q_u64(((const uint64_t[2]){1, 2})); + } catch (uint64x2_t exc) { +return 0; + } + return 1; +} + Modified: cfe/trunk/test/SemaCXX/warn-overaligned-type-thrown.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-overaligned-type-thrown.cpp?rev=367119&r1=367118&r2=367119&view=diff == --- cfe/trunk/test/SemaCXX/warn-overaligned-type-thrown.cpp (original) +++ cfe/trunk/test/SemaCXX/warn-overaligned-type-thrown.cpp Fri Jul 26 08:05:19 2019 @@ -2,11 +2,12 @@ // RUN: %clang_cc1 -triple arm64-apple-ios10 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s // RUN: %clang_cc1 -triple arm64-apple-tvos10 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s // RUN: %clang_cc1 -triple arm64-apple-watchos4 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s +// RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s // RUN: %clang_cc1 -triple x86_64-apple-macosx10.14 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s // RUN: %clang_cc1 -triple arm64-apple-ios12 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s // RUN: %clang_cc1 -triple arm64-apple-tvos12 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s // RUN: %clang_cc1 -triple arm64-apple-watchos5 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s -// RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s +// RUN: %clang_cc1 -triple arm-linux-androideabi -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s // RUN: %clang_cc1 -triple aarch64-linux-gnueabi -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s // RUN: %clang_cc1 -triple mipsel-linux-gnu -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s // RUN: %clang_cc1 -triple mips64el-linux-gnu -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] fa8aeab - [AArch64] Add support for the Cortex-A715 CPU
Author: Simi Pallipurath Date: 2022-11-03T09:28:46Z New Revision: fa8aeab606c1ca2756bf8b6a451998f20671ce52 URL: https://github.com/llvm/llvm-project/commit/fa8aeab606c1ca2756bf8b6a451998f20671ce52 DIFF: https://github.com/llvm/llvm-project/commit/fa8aeab606c1ca2756bf8b6a451998f20671ce52.diff LOG: [AArch64] Add support for the Cortex-A715 CPU Cortex-A715 is an Armv9-A AArch64 CPU. This patch introduces support for Cortex-A715. Technical Reference Manual: https://developer.arm.com/documentation/101590/latest. Reviewed By: vhscampos Differential Revision: https://reviews.llvm.org/D136957 Added: Modified: clang/docs/ReleaseNotes.rst clang/test/Driver/aarch64-mcpu.c clang/test/Misc/target-invalid-cpu-note.c llvm/docs/ReleaseNotes.rst llvm/include/llvm/Support/AArch64TargetParser.def llvm/lib/Support/Host.cpp llvm/lib/Target/AArch64/AArch64.td llvm/lib/Target/AArch64/AArch64Subtarget.cpp llvm/lib/Target/AArch64/AArch64Subtarget.h llvm/unittests/Support/TargetParserTest.cpp Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 435d9ded7c72e..763f4cece4634 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -733,6 +733,9 @@ Arm and AArch64 Support in Clang them, which it cannot. - Add driver and tuning support for Neoverse V2 via the flag ``-mcpu=neoverse-v2``. Native detection is also supported via ``-mcpu=native``. +- Support has been added for the following processors (-mcpu identifiers in parenthesis): + + * Arm Cortex-A715 (cortex-a715). Floating Point Support in Clang --- diff --git a/clang/test/Driver/aarch64-mcpu.c b/clang/test/Driver/aarch64-mcpu.c index 0433f6a5b3d3f..b40c579acdf00 100644 --- a/clang/test/Driver/aarch64-mcpu.c +++ b/clang/test/Driver/aarch64-mcpu.c @@ -45,6 +45,8 @@ // CORTEXA78: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a78" // RUN: %clang -target aarch64 -mcpu=cortex-a78c -### -c %s 2>&1 | FileCheck -check-prefix=CORTEX-A78C %s // CORTEX-A78C: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a78c" +// RUN: %clang -target aarch64 -mcpu=cortex-a715 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEX-A715 %s +// CORTEX-A715: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a715" // RUN: %clang -target aarch64 -mcpu=neoverse-e1 -### -c %s 2>&1 | FileCheck -check-prefix=NEOVERSE-E1 %s // NEOVERSE-E1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "neoverse-e1" // RUN: %clang -target aarch64 -mcpu=neoverse-v1 -### -c %s 2>&1 | FileCheck -check-prefix=NEOVERSE-V1 %s diff --git a/clang/test/Misc/target-invalid-cpu-note.c b/clang/test/Misc/target-invalid-cpu-note.c index f2071c866956f..c0b542086a752 100644 --- a/clang/test/Misc/target-invalid-cpu-note.c +++ b/clang/test/Misc/target-invalid-cpu-note.c @@ -5,11 +5,11 @@ // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AARCH64 // AARCH64: error: unknown target CPU 'not-a-cpu' -// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-m1, apple-m2, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, grace{{$}} +// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-a715, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-m1, apple-m2, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, grace{{$}} // RUN: not %clang_cc1 -triple arm64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_AARCH64 // TUNE_AARCH64: error: unknown target CPU 'not-a-cpu' -// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, cortex-a65ae,
[clang] c1873d8 - [Clang][Driver] Pass through the --be8 endian flag to linker in BareMetal driver For Arm.
Author: Simi Pallipurath Date: 2023-07-19T09:37:40+01:00 New Revision: c1873d84a3316fa03326e9157e799b81f63d7a10 URL: https://github.com/llvm/llvm-project/commit/c1873d84a3316fa03326e9157e799b81f63d7a10 DIFF: https://github.com/llvm/llvm-project/commit/c1873d84a3316fa03326e9157e799b81f63d7a10.diff LOG: [Clang][Driver] Pass through the --be8 endian flag to linker in BareMetal driver For Arm. When linking a big-endian image for Arm, clang has to select between BE8 and BE32 formats. The default is dependent on the selected target architecture. For ARMv6 and later architectures the default is BE8, for older architectures the default is BE32. For BE8 and BE32, compiler outputs a big endian ELF relocatable object file with the instructions and data both big endian. The difference is that at link time, for BE8 a linker must endian reverse the instructions to little endian. For BE8, the clang has to pass --be8 to the linker for Arm. At the moment clang is not passing the --be8 flag to linker for the baremetal target architectures above ArmV6 for Arm. This patch passes through --be8 and -BE or EL to the linker, taking into account the target and the -mbig-endian and -mlittle-endian flag. Also there are few more changes in the baremetal driver so that the code can cope with AArch64 being big-endian as well. Reviewed By: michaelplatings, MaskRay Differential Revision: https://reviews.llvm.org/D154786 Added: Modified: clang/lib/Driver/ToolChains/Arch/ARM.cpp clang/lib/Driver/ToolChains/Arch/ARM.h clang/lib/Driver/ToolChains/BareMetal.cpp clang/lib/Driver/ToolChains/Gnu.cpp clang/test/Driver/baremetal.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp index 15b370fa7d0144..1893bde99cd8bf 100644 --- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -32,6 +32,20 @@ bool arm::isARMMProfile(const llvm::Triple &Triple) { return llvm::ARM::parseArchProfile(Arch) == llvm::ARM::ProfileKind::M; } +// On Arm the endianness of the output file is determined by the target and +// can be overridden by the pseudo-target flags '-mlittle-endian'/'-EL' and +// '-mbig-endian'/'-EB'. Unlike other targets the flag does not result in a +// normalized triple so we must handle the flag here. +bool arm::isARMBigEndian(const llvm::Triple &Triple, const ArgList &Args) { + if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian, + options::OPT_mbig_endian)) { +return !A->getOption().matches(options::OPT_mlittle_endian); + } + + return Triple.getArch() == llvm::Triple::armeb || + Triple.getArch() == llvm::Triple::thumbeb; +} + // True if A-profile. bool arm::isARMAProfile(const llvm::Triple &Triple) { llvm::StringRef Arch = Triple.getArchName(); diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.h b/clang/lib/Driver/ToolChains/Arch/ARM.h index 83a4da6844677f..fa62ac89e3a138 100644 --- a/clang/lib/Driver/ToolChains/Arch/ARM.h +++ b/clang/lib/Driver/ToolChains/Arch/ARM.h @@ -11,6 +11,7 @@ #include "clang/Driver/ToolChain.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Option/ArgList.h" #include "llvm/Option/Option.h" #include "llvm/TargetParser/ARMTargetParser.h" #include "llvm/TargetParser/Triple.h" @@ -73,6 +74,7 @@ llvm::ARM::FPUKind getARMTargetFeatures(const Driver &D, int getARMSubArchVersionNumber(const llvm::Triple &Triple); bool isARMMProfile(const llvm::Triple &Triple); bool isARMAProfile(const llvm::Triple &Triple); +bool isARMBigEndian(const llvm::Triple &Triple, const llvm::opt::ArgList &Args); } // end namespace arm } // end namespace tools diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp index a4bd4bb0f6fb76..0d9a103328c130 100644 --- a/clang/lib/Driver/ToolChains/BareMetal.cpp +++ b/clang/lib/Driver/ToolChains/BareMetal.cpp @@ -12,6 +12,7 @@ #include "Gnu.h" #include "clang/Driver/InputInfo.h" +#include "Arch/ARM.h" #include "Arch/RISCV.h" #include "clang/Driver/Compilation.h" #include "clang/Driver/Driver.h" @@ -115,10 +116,12 @@ BareMetal::BareMetal(const Driver &D, const llvm::Triple &Triple, } } -/// Is the triple {arm,thumb}-none-none-{eabi,eabihf} ? +/// Is the triple {arm,armeb,thumb,thumbeb}-none-none-{eabi,eabihf} ? static bool isARMBareMetal(const llvm::Triple &Triple) { if (Triple.getArch() != llvm::Triple::arm && - Triple.getArch() != llvm::Triple::thumb) + Triple.getArch() != llvm::Triple::thumb && + Triple.getArch() != llvm::Triple::armeb && + Triple.getArch() != llvm::Triple::thumbeb) return false; if (Triple.getVendor() != llvm::Triple::UnknownVendor) @@ -134,9 +137,10 @@ static bool isARMBareMetal(const llvm::Triple &Triple) { return true; } -/// Is the triple aarch64-none-elf? +/// Is the triple {aarch64.aa
[clang] 9dcd232 - [clang][driver][NFC] Call IsARMBigEndain function only for isARM and isThumb.
Author: Simi Pallipurath Date: 2023-07-25T09:20:59+01:00 New Revision: 9dcd232f4afabdad46e5bc2d71834765acd7738c URL: https://github.com/llvm/llvm-project/commit/9dcd232f4afabdad46e5bc2d71834765acd7738c DIFF: https://github.com/llvm/llvm-project/commit/9dcd232f4afabdad46e5bc2d71834765acd7738c.diff LOG: [clang][driver][NFC] Call IsARMBigEndain function only for isARM and isThumb. IsARMBIgEndian function returns true only if: 1. The triples are either arm or thumb and the commandline has the option -mbig-endian 2. The triples are either armeb or thumbeb. Missing the checking of arm or thumb triples in the first case pass through the --be8 endian flag to linker For AArch64 as well which is not expected. This is the regression happened from the previous patch https://reviews.llvm.org/D154786. It is better to refactor to only call IsARMBigEndian for isARM and isthumb satisfying conditions which keeps ARM and AArch64 separate. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D155808 Added: Modified: clang/lib/Driver/ToolChains/BareMetal.cpp clang/lib/Driver/ToolChains/Gnu.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp index 0d9a103328c130..26a6276ae50aa1 100644 --- a/clang/lib/Driver/ToolChains/BareMetal.cpp +++ b/clang/lib/Driver/ToolChains/BareMetal.cpp @@ -443,12 +443,13 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-Bstatic"); - if (Triple.isARM() || Triple.isThumb() || Triple.isAArch64()) { + if (Triple.isARM() || Triple.isThumb()) { bool IsBigEndian = arm::isARMBigEndian(Triple, Args); if (IsBigEndian) arm::appendBE8LinkFlag(Args, CmdArgs, Triple); -IsBigEndian = IsBigEndian || Arch == llvm::Triple::aarch64_be; CmdArgs.push_back(IsBigEndian ? "-EB" : "-EL"); + } else if (Triple.isAArch64()) { +CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL"); } Args.AddAllArgs(CmdArgs, diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index b58a607d5921cb..b64fff8b14be8a 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -424,12 +424,13 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, if (Args.hasArg(options::OPT_s)) CmdArgs.push_back("-s"); - if (Triple.isARM() || Triple.isThumb() || Triple.isAArch64()) { + if (Triple.isARM() || Triple.isThumb()) { bool IsBigEndian = arm::isARMBigEndian(Triple, Args); if (IsBigEndian) arm::appendBE8LinkFlag(Args, CmdArgs, Triple); -IsBigEndian = IsBigEndian || Arch == llvm::Triple::aarch64_be; CmdArgs.push_back(IsBigEndian ? "-EB" : "-EL"); + } else if (Triple.isAArch64()) { +CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL"); } // Most Android ARM64 targets should enable the linker fix for erratum ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 3f75d38 - [clang] Improve hermeticity of clang header tests.
Author: Simi Pallipurath Date: 2023-07-31T08:25:36+01:00 New Revision: 3f75d38a4d4d9e30d6ad1f805b225f1e073d21e0 URL: https://github.com/llvm/llvm-project/commit/3f75d38a4d4d9e30d6ad1f805b225f1e073d21e0 DIFF: https://github.com/llvm/llvm-project/commit/3f75d38a4d4d9e30d6ad1f805b225f1e073d21e0.diff LOG: [clang] Improve hermeticity of clang header tests. At the moment the below header tests fail with the multilib error in LLVM Embedded Toolchain for Arm because there is no corresponding aarch64 big endian library variant exist. Specifying --sysroot to its own testing directory clang/test/Headers/Inputs (which does not have any dependency library) prevents these header tests from being located in standard library directories. 1. clang/test/Headers/arm-neon-header.c 2. clang/test/Headers/arm-fp16-header.c Reviewed By: michaelplatings Differential Revision: https://reviews.llvm.org/D156427 Added: Modified: clang/test/Headers/arm-fp16-header.c clang/test/Headers/arm-neon-header.c Removed: diff --git a/clang/test/Headers/arm-fp16-header.c b/clang/test/Headers/arm-fp16-header.c index 556854023dff89..b1a87faebfe0bd 100644 --- a/clang/test/Headers/arm-fp16-header.c +++ b/clang/test/Headers/arm-fp16-header.c @@ -1,20 +1,20 @@ -// RUN: %clang -fsyntax-only -ffreestanding --target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c89 -xc %s -// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding --target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c99 -xc %s -// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding --target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c11 -xc %s +// RUN: %clang -fsyntax-only -ffreestanding --target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c89 --sysroot=%S/Inputs -xc %s +// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding --target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c99 --sysroot=%S/Inputs -xc %s +// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding --target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c11 --sysroot=%S/Inputs -xc %s -// RUN: %clang -fsyntax-only -ffreestanding --target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c89 -xc %s -// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding --target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c99 -xc %s -// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding --target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c11 -xc %s +// RUN: %clang -fsyntax-only -ffreestanding --target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c89 --sysroot=%S/Inputs -xc %s +// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding --target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c99 --sysroot=%S/Inputs -xc %s +// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding --target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c11 --sysroot=%S/Inputs -xc %s -// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ --target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++98 -xc++ %s -// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ --target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++11 -xc++ %s -// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ --target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++14 -xc++ %s -// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ --target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++17 -xc++ %s +// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ --target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++98 --sysroot=%S/Inputs -xc++ %s +// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ --target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++11 --sysroot=%S/Inputs -xc++ %s +// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ --target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++14 --sysroot=%S/Inputs -xc++ %s +// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ --target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++17 --sysroot=%S/Inputs -xc++ %s -// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ --target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++98 -xc++ %s -// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ --target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++11 -xc++ %s -// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ --target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++14 -xc++ %s -// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ --target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++17 -xc++ %s +// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ --target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++98 --sysroot=%S/Inputs -xc++ %s +// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -n
[clang] [Clang][ARM]Ensure both -mno-unaligned-access and -munaligned-access are passed to multilib selection logic (PR #134099)
https://github.com/simpal01 updated https://github.com/llvm/llvm-project/pull/134099 >From 7f6302053575732f633c69bbf55f2624da1e8bf4 Mon Sep 17 00:00:00 2001 From: Simi Pallipurath Date: Wed, 2 Apr 2025 12:35:16 +0100 Subject: [PATCH 1/3] Refine multilib selection to handle alignment based on architecture features. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the multilib selection logic to bypass the alignment option based on each architecture’s feature set, rather than relying solely on command-line options. Previously, alignment option was bypassed only when -mno-unaligned-access was explicitly specified on the commandline. This change makes the selection more robust and architecture aware. --- clang/lib/Driver/ToolChain.cpp| 24 +-- .../test/Driver/print-multi-selection-flags.c | 6 + 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 8a922b283daf5..476026f82b32b 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -239,12 +239,12 @@ static void getAArch64MultilibFlags(const Driver &D, Result.push_back(BranchProtectionArg->getAsString(Args)); } - if (Arg *AlignArg = Args.getLastArg( - options::OPT_mstrict_align, options::OPT_mno_strict_align, - options::OPT_mno_unaligned_access, options::OPT_munaligned_access)) { -if (AlignArg->getOption().matches(options::OPT_mstrict_align) || -AlignArg->getOption().matches(options::OPT_mno_unaligned_access)) - Result.push_back(AlignArg->getAsString(Args)); + if (FeatureSet.contains("+strict-align")) { +Result.push_back("-mno-unaligned-access"); +Result.push_back("-mstrict-align"); + } else { +Result.push_back("-munaligned-access"); +Result.push_back("-mno-strict-align"); } if (Arg *Endian = Args.getLastArg(options::OPT_mbig_endian, @@ -313,12 +313,12 @@ static void getARMMultilibFlags(const Driver &D, Result.push_back(BranchProtectionArg->getAsString(Args)); } - if (Arg *AlignArg = Args.getLastArg( - options::OPT_mstrict_align, options::OPT_mno_strict_align, - options::OPT_mno_unaligned_access, options::OPT_munaligned_access)) { -if (AlignArg->getOption().matches(options::OPT_mstrict_align) || -AlignArg->getOption().matches(options::OPT_mno_unaligned_access)) - Result.push_back(AlignArg->getAsString(Args)); + if (FeatureSet.contains("+strict-align")) { +Result.push_back("-mno-unaligned-access"); +Result.push_back("-mstrict-align"); + } else { +Result.push_back("-munaligned-access"); +Result.push_back("-mno-strict-align"); } if (Arg *Endian = Args.getLastArg(options::OPT_mbig_endian, diff --git a/clang/test/Driver/print-multi-selection-flags.c b/clang/test/Driver/print-multi-selection-flags.c index 5a35ae374f011..b21c2d11c1009 100644 --- a/clang/test/Driver/print-multi-selection-flags.c +++ b/clang/test/Driver/print-multi-selection-flags.c @@ -69,9 +69,15 @@ // CHECK-BRANCH-PROTECTION: -mbranch-protection=standard // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -mno-unaligned-access | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -mno-unaligned-access | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s // CHECK-NO-UNALIGNED-ACCESS: -mno-unaligned-access +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -munaligned-access | FileCheck --check-prefix=CHECK-UNALIGNED-ACCESS %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf | FileCheck --check-prefix=CHECK-UNALIGNED-ACCESS %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -munaligned-access | FileCheck --check-prefix=CHECK-UNALIGNED-ACCESS %s +// CHECK-UNALIGNED-ACCESS: -munaligned-access + // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -mbig-endian | FileCheck --check-prefix=CHECK-BIG-ENDIAN %s // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -mbig-endian | FileCheck --check-prefix=CHECK-BIG-ENDIAN %s // CHECK-BIG-ENDIAN: -mbig-endian >From 0242cea7fc54c90c5fbb8a16628a14167d4377cc Mon Sep 17 00:00:00 2001 From: Simi Pallipurath Date: Wed, 2 Apr 2025 17:25:06 +0100 Subject: [PATCH 2/3] fixup! Test that test -mstrict-ali
[clang] [Clang][ARM]Ensure both -mno-unaligned-access and -munaligned-access are passed to multilib selection logic (PR #134099)
@@ -239,12 +239,12 @@ static void getAArch64MultilibFlags(const Driver &D, Result.push_back(BranchProtectionArg->getAsString(Args)); } - if (Arg *AlignArg = Args.getLastArg( - options::OPT_mstrict_align, options::OPT_mno_strict_align, - options::OPT_mno_unaligned_access, options::OPT_munaligned_access)) { -if (AlignArg->getOption().matches(options::OPT_mstrict_align) || -AlignArg->getOption().matches(options::OPT_mno_unaligned_access)) - Result.push_back(AlignArg->getAsString(Args)); + if (FeatureSet.contains("+strict-align")) { simpal01 wrote: Canonicalized unaligned access option to -mno-unaligned-access/-munaligned-access. multilib.yaml also uses the same options. https://github.com/llvm/llvm-project/pull/134099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][ARM]Ensure both -mno-unaligned-access and -munaligned-access are passed to multilib selection logic (PR #134099)
@@ -239,12 +239,10 @@ static void getAArch64MultilibFlags(const Driver &D, Result.push_back(BranchProtectionArg->getAsString(Args)); } - if (Arg *AlignArg = Args.getLastArg( - options::OPT_mstrict_align, options::OPT_mno_strict_align, - options::OPT_mno_unaligned_access, options::OPT_munaligned_access)) { -if (AlignArg->getOption().matches(options::OPT_mstrict_align) || -AlignArg->getOption().matches(options::OPT_mno_unaligned_access)) - Result.push_back(AlignArg->getAsString(Args)); + if (FeatureSet.contains("+strict-align")) { +Result.push_back("-mno-unaligned-access"); simpal01 wrote: Done https://github.com/llvm/llvm-project/pull/134099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][ARM]Ensure both -mno-unaligned-access and -munaligned-access are passed to multilib selection logic (PR #134099)
https://github.com/simpal01 updated https://github.com/llvm/llvm-project/pull/134099 >From 7f6302053575732f633c69bbf55f2624da1e8bf4 Mon Sep 17 00:00:00 2001 From: Simi Pallipurath Date: Wed, 2 Apr 2025 12:35:16 +0100 Subject: [PATCH 1/5] Refine multilib selection to handle alignment based on architecture features. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the multilib selection logic to bypass the alignment option based on each architecture’s feature set, rather than relying solely on command-line options. Previously, alignment option was bypassed only when -mno-unaligned-access was explicitly specified on the commandline. This change makes the selection more robust and architecture aware. --- clang/lib/Driver/ToolChain.cpp| 24 +-- .../test/Driver/print-multi-selection-flags.c | 6 + 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 8a922b283daf5..476026f82b32b 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -239,12 +239,12 @@ static void getAArch64MultilibFlags(const Driver &D, Result.push_back(BranchProtectionArg->getAsString(Args)); } - if (Arg *AlignArg = Args.getLastArg( - options::OPT_mstrict_align, options::OPT_mno_strict_align, - options::OPT_mno_unaligned_access, options::OPT_munaligned_access)) { -if (AlignArg->getOption().matches(options::OPT_mstrict_align) || -AlignArg->getOption().matches(options::OPT_mno_unaligned_access)) - Result.push_back(AlignArg->getAsString(Args)); + if (FeatureSet.contains("+strict-align")) { +Result.push_back("-mno-unaligned-access"); +Result.push_back("-mstrict-align"); + } else { +Result.push_back("-munaligned-access"); +Result.push_back("-mno-strict-align"); } if (Arg *Endian = Args.getLastArg(options::OPT_mbig_endian, @@ -313,12 +313,12 @@ static void getARMMultilibFlags(const Driver &D, Result.push_back(BranchProtectionArg->getAsString(Args)); } - if (Arg *AlignArg = Args.getLastArg( - options::OPT_mstrict_align, options::OPT_mno_strict_align, - options::OPT_mno_unaligned_access, options::OPT_munaligned_access)) { -if (AlignArg->getOption().matches(options::OPT_mstrict_align) || -AlignArg->getOption().matches(options::OPT_mno_unaligned_access)) - Result.push_back(AlignArg->getAsString(Args)); + if (FeatureSet.contains("+strict-align")) { +Result.push_back("-mno-unaligned-access"); +Result.push_back("-mstrict-align"); + } else { +Result.push_back("-munaligned-access"); +Result.push_back("-mno-strict-align"); } if (Arg *Endian = Args.getLastArg(options::OPT_mbig_endian, diff --git a/clang/test/Driver/print-multi-selection-flags.c b/clang/test/Driver/print-multi-selection-flags.c index 5a35ae374f011..b21c2d11c1009 100644 --- a/clang/test/Driver/print-multi-selection-flags.c +++ b/clang/test/Driver/print-multi-selection-flags.c @@ -69,9 +69,15 @@ // CHECK-BRANCH-PROTECTION: -mbranch-protection=standard // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -mno-unaligned-access | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -mno-unaligned-access | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s // CHECK-NO-UNALIGNED-ACCESS: -mno-unaligned-access +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -munaligned-access | FileCheck --check-prefix=CHECK-UNALIGNED-ACCESS %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf | FileCheck --check-prefix=CHECK-UNALIGNED-ACCESS %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -munaligned-access | FileCheck --check-prefix=CHECK-UNALIGNED-ACCESS %s +// CHECK-UNALIGNED-ACCESS: -munaligned-access + // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -mbig-endian | FileCheck --check-prefix=CHECK-BIG-ENDIAN %s // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -mbig-endian | FileCheck --check-prefix=CHECK-BIG-ENDIAN %s // CHECK-BIG-ENDIAN: -mbig-endian >From 0242cea7fc54c90c5fbb8a16628a14167d4377cc Mon Sep 17 00:00:00 2001 From: Simi Pallipurath Date: Wed, 2 Apr 2025 17:25:06 +0100 Subject: [PATCH 2/5] fixup! Test that test -mstrict-ali
[clang] Bypass alignment option based on architecture features instead of command-line flags (PR #134099)
https://github.com/simpal01 edited https://github.com/llvm/llvm-project/pull/134099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Bypass alignment option based on architecture features instead of command-line flags (PR #134099)
https://github.com/simpal01 edited https://github.com/llvm/llvm-project/pull/134099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Bypass alignment option based on architecture features instead of command-line flags (PR #134099)
https://github.com/simpal01 edited https://github.com/llvm/llvm-project/pull/134099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Refine multilib selection to handle alignment based on architecture features. (PR #134099)
https://github.com/simpal01 created https://github.com/llvm/llvm-project/pull/134099 Update the multilib selection logic to bypass the alignment option based on each architecture’s feature set, rather than relying on command-line options. Previously, alignment option was bypassed only when -mno-unaligned-access was explicitly specified on the command line. This change makes the selection more robust and architecture aware. >From 7f6302053575732f633c69bbf55f2624da1e8bf4 Mon Sep 17 00:00:00 2001 From: Simi Pallipurath Date: Wed, 2 Apr 2025 12:35:16 +0100 Subject: [PATCH] Refine multilib selection to handle alignment based on architecture features. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the multilib selection logic to bypass the alignment option based on each architecture’s feature set, rather than relying solely on command-line options. Previously, alignment option was bypassed only when -mno-unaligned-access was explicitly specified on the commandline. This change makes the selection more robust and architecture aware. --- clang/lib/Driver/ToolChain.cpp| 24 +-- .../test/Driver/print-multi-selection-flags.c | 6 + 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 8a922b283daf5..476026f82b32b 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -239,12 +239,12 @@ static void getAArch64MultilibFlags(const Driver &D, Result.push_back(BranchProtectionArg->getAsString(Args)); } - if (Arg *AlignArg = Args.getLastArg( - options::OPT_mstrict_align, options::OPT_mno_strict_align, - options::OPT_mno_unaligned_access, options::OPT_munaligned_access)) { -if (AlignArg->getOption().matches(options::OPT_mstrict_align) || -AlignArg->getOption().matches(options::OPT_mno_unaligned_access)) - Result.push_back(AlignArg->getAsString(Args)); + if (FeatureSet.contains("+strict-align")) { +Result.push_back("-mno-unaligned-access"); +Result.push_back("-mstrict-align"); + } else { +Result.push_back("-munaligned-access"); +Result.push_back("-mno-strict-align"); } if (Arg *Endian = Args.getLastArg(options::OPT_mbig_endian, @@ -313,12 +313,12 @@ static void getARMMultilibFlags(const Driver &D, Result.push_back(BranchProtectionArg->getAsString(Args)); } - if (Arg *AlignArg = Args.getLastArg( - options::OPT_mstrict_align, options::OPT_mno_strict_align, - options::OPT_mno_unaligned_access, options::OPT_munaligned_access)) { -if (AlignArg->getOption().matches(options::OPT_mstrict_align) || -AlignArg->getOption().matches(options::OPT_mno_unaligned_access)) - Result.push_back(AlignArg->getAsString(Args)); + if (FeatureSet.contains("+strict-align")) { +Result.push_back("-mno-unaligned-access"); +Result.push_back("-mstrict-align"); + } else { +Result.push_back("-munaligned-access"); +Result.push_back("-mno-strict-align"); } if (Arg *Endian = Args.getLastArg(options::OPT_mbig_endian, diff --git a/clang/test/Driver/print-multi-selection-flags.c b/clang/test/Driver/print-multi-selection-flags.c index 5a35ae374f011..b21c2d11c1009 100644 --- a/clang/test/Driver/print-multi-selection-flags.c +++ b/clang/test/Driver/print-multi-selection-flags.c @@ -69,9 +69,15 @@ // CHECK-BRANCH-PROTECTION: -mbranch-protection=standard // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -mno-unaligned-access | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -mno-unaligned-access | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s // CHECK-NO-UNALIGNED-ACCESS: -mno-unaligned-access +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -munaligned-access | FileCheck --check-prefix=CHECK-UNALIGNED-ACCESS %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf | FileCheck --check-prefix=CHECK-UNALIGNED-ACCESS %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -munaligned-access | FileCheck --check-prefix=CHECK-UNALIGNED-ACCESS %s +// CHECK-UNALIGNED-ACCESS: -munaligned-access + // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -mbig-endian | FileCheck --check-prefix=CHECK-BIG-ENDIAN %s // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml
[clang] Refine multilib selection to handle alignment based on architecture features. (PR #134099)
https://github.com/simpal01 edited https://github.com/llvm/llvm-project/pull/134099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Bypass alignment option based on architecture features instead of command-line flags (PR #134099)
https://github.com/simpal01 edited https://github.com/llvm/llvm-project/pull/134099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Bypass alignment option based on architecture features instead of command-line flags (PR #134099)
https://github.com/simpal01 edited https://github.com/llvm/llvm-project/pull/134099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][ARM]Ensure both -mno-unaligned-access and -munaligned-access are passed to multilib selection logic (PR #134099)
https://github.com/simpal01 updated https://github.com/llvm/llvm-project/pull/134099 >From 7f6302053575732f633c69bbf55f2624da1e8bf4 Mon Sep 17 00:00:00 2001 From: Simi Pallipurath Date: Wed, 2 Apr 2025 12:35:16 +0100 Subject: [PATCH 1/4] Refine multilib selection to handle alignment based on architecture features. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the multilib selection logic to bypass the alignment option based on each architecture’s feature set, rather than relying solely on command-line options. Previously, alignment option was bypassed only when -mno-unaligned-access was explicitly specified on the commandline. This change makes the selection more robust and architecture aware. --- clang/lib/Driver/ToolChain.cpp| 24 +-- .../test/Driver/print-multi-selection-flags.c | 6 + 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 8a922b283daf5..476026f82b32b 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -239,12 +239,12 @@ static void getAArch64MultilibFlags(const Driver &D, Result.push_back(BranchProtectionArg->getAsString(Args)); } - if (Arg *AlignArg = Args.getLastArg( - options::OPT_mstrict_align, options::OPT_mno_strict_align, - options::OPT_mno_unaligned_access, options::OPT_munaligned_access)) { -if (AlignArg->getOption().matches(options::OPT_mstrict_align) || -AlignArg->getOption().matches(options::OPT_mno_unaligned_access)) - Result.push_back(AlignArg->getAsString(Args)); + if (FeatureSet.contains("+strict-align")) { +Result.push_back("-mno-unaligned-access"); +Result.push_back("-mstrict-align"); + } else { +Result.push_back("-munaligned-access"); +Result.push_back("-mno-strict-align"); } if (Arg *Endian = Args.getLastArg(options::OPT_mbig_endian, @@ -313,12 +313,12 @@ static void getARMMultilibFlags(const Driver &D, Result.push_back(BranchProtectionArg->getAsString(Args)); } - if (Arg *AlignArg = Args.getLastArg( - options::OPT_mstrict_align, options::OPT_mno_strict_align, - options::OPT_mno_unaligned_access, options::OPT_munaligned_access)) { -if (AlignArg->getOption().matches(options::OPT_mstrict_align) || -AlignArg->getOption().matches(options::OPT_mno_unaligned_access)) - Result.push_back(AlignArg->getAsString(Args)); + if (FeatureSet.contains("+strict-align")) { +Result.push_back("-mno-unaligned-access"); +Result.push_back("-mstrict-align"); + } else { +Result.push_back("-munaligned-access"); +Result.push_back("-mno-strict-align"); } if (Arg *Endian = Args.getLastArg(options::OPT_mbig_endian, diff --git a/clang/test/Driver/print-multi-selection-flags.c b/clang/test/Driver/print-multi-selection-flags.c index 5a35ae374f011..b21c2d11c1009 100644 --- a/clang/test/Driver/print-multi-selection-flags.c +++ b/clang/test/Driver/print-multi-selection-flags.c @@ -69,9 +69,15 @@ // CHECK-BRANCH-PROTECTION: -mbranch-protection=standard // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -mno-unaligned-access | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -mno-unaligned-access | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s // CHECK-NO-UNALIGNED-ACCESS: -mno-unaligned-access +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -munaligned-access | FileCheck --check-prefix=CHECK-UNALIGNED-ACCESS %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf | FileCheck --check-prefix=CHECK-UNALIGNED-ACCESS %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -munaligned-access | FileCheck --check-prefix=CHECK-UNALIGNED-ACCESS %s +// CHECK-UNALIGNED-ACCESS: -munaligned-access + // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -mbig-endian | FileCheck --check-prefix=CHECK-BIG-ENDIAN %s // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -mbig-endian | FileCheck --check-prefix=CHECK-BIG-ENDIAN %s // CHECK-BIG-ENDIAN: -mbig-endian >From 0242cea7fc54c90c5fbb8a16628a14167d4377cc Mon Sep 17 00:00:00 2001 From: Simi Pallipurath Date: Wed, 2 Apr 2025 17:25:06 +0100 Subject: [PATCH 2/4] fixup! Test that test -mstrict-ali