From a7906214c4751b4c181546ae48ecd05c8f84f07b Mon Sep 17 00:00:00 2001
From: George Koehler <kernigh@gmail.com>
Date: Tue, 2 Apr 2019 11:29:19 -0400
Subject: [PATCH] Use -fomit-frame-pointer when optimizing PowerPC code

This enables -fomit-frame-pointer when optimizing code for all PowerPC
targets, instead of only Linux and NetBSD.
---
 clang/lib/Driver/ToolChains/Clang.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index a5b98aad54d..6bfca0a5f15 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -523,8 +523,12 @@ static bool useFramePointerForTargetByDefault(const ArgList &Args,
     // XCore never wants frame pointers, regardless of OS.
     // WebAssembly never wants frame pointers.
     return false;
+  case llvm::Triple::ppc:
+  case llvm::Triple::ppc64:
+  case llvm::Triple::ppc64le:
   case llvm::Triple::riscv32:
   case llvm::Triple::riscv64:
+    // PowerPC's frame pointer is often an extra copy of the stack pointer.
     return !areOptimizationsEnabled(Args);
   default:
     break;
@@ -542,9 +546,6 @@ static bool useFramePointerForTargetByDefault(const ArgList &Args,
     case llvm::Triple::mips64el:
     case llvm::Triple::mips:
     case llvm::Triple::mipsel:
-    case llvm::Triple::ppc:
-    case llvm::Triple::ppc64:
-    case llvm::Triple::ppc64le:
     case llvm::Triple::systemz:
     case llvm::Triple::x86:
     case llvm::Triple::x86_64:
-- 
2.19.1

