From 1dd034ed5060fc6078bf56d5656cb1554f750de6 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Fri, 12 Apr 2019 01:29:18 +0000 Subject: [PATCH] Enable frame pointer elimination for OpenBSD on x86 and mips64. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@358245 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/ToolChains/Clang.cpp | 12 ++++++++++++ test/Driver/frame-pointer-elim.c | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index a5b98aad54..18856650a9 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -534,6 +534,18 @@ static bool useFramePointerForTargetByDefault(const ArgList &Args, return !areOptimizationsEnabled(Args); } + if (Triple.isOSOpenBSD()) { + switch (Triple.getArch()) { + case llvm::Triple::mips64: + case llvm::Triple::mips64el: + case llvm::Triple::x86: + case llvm::Triple::x86_64: + return !areOptimizationsEnabled(Args); + default: + return true; + } + } + if (Triple.isOSLinux() || Triple.getOS() == llvm::Triple::CloudABI || Triple.isOSHurd()) { switch (Triple.getArch()) { diff --git a/test/Driver/frame-pointer-elim.c b/test/Driver/frame-pointer-elim.c index 6fcd3eb75a..b050f71611 100644 --- a/test/Driver/frame-pointer-elim.c +++ b/test/Driver/frame-pointer-elim.c @@ -26,6 +26,15 @@ // RUN: FileCheck --check-prefix=NETBSD %s // NETBSD-NOT: "-momit-leaf-frame-pointer" +// OpenBSD follows the same rules as Linux. +// RUN: %clang -### -target x86_64-unknown-openbsd -S -O1 %s 2>&1 | \ +// RUN: FileCheck --check-prefix=OPENBSD-OPT %s +// OPENBSD-OPT: "-momit-leaf-frame-pointer" + +// RUN: %clang -### -target x86_64-unknown-openbsd -S %s 2>&1 | \ +// RUN: FileCheck --check-prefix=OPENBSD %s +// OPENBSD-NOT: "-momit-leaf-frame-pointer" + // Darwin disables omitting the leaf frame pointer even under optimization // unless the command lines are given. // RUN: %clang -### -target i386-apple-darwin -S %s 2>&1 | \ -- 2.40.0