[all-commits] [llvm/llvm-project] 167338: [AVR] correctly declare __do_copy_data and __do_cl...

Ayke via All-commits all-commits at lists.llvm.org
Sun Jan 8 09:56:43 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 167338de9687a8e65672001aa4c4f2e62cf45a76
      https://github.com/llvm/llvm-project/commit/167338de9687a8e65672001aa4c4f2e62cf45a76
  Author: Ayke van Laethem <aykevanlaethem at gmail.com>
  Date:   2023-01-08 (Sun, 08 Jan 2023)

  Changed paths:
    M llvm/lib/Target/AVR/AVRAsmPrinter.cpp
    M llvm/lib/Target/AVR/AVRDevices.td
    M llvm/lib/Target/AVR/AVRSubtarget.h
    M llvm/test/CodeGen/AVR/clear-bss.ll
    A llvm/test/CodeGen/AVR/no-clear-bss.ll
    A llvm/test/CodeGen/AVR/no-copy-data.ll

  Log Message:
  -----------
  [AVR] correctly declare __do_copy_data and __do_clear_bss

These two symbols are declared in object files to indicate whether .data
needs to be copied from flash or .bss needs to be cleared. They are
supported on avr-gcc and reduce firmware size a bit, which is especially
important on very small chips.

I checked the behavior of avr-gcc and matched it as well as possible.
>From my investigation, it seems to work as follows:

__do_copy_data is set when the compiler finds a data symbol:
  * without a section name
  * with a section name starting with ".data" or ".gnu.linkonce.d"
  * with a section name starting with ".rodata" or ".gnu.linkonce.r" and
    flash and RAM are in the same address space

__do_clear_bss is set when the compiler finds a data symbol:
  * without a section name
  * with a section name that starts with .bss

Simply checking whether the calculated section name starts with ".data",
".rodata" or ".bss" should result in the same behavior.

Fixes: https://github.com/llvm/llvm-project/issues/58857

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


  Commit: 0408b131eb66ef842e7d57c1a0410a2a14f891ac
      https://github.com/llvm/llvm-project/commit/0408b131eb66ef842e7d57c1a0410a2a14f891ac
  Author: Ayke van Laethem <aykevanlaethem at gmail.com>
  Date:   2023-01-08 (Sun, 08 Jan 2023)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
    M llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
    A llvm/test/CodeGen/AVR/llrint.ll
    A llvm/test/CodeGen/AVR/llround-conv.ll
    A llvm/test/CodeGen/AVR/lrint.ll
    A llvm/test/CodeGen/AVR/lround-conv.ll

  Log Message:
  -----------
  [SelectionDAG][AVR] Add support for lrint and lround intrinsics

Integer legalization already supported splitting the output integer of
llround and llrint, but did not support this for lround and lrint yet.
This is not a problem for 32-bit architectures, but for 8/16-bit
architectures like AVR it results in a crash like this:

    ExpandIntegerResult #0: t7: i32 = lround t6

    LLVM ERROR: Do not know how to expand the result of this operator!

This patch simply add lrint/lround to the list of ISD opcodes to expand.

Fixes https://github.com/llvm/llvm-project/issues/59573.

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


Compare: https://github.com/llvm/llvm-project/compare/91487b248195...0408b131eb66


More information about the All-commits mailing list