mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-04 03:06:28 +00:00
ARM: locate user-defined text sections next to default text.
Make sure functions located in user specified text sections (via the section attribute) are located together with the default text sections. Otherwise, for large object files, the relocations for call instructions are more likely to be out of range. This becomes even more likely in the presence of LTO. rdar://12402636 llvm-svn: 165254
This commit is contained in:
parent
f89fff64e1
commit
3237e667f1
@ -23,6 +23,8 @@
|
|||||||
#include "InstPrinter/ARMInstPrinter.h"
|
#include "InstPrinter/ARMInstPrinter.h"
|
||||||
#include "MCTargetDesc/ARMAddressingModes.h"
|
#include "MCTargetDesc/ARMAddressingModes.h"
|
||||||
#include "MCTargetDesc/ARMMCExpr.h"
|
#include "MCTargetDesc/ARMMCExpr.h"
|
||||||
|
#include "llvm/ADT/SetVector.h"
|
||||||
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/DebugInfo.h"
|
#include "llvm/DebugInfo.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
@ -42,7 +44,6 @@
|
|||||||
#include "llvm/Target/Mangler.h"
|
#include "llvm/Target/Mangler.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/ADT/SmallString.h"
|
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
@ -592,9 +593,24 @@ void ARMAsmPrinter::EmitStartOfAsmFile(Module &M) {
|
|||||||
const TargetLoweringObjectFileMachO &TLOFMacho =
|
const TargetLoweringObjectFileMachO &TLOFMacho =
|
||||||
static_cast<const TargetLoweringObjectFileMachO &>(
|
static_cast<const TargetLoweringObjectFileMachO &>(
|
||||||
getObjFileLowering());
|
getObjFileLowering());
|
||||||
OutStreamer.SwitchSection(TLOFMacho.getTextSection());
|
|
||||||
OutStreamer.SwitchSection(TLOFMacho.getTextCoalSection());
|
// Collect the set of sections our functions will go into.
|
||||||
OutStreamer.SwitchSection(TLOFMacho.getConstTextCoalSection());
|
SetVector<const MCSection *, SmallVector<const MCSection *, 8>,
|
||||||
|
SmallPtrSet<const MCSection *, 8> > TextSections;
|
||||||
|
// Default text section comes first.
|
||||||
|
TextSections.insert(TLOFMacho.getTextSection());
|
||||||
|
// Now any user defined text sections from function attributes.
|
||||||
|
for (Module::iterator F = M.begin(), e = M.end(); F != e; ++F)
|
||||||
|
if (!F->isDeclaration() && !F->hasAvailableExternallyLinkage())
|
||||||
|
TextSections.insert(TLOFMacho.SectionForGlobal(F, Mang, TM));
|
||||||
|
// Now the coalescable sections.
|
||||||
|
TextSections.insert(TLOFMacho.getTextCoalSection());
|
||||||
|
TextSections.insert(TLOFMacho.getConstTextCoalSection());
|
||||||
|
|
||||||
|
// Emit the sections in the .s file header to fix the order.
|
||||||
|
for (unsigned i = 0, e = TextSections.size(); i != e; ++i)
|
||||||
|
OutStreamer.SwitchSection(TextSections[i]);
|
||||||
|
|
||||||
if (RelocM == Reloc::DynamicNoPIC) {
|
if (RelocM == Reloc::DynamicNoPIC) {
|
||||||
const MCSection *sect =
|
const MCSection *sect =
|
||||||
OutContext.getMachOSection("__TEXT", "__symbol_stub4",
|
OutContext.getMachOSection("__TEXT", "__symbol_stub4",
|
||||||
|
21
test/CodeGen/ARM/darwin-section-order.ll
Normal file
21
test/CodeGen/ARM/darwin-section-order.ll
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
; RUN: llc < %s -mtriple=armv7-apple-darwin | FileCheck %s
|
||||||
|
|
||||||
|
; CHECK: .section __TEXT,__text,regular,pure_instructions
|
||||||
|
; CHECK: .section __TEXT,myprecious
|
||||||
|
; CHECK: .section __TEXT,__textcoal_nt,coalesced,pure_instructions
|
||||||
|
; CHECK: .section __TEXT,__const_coal,coalesced
|
||||||
|
; CHECK: .section __TEXT,__picsymbolstub4,symbol_stubs,none,16
|
||||||
|
; CHECK: .section __TEXT,__StaticInit,regular,pure_instructions
|
||||||
|
|
||||||
|
|
||||||
|
define void @normal() nounwind readnone {
|
||||||
|
; CHECK: .section __TEXT,__text,regular,pure_instructions
|
||||||
|
; CHECK: _normal:
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @special() nounwind readnone section "__TEXT,myprecious" {
|
||||||
|
; CHECK: .section __TEXT,myprecious
|
||||||
|
; CHECK: _special:
|
||||||
|
ret void
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user