From fe234d2e99d873d68d3f707af17fb4d41fe57bdc Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Tue, 5 Feb 2019 20:15:03 +0000 Subject: [PATCH] Do not use frame pointer by default for MSP430 This is suggested by 3.3.9 of MSP430 EABI document. We do allow user to manually enable frame pointer. GCC toolchain uses the same behavior. Patch by Dmitry Mikushev! Differential Revision: https://reviews.llvm.org/D56925 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@353212 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/ToolChains/Clang.cpp | 1 + test/CodeGen/msp430-fp-elim.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 test/CodeGen/msp430-fp-elim.c diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index f125bce01d..3b1ef3a5a8 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -519,6 +519,7 @@ static bool useFramePointerForTargetByDefault(const ArgList &Args, case llvm::Triple::xcore: case llvm::Triple::wasm32: case llvm::Triple::wasm64: + case llvm::Triple::msp430: // XCore never wants frame pointers, regardless of OS. // WebAssembly never wants frame pointers. return false; diff --git a/test/CodeGen/msp430-fp-elim.c b/test/CodeGen/msp430-fp-elim.c new file mode 100644 index 0000000000..c022adecbc --- /dev/null +++ b/test/CodeGen/msp430-fp-elim.c @@ -0,0 +1,19 @@ +// REQUIRES: msp430-registered-target +// RUN: %clang_cc1 -mdisable-fp-elim -triple msp430 -S %s -o - | FileCheck %s --check-prefix=FP_ENFORCED +// RUN: %clang_cc1 -triple msp430 -S %s -o - | FileCheck %s --check-prefix=FP_DEFAULT + +// Check the frame pointer is not used on MSP430 by default, but can be forcibly turned on. + +// FP_ENFORCED: push r4 +// FP_ENFORCED: mov r4, r4 +// FP_ENFORCED: pop r4 +// FP_DEFAULT: .globl fp_elim_check +// FP_DEFAULT-NOT: push r4 +// FP_DEFAULT: mov r4, r4 +// FP_DEFAULT-NOT: pop r4 + +void fp_elim_check() +{ + asm volatile ("mov r4, r4"); +} + -- 2.40.0