Skip to content

Commit 39f1561

Browse files
committed
Handle attribute(used) global variables that are i8.
llvm-svn: 46090
1 parent ed20366 commit 39f1561

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

llvm/lib/Transforms/IPO/StripSymbols.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,21 @@ bool StripSymbols::runOnModule(Module &M) {
101101
// If we're not just stripping debug info, strip all symbols from the
102102
// functions and the names from any internal globals.
103103
if (!OnlyDebugInfo) {
104-
SmallPtrSet<const Constant *, 8> llvmUsedValues;
105-
Value *LLVMUsed = M.getValueSymbolTable().lookup("llvm.used");
106-
if (LLVMUsed) {
104+
SmallPtrSet<const GlobalValue*, 8> llvmUsedValues;
105+
if (GlobalVariable *LLVMUsed = M.getGlobalVariable("llvm.used")) {
106+
llvmUsedValues.insert(LLVMUsed);
107107
// Collect values that are preserved as per explicit request.
108108
// llvm.used is used to list these values.
109-
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(LLVMUsed)) {
110-
if (ConstantArray *InitList =
111-
dyn_cast<ConstantArray>(GV->getInitializer())) {
112-
for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
113-
if (ConstantExpr *CE =
114-
dyn_cast<ConstantExpr>(InitList->getOperand(i)))
115-
if (CE->isCast())
116-
llvmUsedValues.insert(CE->getOperand(0));
117-
}
109+
if (ConstantArray *Inits =
110+
dyn_cast<ConstantArray>(LLVMUsed->getInitializer())) {
111+
for (unsigned i = 0, e = Inits->getNumOperands(); i != e; ++i) {
112+
if (GlobalValue *GV = dyn_cast<GlobalValue>(Inits->getOperand(i)))
113+
llvmUsedValues.insert(GV);
114+
else if (ConstantExpr *CE =
115+
dyn_cast<ConstantExpr>(Inits->getOperand(i)))
116+
if (CE->getOpcode() == Instruction::BitCast)
117+
if (GlobalValue *GV = dyn_cast<GlobalValue>(CE->getOperand(0)))
118+
llvmUsedValues.insert(GV);
118119
}
119120
}
120121
}
@@ -123,8 +124,6 @@ bool StripSymbols::runOnModule(Module &M) {
123124
I != E; ++I) {
124125
if (I->hasInternalLinkage() && llvmUsedValues.count(I) == 0)
125126
I->setName(""); // Internal symbols can't participate in linkage
126-
else if (I->getName() == "llvm.used") {
127-
}
128127
}
129128

130129
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {

0 commit comments

Comments
 (0)