diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp --- a/clang/lib/Basic/Targets/ARM.cpp +++ b/clang/lib/Basic/Targets/ARM.cpp @@ -254,6 +254,7 @@ 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 @@ 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.h b/clang/lib/Driver/ToolChains/FreeBSD.h --- a/clang/lib/Driver/ToolChains/FreeBSD.h +++ b/clang/lib/Driver/ToolChains/FreeBSD.h @@ -78,8 +78,6 @@ 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/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp --- a/clang/lib/Driver/ToolChains/FreeBSD.cpp +++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp @@ -85,16 +85,7 @@ 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::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/test/Driver/arm-abi.c b/clang/test/Driver/arm-abi.c --- 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 --- 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 --- a/llvm/lib/TargetParser/ARMTargetParser.cpp +++ b/llvm/lib/TargetParser/ARMTargetParser.cpp @@ -523,7 +523,7 @@ default: if (TT.isOSNetBSD()) return "apcs-gnu"; - if (TT.isOSOpenBSD()) + if (TT.isOSFreeBSD() || TT.isOSOpenBSD()) return "aapcs-linux"; return "aapcs"; }