[llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp
Chris Lattner
sabre at nondot.org
Mon Sep 25 20:38:37 PDT 2006
Changes in directory llvm/lib/CodeGen:
AsmPrinter.cpp updated: 1.98 -> 1.99
---
Log message:
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.
---
Diffs of the changes: (+21 -2)
AsmPrinter.cpp | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.98 llvm/lib/CodeGen/AsmPrinter.cpp:1.99
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.98 Sun Sep 24 14:44:59 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Sep 25 22:38:18 2006
@@ -253,8 +253,11 @@
assert(GV->hasInitializer() && "Not a special LLVM global!");
- if (GV->getName() == "llvm.used")
- return true; // No need to emit this at all.
+ if (GV->getName() == "llvm.used") {
+ 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()) {
SwitchToDataSection(TAI->getStaticCtorsSection(), 0);
@@ -273,6 +276,22 @@
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
/// function pointers, ignoring the init priority.
void AsmPrinter::EmitXXStructorList(Constant *List) {
More information about the llvm-commits
mailing list