forked from OSchip/llvm-project
parent
647e883a09
commit
776abee608
|
@ -63,6 +63,8 @@ namespace {
|
|||
: AsmPrinter(O, TM, T) {
|
||||
}
|
||||
|
||||
std::set<std::string> ExtWeakSymbols;
|
||||
|
||||
/// We name each basic block in a Function with a unique number, so
|
||||
/// that we can consistently refer to them later. This is cleared
|
||||
/// at the beginning of each call to runOnMachineFunction().
|
||||
|
@ -127,7 +129,7 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||
break;
|
||||
case Function::WeakLinkage:
|
||||
case Function::LinkOnceLinkage:
|
||||
O << "\t.weak\t" << CurrentFnName << "\n";
|
||||
O << TAI->getWeakRefDirective() << CurrentFnName << "\n";
|
||||
break;
|
||||
}
|
||||
EmitAlignment(2, F);
|
||||
|
@ -244,6 +246,9 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
|||
GlobalValue *GV = MO.getGlobal();
|
||||
std::string Name = Mang->getValueName(GV);
|
||||
O << Name;
|
||||
if (GV->hasExternalWeakLinkage()) {
|
||||
ExtWeakSymbols.insert(Name);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MachineOperand::MO_ExternalSymbol:
|
||||
|
@ -325,6 +330,13 @@ bool ARMAsmPrinter::doFinalization(Module &M) {
|
|||
}
|
||||
}
|
||||
|
||||
if (ExtWeakSymbols.begin() != ExtWeakSymbols.end())
|
||||
SwitchToDataSection("");
|
||||
for (std::set<std::string>::iterator i = ExtWeakSymbols.begin(),
|
||||
e = ExtWeakSymbols.end(); i != e; ++i) {
|
||||
O << TAI->getWeakRefDirective() << *i << "\n";
|
||||
}
|
||||
|
||||
AsmPrinter::doFinalization(M);
|
||||
return false; // success
|
||||
}
|
||||
|
|
|
@ -23,4 +23,5 @@ ARMTargetAsmInfo::ARMTargetAsmInfo(const ARMTargetMachine &TM) {
|
|||
CommentString = "@";
|
||||
ConstantPoolSection = "\t.text\n";
|
||||
AlignmentIsInBytes = false;
|
||||
WeakRefDirective = "\t.weak\t";
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm &&
|
||||
; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm | grep .weak
|
||||
; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm | grep .weak.*f &&
|
||||
; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm | grep .weak.*h
|
||||
|
||||
implementation ; Functions:
|
||||
|
||||
|
@ -7,3 +8,11 @@ weak uint %f() {
|
|||
entry:
|
||||
unreachable
|
||||
}
|
||||
|
||||
void %g() {
|
||||
entry:
|
||||
tail call void %h( )
|
||||
ret void
|
||||
}
|
||||
|
||||
declare extern_weak void %h()
|
||||
|
|
Loading…
Reference in New Issue