mirror of
https://github.com/RPCS3/llvm.git
synced 2025-05-15 18:06:08 +00:00

Summary: LLVM defaults to the newer .init_array/.fini_array scheme for static constructors rather than the less desirable .ctors/.dtors (the UseCtors flag defaults to false). This wasn't being respected in the RISC-V backend because it fails to call TargetLoweringObjectFileELF::InitializeELF with the the appropriate flag for UseInitArray. This patch fixes this by implementing RISCVELFTargetObjectFile and overriding its Initialize method to call InitializeELF(TM.Options.UseInitArray). Reviewers: asb, apazos Reviewed By: asb Subscribers: mgorny, rbar, johnrusso, simoncook, jordy.potman.lists, sabuasal, niosHD, kito-cheng, shiva0217, llvm-commits Differential Revision: https://reviews.llvm.org/D44750 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328433 91177308-0d34-0410-b5e6-96231b3b80d8
31 lines
1.3 KiB
LLVM
31 lines
1.3 KiB
LLVM
; RUN: llc -mtriple=riscv32-unknown-linux-gnu -verify-machineinstrs -o - %s \
|
|
; RUN: | FileCheck --check-prefix=INITARRAY %s
|
|
; RUN: llc -mtriple=riscv32-unknown-elf -verify-machineinstrs -o - %s \
|
|
; RUN: | FileCheck --check-prefix=INITARRAY %s
|
|
; RUN: llc -mtriple=riscv64-unknown-linux-gnu -verify-machineinstrs -o - %s \
|
|
; RUN: | FileCheck --check-prefix=INITARRAY %s
|
|
; RUN: llc -mtriple=riscv64-unknown-elf -verify-machineinstrs -o - %s \
|
|
; RUN: | FileCheck --check-prefix=INITARRAY %s
|
|
|
|
; RUN: llc -mtriple=riscv32-unknown-linux-gnu -verify-machineinstrs -use-ctors -o - %s \
|
|
; RUN: | FileCheck --check-prefix=CTOR %s
|
|
; RUN: llc -mtriple=riscv32-unknown-elf -verify-machineinstrs -use-ctors -o - %s \
|
|
; RUN: | FileCheck --check-prefix=CTOR %s
|
|
; RUN: llc -mtriple=riscv64-unknown-linux-gnu -verify-machineinstrs -use-ctors -o - %s \
|
|
; RUN: | FileCheck --check-prefix=CTOR %s
|
|
; RUN: llc -mtriple=riscv64-unknown-elf -verify-machineinstrs -use-ctors -o - %s \
|
|
; RUN: | FileCheck --check-prefix=CTOR %s
|
|
|
|
define internal void @_GLOBAL__I_a() section ".text.startup" {
|
|
ret void
|
|
}
|
|
|
|
@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }]
|
|
|
|
;INITARRAY: section .init_array
|
|
;INITARRAY-NOT: .section .ctors
|
|
|
|
;CTOR: .section .ctors
|
|
;CTOR-NOT: section .init_array
|
|
|