[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
|
|
|
//===-- RISCVTargetObjectFile.h - RISCV Object Info -*- C++ ---------*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
[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
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_RISCV_RISCVTARGETOBJECTFILE_H
|
|
|
|
#define LLVM_LIB_TARGET_RISCV_RISCVTARGETOBJECTFILE_H
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
/// This implementation is used for RISCV ELF targets.
|
|
|
|
class RISCVELFTargetObjectFile : public TargetLoweringObjectFileELF {
|
2019-04-11 12:59:13 +08:00
|
|
|
MCSection *SmallDataSection;
|
|
|
|
MCSection *SmallBSSSection;
|
|
|
|
unsigned SSThreshold = 8;
|
|
|
|
|
|
|
|
public:
|
[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
|
|
|
void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
|
2019-04-11 12:59:13 +08:00
|
|
|
|
|
|
|
/// Return true if this global address should be placed into small data/bss
|
|
|
|
/// section.
|
|
|
|
bool isGlobalInSmallSection(const GlobalObject *GO,
|
|
|
|
const TargetMachine &TM) const;
|
|
|
|
|
|
|
|
MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
|
|
|
|
const TargetMachine &TM) const override;
|
|
|
|
|
|
|
|
/// Return true if this constant should be placed into small data section.
|
|
|
|
bool isConstantInSmallSection(const DataLayout &DL, const Constant *CN) const;
|
|
|
|
|
|
|
|
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
|
|
|
|
const Constant *C,
|
2020-05-22 06:23:00 +08:00
|
|
|
Align &Alignment) const override;
|
2019-04-11 12:59:13 +08:00
|
|
|
|
|
|
|
void getModuleMetadata(Module &M) override;
|
|
|
|
|
|
|
|
bool isInSmallSection(uint64_t Size) const;
|
[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
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|