mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-02 22:32:08 +00:00
Add support for targets that want to do something with the llvm.used list,
because they have an aggressive linker that does dead code stripping. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30604 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
384299ef45
commit
cb05af852f
@ -197,6 +197,7 @@ namespace llvm {
|
|||||||
void printDataDirective(const Type *type);
|
void printDataDirective(const Type *type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void EmitLLVMUsedList(Constant *List);
|
||||||
void EmitXXStructorList(Constant *List);
|
void EmitXXStructorList(Constant *List);
|
||||||
void EmitConstantPool(unsigned Alignment, const char *Section,
|
void EmitConstantPool(unsigned Alignment, const char *Section,
|
||||||
std::vector<std::pair<MachineConstantPoolEntry,unsigned> > &CP);
|
std::vector<std::pair<MachineConstantPoolEntry,unsigned> > &CP);
|
||||||
|
@ -199,6 +199,11 @@ namespace llvm {
|
|||||||
/// directives, this is true for most ELF targets.
|
/// directives, this is true for most ELF targets.
|
||||||
bool HasDotTypeDotSizeDirective; // Defaults to true.
|
bool HasDotTypeDotSizeDirective; // Defaults to true.
|
||||||
|
|
||||||
|
/// UsedDirective - This directive, if non-null, is used to declare a global
|
||||||
|
/// as being used somehow that the assembler can't see. This prevents dead
|
||||||
|
/// code elimination on some targets.
|
||||||
|
const char *UsedDirective; // Defaults to null.
|
||||||
|
|
||||||
//===--- Dwarf Emission Directives -----------------------------------===//
|
//===--- Dwarf Emission Directives -----------------------------------===//
|
||||||
|
|
||||||
/// HasLEB128 - True if target asm supports leb128 directives.
|
/// HasLEB128 - True if target asm supports leb128 directives.
|
||||||
@ -387,6 +392,9 @@ namespace llvm {
|
|||||||
bool hasDotTypeDotSizeDirective() const {
|
bool hasDotTypeDotSizeDirective() const {
|
||||||
return HasDotTypeDotSizeDirective;
|
return HasDotTypeDotSizeDirective;
|
||||||
}
|
}
|
||||||
|
const char *getUsedDirective() const {
|
||||||
|
return UsedDirective;
|
||||||
|
}
|
||||||
bool hasLEB128() const {
|
bool hasLEB128() const {
|
||||||
return HasLEB128;
|
return HasLEB128;
|
||||||
}
|
}
|
||||||
|
@ -253,8 +253,11 @@ bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) {
|
|||||||
|
|
||||||
assert(GV->hasInitializer() && "Not a special LLVM global!");
|
assert(GV->hasInitializer() && "Not a special LLVM global!");
|
||||||
|
|
||||||
if (GV->getName() == "llvm.used")
|
if (GV->getName() == "llvm.used") {
|
||||||
return true; // No need to emit this at all.
|
if (TAI->getUsedDirective() != 0) // No need to emit this at all.
|
||||||
|
EmitLLVMUsedList(GV->getInitializer());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (GV->getName() == "llvm.global_ctors" && GV->use_empty()) {
|
if (GV->getName() == "llvm.global_ctors" && GV->use_empty()) {
|
||||||
SwitchToDataSection(TAI->getStaticCtorsSection(), 0);
|
SwitchToDataSection(TAI->getStaticCtorsSection(), 0);
|
||||||
@ -273,6 +276,22 @@ bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// EmitLLVMUsedList - For targets that define a TAI::UsedDirective, mark each
|
||||||
|
/// global in the specified llvm.used list as being used with this directive.
|
||||||
|
void AsmPrinter::EmitLLVMUsedList(Constant *List) {
|
||||||
|
const char *Directive = TAI->getUsedDirective();
|
||||||
|
|
||||||
|
// Should be an array of 'sbyte*'.
|
||||||
|
ConstantArray *InitList = dyn_cast<ConstantArray>(List);
|
||||||
|
if (InitList == 0) return;
|
||||||
|
|
||||||
|
for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
|
||||||
|
O << Directive;
|
||||||
|
EmitConstantValueOnly(InitList->getOperand(i));
|
||||||
|
O << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// EmitXXStructorList - Emit the ctor or dtor list. This just prints out the
|
/// EmitXXStructorList - Emit the ctor or dtor list. This just prints out the
|
||||||
/// function pointers, ignoring the init priority.
|
/// function pointers, ignoring the init priority.
|
||||||
void AsmPrinter::EmitXXStructorList(Constant *List) {
|
void AsmPrinter::EmitXXStructorList(Constant *List) {
|
||||||
|
@ -58,6 +58,7 @@ TargetAsmInfo::TargetAsmInfo() :
|
|||||||
COMMDirective("\t.comm\t"),
|
COMMDirective("\t.comm\t"),
|
||||||
COMMDirectiveTakesAlignment(true),
|
COMMDirectiveTakesAlignment(true),
|
||||||
HasDotTypeDotSizeDirective(true),
|
HasDotTypeDotSizeDirective(true),
|
||||||
|
UsedDirective(0),
|
||||||
HasLEB128(false),
|
HasLEB128(false),
|
||||||
HasDotLoc(false),
|
HasDotLoc(false),
|
||||||
HasDotFile(false),
|
HasDotFile(false),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user