[llvm-commits] [llvm] r46090 - /llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp
Chris Lattner
sabre at nondot.org
Wed Jan 16 13:35:44 PST 2008
Author: lattner
Date: Wed Jan 16 15:35:43 2008
New Revision: 46090
URL: http://llvm.org/viewvc/llvm-project?rev=46090&view=rev
Log:
Handle attribute(used) global variables that are i8.
Modified:
llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp
Modified: llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp?rev=46090&r1=46089&r2=46090&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp Wed Jan 16 15:35:43 2008
@@ -101,20 +101,21 @@
// If we're not just stripping debug info, strip all symbols from the
// functions and the names from any internal globals.
if (!OnlyDebugInfo) {
- SmallPtrSet<const Constant *, 8> llvmUsedValues;
- Value *LLVMUsed = M.getValueSymbolTable().lookup("llvm.used");
- if (LLVMUsed) {
+ SmallPtrSet<const GlobalValue*, 8> llvmUsedValues;
+ if (GlobalVariable *LLVMUsed = M.getGlobalVariable("llvm.used")) {
+ llvmUsedValues.insert(LLVMUsed);
// Collect values that are preserved as per explicit request.
// llvm.used is used to list these values.
- if (GlobalVariable *GV = dyn_cast<GlobalVariable>(LLVMUsed)) {
- if (ConstantArray *InitList =
- dyn_cast<ConstantArray>(GV->getInitializer())) {
- for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
- if (ConstantExpr *CE =
- dyn_cast<ConstantExpr>(InitList->getOperand(i)))
- if (CE->isCast())
- llvmUsedValues.insert(CE->getOperand(0));
- }
+ if (ConstantArray *Inits =
+ dyn_cast<ConstantArray>(LLVMUsed->getInitializer())) {
+ for (unsigned i = 0, e = Inits->getNumOperands(); i != e; ++i) {
+ if (GlobalValue *GV = dyn_cast<GlobalValue>(Inits->getOperand(i)))
+ llvmUsedValues.insert(GV);
+ else if (ConstantExpr *CE =
+ dyn_cast<ConstantExpr>(Inits->getOperand(i)))
+ if (CE->getOpcode() == Instruction::BitCast)
+ if (GlobalValue *GV = dyn_cast<GlobalValue>(CE->getOperand(0)))
+ llvmUsedValues.insert(GV);
}
}
}
@@ -123,8 +124,6 @@
I != E; ++I) {
if (I->hasInternalLinkage() && llvmUsedValues.count(I) == 0)
I->setName(""); // Internal symbols can't participate in linkage
- else if (I->getName() == "llvm.used") {
- }
}
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
More information about the llvm-commits
mailing list