]> granicus.if.org Git - clang/commitdiff
[RISCV] Fix logic to check if frame pointer should be used
authorMandeep Singh Grang <mgrang@codeaurora.org>
Thu, 12 Apr 2018 19:31:37 +0000 (19:31 +0000)
committerMandeep Singh Grang <mgrang@codeaurora.org>
Thu, 12 Apr 2018 19:31:37 +0000 (19:31 +0000)
Summary: The logic was broken for Linux triples as it returns true in the switch for Triple.isOSLinux().

Reviewers: asb, apazos

Reviewed By: asb

Subscribers: kito-cheng, shiva0217, cfe-commits

Differential Revision: https://reviews.llvm.org/D45237

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329941 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains/Clang.cpp
test/Driver/frame-pointer.c

index 7d2d3c45c8672ef24f98c0ad8498e43424ecf163..19a4bd05c48e4a258871b830d7e2e92a1ed17f73 100644 (file)
@@ -529,6 +529,9 @@ static bool useFramePointerForTargetByDefault(const ArgList &Args,
     // XCore never wants frame pointers, regardless of OS.
     // WebAssembly never wants frame pointers.
     return false;
+  case llvm::Triple::riscv32:
+  case llvm::Triple::riscv64:
+    return !areOptimizationsEnabled(Args);
   default:
     break;
   }
@@ -552,14 +555,6 @@ static bool useFramePointerForTargetByDefault(const ArgList &Args,
     }
   }
 
-  switch (Triple.getArch()) {
-    case llvm::Triple::riscv32:
-    case llvm::Triple::riscv64:
-      return !areOptimizationsEnabled(Args);
-    default:
-      break;
-  }
-
   if (Triple.isOSWindows()) {
     switch (Triple.getArch()) {
     case llvm::Triple::x86:
index cf5c07d542f016a3cc2842a44ffdf2d62f8898aa..85c9f3a21f105e790610966eb31f689f8e406d4e 100644 (file)
 // RUN: %clang -target riscv64-unknown-elf -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK3-64 %s
 // RUN: %clang -target riscv64-unknown-elf -### -S -Os %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s
 
+// RUN: %clang -target riscv32-unknown-linux-gnu -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -### -S -O2 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK2-32 %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK3-32 %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -### -S -Os %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKs-32 %s
+
+// RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-64 %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-64 %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O2 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK2-64 %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK3-64 %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -### -S -Os %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s
+
 // CHECK0-32: -mdisable-fp-elim
 // CHECK1-32-NOT: -mdisable-fp-elim
 // CHECK2-32-NOT: -mdisable-fp-elim