Author: Lucas Duarte Prates Date: 2024-08-29T09:11:48+01:00 New Revision: b822b69ff54bcd2f08445bd02b8dad0584422874
URL: https://github.com/llvm/llvm-project/commit/b822b69ff54bcd2f08445bd02b8dad0584422874 DIFF: https://github.com/llvm/llvm-project/commit/b822b69ff54bcd2f08445bd02b8dad0584422874.diff LOG: [Driver] Add -mbranch-protection to ARM and AArch64 multilib flags (#106391) This adds the `-mbranch-protection` command line option to the set of flags used by the multilib selection for ARM and AArch64 targets. Added: Modified: clang/lib/Driver/ToolChain.cpp clang/test/Driver/print-multi-selection-flags.c Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index c93c97146b6104..76901875c66959 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -221,6 +221,12 @@ static void getAArch64MultilibFlags(const Driver &D, assert(!ArchName.empty() && "at least one architecture should be found"); MArch.insert(MArch.begin(), ("-march=" + ArchName).str()); Result.push_back(llvm::join(MArch, "+")); + + const Arg *BranchProtectionArg = + Args.getLastArgNoClaim(options::OPT_mbranch_protection_EQ); + if (BranchProtectionArg) { + Result.push_back(BranchProtectionArg->getAsString(Args)); + } } static void getARMMultilibFlags(const Driver &D, @@ -268,6 +274,12 @@ static void getARMMultilibFlags(const Driver &D, case arm::FloatABI::Invalid: llvm_unreachable("Invalid float ABI"); } + + const Arg *BranchProtectionArg = + Args.getLastArgNoClaim(options::OPT_mbranch_protection_EQ); + if (BranchProtectionArg) { + Result.push_back(BranchProtectionArg->getAsString(Args)); + } } static void getRISCVMultilibFlags(const Driver &D, const llvm::Triple &Triple, diff --git a/clang/test/Driver/print-multi-selection-flags.c b/clang/test/Driver/print-multi-selection-flags.c index 2770a3ad5eaa1d..0116c7f5a03b9a 100644 --- a/clang/test/Driver/print-multi-selection-flags.c +++ b/clang/test/Driver/print-multi-selection-flags.c @@ -59,6 +59,10 @@ // CHECK-SVE2: --target=aarch64-unknown-none-elf // CHECK-SVE2: -march=armv{{.*}}-a{{.*}}+simd{{.*}}+sve{{.*}}+sve2{{.*}} +// RUN: %clang -print-multi-flags-experimental --target=arm-none-eabi -mbranch-protection=standard | FileCheck --check-prefix=CHECK-BRANCH-PROTECTION %s +// RUN: %clang -print-multi-flags-experimental --target=aarch64-none-elf -mbranch-protection=standard | FileCheck --check-prefix=CHECK-BRANCH-PROTECTION %s +// CHECK-BRANCH-PROTECTION: -mbranch-protection=standard + // RUN: %clang -print-multi-flags-experimental --target=riscv32-none-elf -march=rv32g | FileCheck --check-prefix=CHECK-RV32 %s // CHECK-RV32: --target=riscv32-unknown-none-elf // CHECK-RV32: -mabi=ilp32d _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits