[RISCV] Use init_array instead of ctors for RISCV target, by default
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
llvm-svn: 328433
2018-03-25 02:37:19 +08:00
|
|
|
; 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
|
|
|
|
}
|
|
|
|
|
2019-05-15 10:35:32 +08:00
|
|
|
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_a, i8* null }]
|
[RISCV] Use init_array instead of ctors for RISCV target, by default
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
llvm-svn: 328433
2018-03-25 02:37:19 +08:00
|
|
|
|
|
|
|
;INITARRAY: section .init_array
|
|
|
|
;INITARRAY-NOT: .section .ctors
|
|
|
|
|
|
|
|
;CTOR: .section .ctors
|
|
|
|
;CTOR-NOT: section .init_array
|
|
|
|
|