[all-commits] [llvm/llvm-project] 8eda71: [Clang][A32/T32][Linux] -O1 implies -fomit-frame-p...

Nick Desaulniers via All-commits all-commits at lists.llvm.org
Tue Jun 2 16:00:14 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 8eda71616fecd098cbd7d2447859c8ac1315966f
      https://github.com/llvm/llvm-project/commit/8eda71616fecd098cbd7d2447859c8ac1315966f
  Author: Nick Desaulniers <ndesaulniers at google.com>
  Date:   2020-06-02 (Tue, 02 Jun 2020)

  Changed paths:
    M clang/lib/Basic/Targets/ARM.cpp
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/test/Driver/frame-pointer-elim.c
    M llvm/docs/ReleaseNotes.rst

  Log Message:
  -----------
  [Clang][A32/T32][Linux] -O1 implies -fomit-frame-pointer

Summary:
An upgrade of LLVM for CrOS [0] containing [1] triggered a bunch of
errors related to writing to reserved registers for a Linux kernel's
arm64 compat vdso (which is a aarch32 image).

After a discussion on LKML [2], it was determined that
-f{no-}omit-frame-pointer was not being specified. Comparing GCC and
Clang [3], it becomes apparent that GCC defaults to omitting the frame
pointer implicitly when optimizations are enabled, and Clang does not.
ie. setting -O1 (or above) implies -fomit-frame-pointer. Clang was
defaulting to -fno-omit-frame-pointer implicitly unless -fomit-frame-pointer
was set explicitly.

Why this becomes a problem is that the Linux kernel's arm64 compat vdso
contains code that uses r7. r7 is used sometimes for the frame pointer
(for example, when targeting thumb (-mthumb)). See useR7AsFramePointer()
in llvm/llvm-project/llvm/lib/Target/ARM/ARMSubtarget.h. This is mostly
for legacy/compatibility reasons, and the 2019 Q4 revision of the ARM
AAPCS looks to standardize r11 as the frame pointer for aarch32, though
this is not yet implemented in LLVM.

Users that are reliant on the implicit value if unspecified when
optimizations are enabled should explicitly choose -fomit-frame-pointer
(new behavior) or -fno-omit-frame-pointer (old behavior).

[0] https://bugs.chromium.org/p/chromium/issues/detail?id=1084372
[1] https://reviews.llvm.org/D76848
[2] https://lore.kernel.org/lkml/20200526173117.155339-1-ndesaulniers@google.com/
[3] https://godbolt.org/z/0oY39t

Reviewers: kristof.beyls, psmith, danalbert, srhines, MaskRay, ostannard, efriedma

Reviewed By: psmith, danalbert, srhines, MaskRay, efriedma

Subscribers: efriedma, olista01, MaskRay, vhscampos, cfe-commits, llvm-commits, manojgupta, llozano, glider, hctim, eugenis, pcc, peter.smith, srhines

Tags: #clang, #llvm

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




More information about the All-commits mailing list