[llvm] 13a10e7 - [Driver][FreeBSD] Simplify ARM handling
Brad Smith via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 10 13:13:27 PST 2023
Author: Brad Smith
Date: 2023-03-10T16:10:44-05:00
New Revision: 13a10e7ec90a71c3665491231d468772c19a4b59
URL: https://github.com/llvm/llvm-project/commit/13a10e7ec90a71c3665491231d468772c19a4b59
DIFF: https://github.com/llvm/llvm-project/commit/13a10e7ec90a71c3665491231d468772c19a4b59.diff
LOG: [Driver][FreeBSD] Simplify ARM handling
Since FreeBSD 8 / 9 support was dropped from the Driver there is room to simplify
things with the ARM handling.
The exception model handling function can be removed.
EABI is now the default.
Reviewed By: dim
Differential Revision: https://reviews.llvm.org/D144823
Added:
Modified:
clang/lib/Basic/Targets/ARM.cpp
clang/lib/Driver/ToolChains/FreeBSD.cpp
clang/lib/Driver/ToolChains/FreeBSD.h
clang/test/Driver/arm-abi.c
clang/test/Driver/freebsd.c
llvm/lib/TargetParser/ARMTargetParser.cpp
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index f11751a760731..b85d5dc2d3478 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -254,6 +254,7 @@ ARMTargetInfo::ARMTargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: TargetInfo(Triple), FPMath(FP_Default), IsAAPCS(true), LDREX(0),
HW_FP(0) {
+ bool IsFreeBSD = Triple.isOSFreeBSD();
bool IsOpenBSD = Triple.isOSOpenBSD();
bool IsNetBSD = Triple.isOSNetBSD();
@@ -321,7 +322,7 @@ ARMTargetInfo::ARMTargetInfo(const llvm::Triple &Triple,
default:
if (IsNetBSD)
setABI("apcs-gnu");
- else if (IsOpenBSD)
+ else if (IsFreeBSD || IsOpenBSD)
setABI("aapcs-linux");
else
setABI("aapcs");
diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index 4ce0087cbe245..13b3654a1bce0 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -85,16 +85,7 @@ void freebsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
else
CmdArgs.push_back("-mfpu=softvfp");
- switch (getToolChain().getTriple().getEnvironment()) {
- case llvm::Triple::GNUEABIHF:
- case llvm::Triple::GNUEABI:
- case llvm::Triple::EABI:
- CmdArgs.push_back("-meabi=5");
- break;
-
- default:
- CmdArgs.push_back("-matpcs");
- }
+ CmdArgs.push_back("-meabi=5");
break;
}
case llvm::Triple::sparc:
@@ -467,21 +458,6 @@ Tool *FreeBSD::buildAssembler() const {
Tool *FreeBSD::buildLinker() const { return new tools::freebsd::Linker(*this); }
-llvm::ExceptionHandling FreeBSD::GetExceptionModel(const ArgList &Args) const {
- // FreeBSD uses SjLj exceptions on ARM oabi.
- switch (getTriple().getEnvironment()) {
- case llvm::Triple::GNUEABIHF:
- case llvm::Triple::GNUEABI:
- case llvm::Triple::EABI:
- return llvm::ExceptionHandling::None;
- default:
- if (getTriple().getArch() == llvm::Triple::arm ||
- getTriple().getArch() == llvm::Triple::thumb)
- return llvm::ExceptionHandling::SjLj;
- return llvm::ExceptionHandling::None;
- }
-}
-
bool FreeBSD::HasNativeLLVMSupport() const { return true; }
ToolChain::UnwindTableLevel
diff --git a/clang/lib/Driver/ToolChains/FreeBSD.h b/clang/lib/Driver/ToolChains/FreeBSD.h
index 9b24ef1a1e1cf..cec67d84a2cea 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.h
+++ b/clang/lib/Driver/ToolChains/FreeBSD.h
@@ -78,8 +78,6 @@ class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF {
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
- llvm::ExceptionHandling
- GetExceptionModel(const llvm::opt::ArgList &Args) const override;
UnwindTableLevel
getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;
bool isPIEDefault(const llvm::opt::ArgList &Args) const override;
diff --git a/clang/test/Driver/arm-abi.c b/clang/test/Driver/arm-abi.c
index ba5c4ba148ce8..548704965b247 100644
--- a/clang/test/Driver/arm-abi.c
+++ b/clang/test/Driver/arm-abi.c
@@ -28,7 +28,9 @@
// RUN: %clang -target arm--netbsd-eabihf %s -### -o %t.o 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-AAPCS %s
-// OpenBSD defaults to aapcs-linux
+// FreeBSD / OpenBSD default to aapcs-linux
+// RUN: %clang -target arm--freebsd- %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-AAPCS-LINUX %s
// RUN: %clang -target arm--openbsd- %s -### -o %t.o 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-AAPCS-LINUX %s
diff --git a/clang/test/Driver/freebsd.c b/clang/test/Driver/freebsd.c
index eedecde5ad5f3..28a888fedf3fe 100644
--- a/clang/test/Driver/freebsd.c
+++ b/clang/test/Driver/freebsd.c
@@ -146,9 +146,10 @@
// RUN: %clang -### %s --target=arm-unknown-freebsd10.0 -no-integrated-as 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-ARM %s
-// CHECK-ARM: "-cc1"{{.*}}" "-exception-model=sjlj"
-// CHECK-ARM: as{{.*}}" "-mfpu=softvfp"{{.*}}"-matpcs"
-// CHECK-ARM-EABI-NOT: as{{.*}}" "-mfpu=vfp"
+// CHECK-ARM-NOT: "-cc1"{{.*}}" "-exception-model=sjlj"
+// CHECK-ARM: as{{.*}}" "-mfpu=softvfp"{{.*}}"-meabi=5"
+// CHECK-ARM-NOT: as{{.*}}" "-mfpu=vfp"
+// CHECK-ARM-NOT: as{{.*}}" "-matpcs"
// RUN: %clang -### %s --target=arm-gnueabi-freebsd10.0 -no-integrated-as 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-ARM-EABI %s
diff --git a/llvm/lib/TargetParser/ARMTargetParser.cpp b/llvm/lib/TargetParser/ARMTargetParser.cpp
index 740219d852684..7e6184d6c10cd 100644
--- a/llvm/lib/TargetParser/ARMTargetParser.cpp
+++ b/llvm/lib/TargetParser/ARMTargetParser.cpp
@@ -523,7 +523,7 @@ StringRef ARM::computeDefaultTargetABI(const Triple &TT, StringRef CPU) {
default:
if (TT.isOSNetBSD())
return "apcs-gnu";
- if (TT.isOSOpenBSD() || TT.isOHOSFamily())
+ if (TT.isOSFreeBSD() || TT.isOSOpenBSD() || TT.isOHOSFamily())
return "aapcs-linux";
return "aapcs";
}
More information about the llvm-commits
mailing list