[all-commits] [llvm/llvm-project] c3e655: Call Frame Information (CFI) Handling for Basic Bl...

Krzysztof Pszeniczny via All-commits all-commits at lists.llvm.org
Tue Jul 14 12:58:10 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: c3e6555616fd92e21b17fbc27f8c145c27890f1a
      https://github.com/llvm/llvm-project/commit/c3e6555616fd92e21b17fbc27f8c145c27890f1a
  Author: Krzysztof Pszeniczny <krzysztof.pszeniczny at gmail.com>
  Date:   2020-07-14 (Tue, 14 Jul 2020)

  Changed paths:
    M llvm/include/llvm/CodeGen/TargetFrameLowering.h
    M llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    M llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
    M llvm/lib/CodeGen/AsmPrinter/DwarfException.h
    M llvm/lib/CodeGen/CFIInstrInserter.cpp
    M llvm/lib/Target/AArch64/AArch64FrameLowering.h
    M llvm/lib/Target/X86/X86FrameLowering.cpp
    M llvm/lib/Target/X86/X86FrameLowering.h
    A llvm/test/CodeGen/X86/cfi-basic-block-sections-1.ll
    A llvm/test/CodeGen/X86/cfi-inserter-basic-block-sections-callee-save-registers.ll

  Log Message:
  -----------
  Call Frame Information (CFI) Handling for Basic Block Sections

This patch handles CFI with basic block sections, which unlike DebugInfo does
not support ranges. The DWARF standard explicitly requires emitting separate
CFI Frame Descriptor Entries for each contiguous fragment of a function. Thus,
the CFI information for all callee-saved registers (possibly including the
frame pointer, if necessary) have to be emitted along with redefining the
Call Frame Address (CFA), viz. where the current frame starts.

CFI directives are emitted in FDE’s in the object file with a low_pc, high_pc
specification. So, a single FDE must point to a contiguous code region unlike
debug info which has the support for ranges. This is what complicates CFI for
basic block sections.

Now, what happens when we start placing individual basic blocks in unique
sections:

* Basic block sections allow the linker to randomly reorder basic blocks in the
address space such that a given basic block can become non-contiguous with the
original function.
* The different basic block sections can no longer share the cfi_startproc and
cfi_endproc directives. So, each basic block section should emit this
independently.
* Each (cfi_startproc, cfi_endproc) directive will result in a new FDE that
caters to that basic block section.
* Now, this basic block section needs to duplicate the information from the
entry block to compute the CFA as it is an independent entity. It cannot refer
to the FDE of the original function and hence must duplicate all the stuff that
is needed to compute the CFA on its own.
* We are working on a de-duplication patch that can share common information in
FDEs in a CIE (Common Information Entry) and we will present this as a follow up
patch. This can significantly reduce the duplication overhead and is
particularly useful when several basic block sections are created.
* The CFI directives are emitted similarly for registers that are pushed onto
the stack, like callee saved registers in the prologue. There are cfi
directives that emit how to retrieve the value of the register at that point
when the push happened. This has to be duplicated too in a basic block that is
floated as a separate section.

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




More information about the All-commits mailing list