mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
print weak references
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32276 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2792cfb82d
commit
392b1b2ef3
@ -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
Block a user