llvm-project/llvm/test/CodeGen/AVR/no-copy-data.ll
Ayke van Laethem 167338de96
[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
2023-01-08 18:56:06 +01:00

9 lines
217 B
LLVM

; RUN: llc < %s -march=avr | FileCheck %s
; CHECK-NOT: .globl __do_copy_data
; CHECK: .globl __do_clear_bss
@noinit = internal global i8 5, section ".noinit"
@external = external global i8
@global = global i8 0