forked from OSchip/llvm-project
parent
19ed0d05b8
commit
346e808ec6
|
@ -87,9 +87,9 @@ XCoreTargetStreamer &XCoreAsmPrinter::getTargetStreamer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void XCoreAsmPrinter::emitArrayBound(MCSymbol *Sym, const GlobalVariable *GV) {
|
void XCoreAsmPrinter::emitArrayBound(MCSymbol *Sym, const GlobalVariable *GV) {
|
||||||
assert(((GV->hasExternalLinkage() ||
|
assert( ( GV->hasExternalLinkage() || GV->hasWeakLinkage() ||
|
||||||
GV->hasWeakLinkage()) ||
|
GV->hasLinkOnceLinkage() || GV->hasCommonLinkage() ) &&
|
||||||
GV->hasLinkOnceLinkage()) && "Unexpected linkage");
|
"Unexpected linkage");
|
||||||
if (ArrayType *ATy = dyn_cast<ArrayType>(
|
if (ArrayType *ATy = dyn_cast<ArrayType>(
|
||||||
cast<PointerType>(GV->getType())->getElementType())) {
|
cast<PointerType>(GV->getType())->getElementType())) {
|
||||||
|
|
||||||
|
@ -99,7 +99,8 @@ void XCoreAsmPrinter::emitArrayBound(MCSymbol *Sym, const GlobalVariable *GV) {
|
||||||
OutStreamer.EmitAssignment(SymGlob,
|
OutStreamer.EmitAssignment(SymGlob,
|
||||||
MCConstantExpr::Create(ATy->getNumElements(),
|
MCConstantExpr::Create(ATy->getNumElements(),
|
||||||
OutContext));
|
OutContext));
|
||||||
if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage()) {
|
if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
|
||||||
|
GV->hasCommonLinkage()) {
|
||||||
// TODO Use COMDAT groups for LinkOnceLinkage
|
// TODO Use COMDAT groups for LinkOnceLinkage
|
||||||
OutStreamer.EmitSymbolAttribute(SymGlob, MCSA_Weak);
|
OutStreamer.EmitSymbolAttribute(SymGlob, MCSA_Weak);
|
||||||
}
|
}
|
||||||
|
@ -131,11 +132,13 @@ void XCoreAsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
|
||||||
case GlobalValue::WeakAnyLinkage:
|
case GlobalValue::WeakAnyLinkage:
|
||||||
case GlobalValue::WeakODRLinkage:
|
case GlobalValue::WeakODRLinkage:
|
||||||
case GlobalValue::ExternalLinkage:
|
case GlobalValue::ExternalLinkage:
|
||||||
|
case GlobalValue::CommonLinkage:
|
||||||
emitArrayBound(GVSym, GV);
|
emitArrayBound(GVSym, GV);
|
||||||
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global);
|
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global);
|
||||||
|
|
||||||
// TODO Use COMDAT groups for LinkOnceLinkage
|
// TODO Use COMDAT groups for LinkOnceLinkage
|
||||||
if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage())
|
if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
|
||||||
|
GV->hasCommonLinkage())
|
||||||
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Weak);
|
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Weak);
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
case GlobalValue::InternalLinkage:
|
case GlobalValue::InternalLinkage:
|
||||||
|
|
|
@ -149,13 +149,13 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
|
||||||
TM.getDataLayout()->getTypeAllocSize(ObjType) < CodeModelLargeSize) {
|
TM.getDataLayout()->getTypeAllocSize(ObjType) < CodeModelLargeSize) {
|
||||||
if (Kind.isReadOnly()) return UseCPRel? ReadOnlySection
|
if (Kind.isReadOnly()) return UseCPRel? ReadOnlySection
|
||||||
: DataRelROSection;
|
: DataRelROSection;
|
||||||
if (Kind.isBSS()) return BSSSection;
|
if (Kind.isBSS() || Kind.isCommon())return BSSSection;
|
||||||
if (Kind.isDataRel()) return DataSection;
|
if (Kind.isDataRel()) return DataSection;
|
||||||
if (Kind.isReadOnlyWithRel()) return DataRelROSection;
|
if (Kind.isReadOnlyWithRel()) return DataRelROSection;
|
||||||
} else {
|
} else {
|
||||||
if (Kind.isReadOnly()) return UseCPRel? ReadOnlySectionLarge
|
if (Kind.isReadOnly()) return UseCPRel? ReadOnlySectionLarge
|
||||||
: DataRelROSectionLarge;
|
: DataRelROSectionLarge;
|
||||||
if (Kind.isBSS()) return BSSSectionLarge;
|
if (Kind.isBSS() || Kind.isCommon())return BSSSectionLarge;
|
||||||
if (Kind.isDataRel()) return DataSectionLarge;
|
if (Kind.isDataRel()) return DataSectionLarge;
|
||||||
if (Kind.isReadOnlyWithRel()) return DataRelROSectionLarge;
|
if (Kind.isReadOnlyWithRel()) return DataRelROSectionLarge;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,21 @@ define protected void @test_protected() {
|
||||||
; CHECK: .weak array
|
; CHECK: .weak array
|
||||||
@array = weak global [2 x i32] zeroinitializer
|
@array = weak global [2 x i32] zeroinitializer
|
||||||
|
|
||||||
|
; CHECK: .globl ac.globound
|
||||||
|
; CHECK: ac.globound = 2
|
||||||
|
; CHECK: .weak ac.globound
|
||||||
|
; CHECK: .globl ac
|
||||||
|
; CHECK: .weak ac
|
||||||
|
@ac = common global [2 x i32] zeroinitializer
|
||||||
|
|
||||||
|
; CHECK: .globl gd
|
||||||
; CHECK: .weak gd
|
; CHECK: .weak gd
|
||||||
@gd = weak global i32 0
|
@gd = weak global i32 0
|
||||||
|
|
||||||
|
; CHECK: .globl gc
|
||||||
|
; CHECK: .weak gc
|
||||||
|
@gc = common global i32 0
|
||||||
|
|
||||||
; CHECK-NOT: .hidden test_hidden_declaration
|
; CHECK-NOT: .hidden test_hidden_declaration
|
||||||
|
|
||||||
; CHECK: .weak gr
|
; CHECK: .weak gr
|
||||||
|
|
Loading…
Reference in New Issue