Index: lib/CodeGen/CGCall.cpp =================================================================== --- lib/CodeGen/CGCall.cpp +++ lib/CodeGen/CGCall.cpp @@ -1736,7 +1736,6 @@ FuncAttrs.addAttribute("no-frame-pointer-elim-non-leaf"); } else { FuncAttrs.addAttribute("no-frame-pointer-elim", "true"); - FuncAttrs.addAttribute("no-frame-pointer-elim-non-leaf"); } FuncAttrs.addAttribute("less-precise-fpmad", Index: lib/Driver/ToolChains/Clang.cpp =================================================================== --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -498,7 +498,7 @@ return codegenoptions::LimitedDebugInfo; } -static bool mustUseNonLeafFramePointerForTarget(const llvm::Triple &Triple) { +static bool mustUseFramePointerForTarget(const llvm::Triple &Triple) { switch (Triple.getArch()){ default: return false; @@ -575,7 +575,7 @@ if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer, options::OPT_fomit_frame_pointer)) return A->getOption().matches(options::OPT_fno_omit_frame_pointer) || - mustUseNonLeafFramePointerForTarget(Triple); + mustUseFramePointerForTarget(Triple); if (Args.hasArg(options::OPT_pg)) return true; @@ -589,6 +589,11 @@ options::OPT_momit_leaf_frame_pointer)) return A->getOption().matches(options::OPT_mno_omit_leaf_frame_pointer); + if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer, + options::OPT_fomit_frame_pointer)) + return A->getOption().matches(options::OPT_fno_omit_frame_pointer) || + mustUseFramePointerForTarget(Triple); + if (Args.hasArg(options::OPT_pg)) return true; Index: test/Driver/cl-options.c =================================================================== --- test/Driver/cl-options.c +++ test/Driver/cl-options.c @@ -171,11 +171,10 @@ // RUN: %clang_cl --target=i686-pc-win32 /O2sy- -### -- %s 2>&1 | FileCheck -check-prefix=PR24003 %s // PR24003: -mdisable-fp-elim -// PR24003: -momit-leaf-frame-pointer // PR24003: -Os // RUN: %clang_cl --target=i686-pc-win32 -Werror /Oy- /O2 -### -- %s 2>&1 | FileCheck -check-prefix=Oy_2 %s -// Oy_2: -momit-leaf-frame-pointer +// Oy_2: -mdisable-fp-elim // Oy_2: -O2 // RUN: %clang_cl --target=i686-pc-win32 -Werror /O2 /O2 -### -- %s 2>&1 | FileCheck -check-prefix=O2O2 %s Index: test/Driver/frame-pointer-elim.c =================================================================== --- test/Driver/frame-pointer-elim.c +++ test/Driver/frame-pointer-elim.c @@ -69,5 +69,20 @@ // RUN: %clang -### -target x86_64-scei-ps4 -S -O2 %s 2>&1 | \ // RUN: FileCheck --check-prefix=OMIT_LEAF %s +// RUN: %clang -### -S -Os -fno-omit-frame-pointer %s 2>&1 | \ +// RUN: FileCheck --check-prefix=NO-OMIT-ALL %s +// NO-OMIT-ALL: "-mdisable-fp-elim" +// NO-OMIT-ALL-NOT: "-momit-leaf-frame-pointer" + +// RUN: %clang -### -S -Os -fno-omit-frame-pointer -momit-leaf-frame-pointer %s 2>&1 | \ +// RUN: FileCheck --check-prefix=NO-OMIT-NONLEAF %s +// NO-OMIT-NONLEAF: "-mdisable-fp-elim" +// NO-OMIT-NONLEAF: "-momit-leaf-frame-pointer" + +// RUN: %clang -### -S -Os -fomit-frame-pointer %s 2>&1 | \ +// RUN: FileCheck --check-prefix=OMIT-ALL %s +// OMIT-ALL-NOT: "-mdisable-fp-elim" +// OMIT-ALL: "-momit-leaf-frame-pointer" + void f0() {} void f1() { f0(); }