Skip to content

Commit 2861fa2

Browse files
brad0tru
authored andcommitted
[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 (cherry picked from commit 13a10e7)
1 parent 1172ed5 commit 2861fa2

File tree

6 files changed

+11
-33
lines changed

6 files changed

+11
-33
lines changed

clang/lib/Basic/Targets/ARM.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ ARMTargetInfo::ARMTargetInfo(const llvm::Triple &Triple,
254254
const TargetOptions &Opts)
255255
: TargetInfo(Triple), FPMath(FP_Default), IsAAPCS(true), LDREX(0),
256256
HW_FP(0) {
257+
bool IsFreeBSD = Triple.isOSFreeBSD();
257258
bool IsOpenBSD = Triple.isOSOpenBSD();
258259
bool IsNetBSD = Triple.isOSNetBSD();
259260

@@ -321,7 +322,7 @@ ARMTargetInfo::ARMTargetInfo(const llvm::Triple &Triple,
321322
default:
322323
if (IsNetBSD)
323324
setABI("apcs-gnu");
324-
else if (IsOpenBSD)
325+
else if (IsFreeBSD || IsOpenBSD)
325326
setABI("aapcs-linux");
326327
else
327328
setABI("aapcs");

clang/lib/Driver/ToolChains/FreeBSD.cpp

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,7 @@ void freebsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
8585
else
8686
CmdArgs.push_back("-mfpu=softvfp");
8787

88-
switch (getToolChain().getTriple().getEnvironment()) {
89-
case llvm::Triple::GNUEABIHF:
90-
case llvm::Triple::GNUEABI:
91-
case llvm::Triple::EABI:
92-
CmdArgs.push_back("-meabi=5");
93-
break;
94-
95-
default:
96-
CmdArgs.push_back("-matpcs");
97-
}
88+
CmdArgs.push_back("-meabi=5");
9889
break;
9990
}
10091
case llvm::Triple::sparc:
@@ -467,21 +458,6 @@ Tool *FreeBSD::buildAssembler() const {
467458

468459
Tool *FreeBSD::buildLinker() const { return new tools::freebsd::Linker(*this); }
469460

470-
llvm::ExceptionHandling FreeBSD::GetExceptionModel(const ArgList &Args) const {
471-
// FreeBSD uses SjLj exceptions on ARM oabi.
472-
switch (getTriple().getEnvironment()) {
473-
case llvm::Triple::GNUEABIHF:
474-
case llvm::Triple::GNUEABI:
475-
case llvm::Triple::EABI:
476-
return llvm::ExceptionHandling::None;
477-
default:
478-
if (getTriple().getArch() == llvm::Triple::arm ||
479-
getTriple().getArch() == llvm::Triple::thumb)
480-
return llvm::ExceptionHandling::SjLj;
481-
return llvm::ExceptionHandling::None;
482-
}
483-
}
484-
485461
bool FreeBSD::HasNativeLLVMSupport() const { return true; }
486462

487463
ToolChain::UnwindTableLevel

clang/lib/Driver/ToolChains/FreeBSD.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF {
7878
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
7979
llvm::opt::ArgStringList &CC1Args) const override;
8080

81-
llvm::ExceptionHandling
82-
GetExceptionModel(const llvm::opt::ArgList &Args) const override;
8381
UnwindTableLevel
8482
getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;
8583
bool isPIEDefault(const llvm::opt::ArgList &Args) const override;

clang/test/Driver/arm-abi.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
// RUN: %clang -target arm--netbsd-eabihf %s -### -o %t.o 2>&1 \
2929
// RUN: | FileCheck -check-prefix=CHECK-AAPCS %s
3030

31-
// OpenBSD defaults to aapcs-linux
31+
// FreeBSD / OpenBSD default to aapcs-linux
32+
// RUN: %clang -target arm--freebsd- %s -### -o %t.o 2>&1 \
33+
// RUN: | FileCheck -check-prefix=CHECK-AAPCS-LINUX %s
3234
// RUN: %clang -target arm--openbsd- %s -### -o %t.o 2>&1 \
3335
// RUN: | FileCheck -check-prefix=CHECK-AAPCS-LINUX %s
3436

clang/test/Driver/freebsd.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,10 @@
146146

147147
// RUN: %clang -### %s --target=arm-unknown-freebsd10.0 -no-integrated-as 2>&1 \
148148
// RUN: | FileCheck --check-prefix=CHECK-ARM %s
149-
// CHECK-ARM: "-cc1"{{.*}}" "-exception-model=sjlj"
150-
// CHECK-ARM: as{{.*}}" "-mfpu=softvfp"{{.*}}"-matpcs"
151-
// CHECK-ARM-EABI-NOT: as{{.*}}" "-mfpu=vfp"
149+
// CHECK-ARM-NOT: "-cc1"{{.*}}" "-exception-model=sjlj"
150+
// CHECK-ARM: as{{.*}}" "-mfpu=softvfp"{{.*}}"-meabi=5"
151+
// CHECK-ARM-NOT: as{{.*}}" "-mfpu=vfp"
152+
// CHECK-ARM-NOT: as{{.*}}" "-matpcs"
152153

153154
// RUN: %clang -### %s --target=arm-gnueabi-freebsd10.0 -no-integrated-as 2>&1 \
154155
// RUN: | FileCheck --check-prefix=CHECK-ARM-EABI %s

llvm/lib/TargetParser/ARMTargetParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ StringRef ARM::computeDefaultTargetABI(const Triple &TT, StringRef CPU) {
523523
default:
524524
if (TT.isOSNetBSD())
525525
return "apcs-gnu";
526-
if (TT.isOSOpenBSD())
526+
if (TT.isOSFreeBSD() || TT.isOSOpenBSD())
527527
return "aapcs-linux";
528528
return "aapcs";
529529
}

0 commit comments

Comments
 (0)