From 776cac4c0a61f14d2dc2c92123b8600d57123c3d Mon Sep 17 00:00:00 2001 From: Oliver Stannard Date: Tue, 6 Aug 2024 12:35:20 +0100 Subject: [PATCH] [ARM] Enable cfi-icall for thumb triples Support for this was added back in 2016 (https://reviews.llvm.org/D27499), but never enabled in the driver. Since then, it's been possible to enable this with an arm triple and the -mthumb option, but not with a thumb triple. This also caused -fsanitise=cfi to enable cfi-icall for arm triple but not thumb triples, which caused spurious sanitiser failures if mixing the two ISAs in one program. --- clang/lib/Driver/ToolChain.cpp | 3 ++- clang/test/Driver/fsanitize.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 20a555afb8092f..2d50c2cbbc881c 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -1381,7 +1381,8 @@ SanitizerMask ToolChain::getSupportedSanitizers() const { SanitizerKind::Nullability | SanitizerKind::LocalBounds; if (getTriple().getArch() == llvm::Triple::x86 || getTriple().getArch() == llvm::Triple::x86_64 || - getTriple().getArch() == llvm::Triple::arm || getTriple().isWasm() || + getTriple().getArch() == llvm::Triple::arm || + getTriple().getArch() == llvm::Triple::thumb || getTriple().isWasm() || getTriple().isAArch64() || getTriple().isRISCV() || getTriple().isLoongArch64()) Res |= SanitizerKind::CFIICall; diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c index db14f6e195c64d..678fa432fb0a0a 100644 --- a/clang/test/Driver/fsanitize.c +++ b/clang/test/Driver/fsanitize.c @@ -611,6 +611,8 @@ // RUN: %clang --target=arm-linux-gnu -fvisibility=hidden -fsanitize=cfi -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI // RUN: %clang --target=aarch64-linux-gnu -fvisibility=hidden -fsanitize=cfi -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI // RUN: %clang --target=arm-linux-android -fvisibility=hidden -fsanitize=cfi -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI +// RUN: %clang --target=arm-none-eabi -fvisibility=hidden -fsanitize=cfi -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI +// RUN: %clang --target=thumb-none-eabi -fvisibility=hidden -fsanitize=cfi -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI // RUN: %clang --target=aarch64-linux-android -fvisibility=hidden -fsanitize=cfi -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI // RUN: %clang --target=aarch64_be -fvisibility=hidden -fsanitize=cfi -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI // RUN: %clang --target=riscv32 -fvisibility=hidden -fsanitize=cfi -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI