mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-15 22:28:18 +00:00
Handle attribute(used) global variables that are i8.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46090 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -101,20 +101,21 @@ bool StripSymbols::runOnModule(Module &M) {
|
|||||||
// If we're not just stripping debug info, strip all symbols from the
|
// If we're not just stripping debug info, strip all symbols from the
|
||||||
// functions and the names from any internal globals.
|
// functions and the names from any internal globals.
|
||||||
if (!OnlyDebugInfo) {
|
if (!OnlyDebugInfo) {
|
||||||
SmallPtrSet<const Constant *, 8> llvmUsedValues;
|
SmallPtrSet<const GlobalValue*, 8> llvmUsedValues;
|
||||||
Value *LLVMUsed = M.getValueSymbolTable().lookup("llvm.used");
|
if (GlobalVariable *LLVMUsed = M.getGlobalVariable("llvm.used")) {
|
||||||
if (LLVMUsed) {
|
llvmUsedValues.insert(LLVMUsed);
|
||||||
// Collect values that are preserved as per explicit request.
|
// Collect values that are preserved as per explicit request.
|
||||||
// llvm.used is used to list these values.
|
// llvm.used is used to list these values.
|
||||||
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(LLVMUsed)) {
|
if (ConstantArray *Inits =
|
||||||
if (ConstantArray *InitList =
|
dyn_cast<ConstantArray>(LLVMUsed->getInitializer())) {
|
||||||
dyn_cast<ConstantArray>(GV->getInitializer())) {
|
for (unsigned i = 0, e = Inits->getNumOperands(); i != e; ++i) {
|
||||||
for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
|
if (GlobalValue *GV = dyn_cast<GlobalValue>(Inits->getOperand(i)))
|
||||||
if (ConstantExpr *CE =
|
llvmUsedValues.insert(GV);
|
||||||
dyn_cast<ConstantExpr>(InitList->getOperand(i)))
|
else if (ConstantExpr *CE =
|
||||||
if (CE->isCast())
|
dyn_cast<ConstantExpr>(Inits->getOperand(i)))
|
||||||
llvmUsedValues.insert(CE->getOperand(0));
|
if (CE->getOpcode() == Instruction::BitCast)
|
||||||
}
|
if (GlobalValue *GV = dyn_cast<GlobalValue>(CE->getOperand(0)))
|
||||||
|
llvmUsedValues.insert(GV);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,8 +124,6 @@ bool StripSymbols::runOnModule(Module &M) {
|
|||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
if (I->hasInternalLinkage() && llvmUsedValues.count(I) == 0)
|
if (I->hasInternalLinkage() && llvmUsedValues.count(I) == 0)
|
||||||
I->setName(""); // Internal symbols can't participate in linkage
|
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) {
|
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
|
||||||
|
Reference in New Issue
Block a user