mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-02 17:55:18 +00:00
Fix Regression/Linker/2006-06-15-GlobalVarAnment.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28812 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
76591ca1eb
commit
1127315562
@ -452,7 +452,8 @@ static bool LinkGlobals(Module *Dest, Module *Src,
|
|||||||
SymbolTable *ST = (SymbolTable*)&Dest->getSymbolTable();
|
SymbolTable *ST = (SymbolTable*)&Dest->getSymbolTable();
|
||||||
|
|
||||||
// Loop over all of the globals in the src module, mapping them over as we go
|
// Loop over all of the globals in the src module, mapping them over as we go
|
||||||
for (Module::global_iterator I = Src->global_begin(), E = Src->global_end(); I != E; ++I) {
|
for (Module::global_iterator I = Src->global_begin(), E = Src->global_end();
|
||||||
|
I != E; ++I) {
|
||||||
GlobalVariable *SGV = I;
|
GlobalVariable *SGV = I;
|
||||||
GlobalVariable *DGV = 0;
|
GlobalVariable *DGV = 0;
|
||||||
// Check to see if may have to link the global.
|
// Check to see if may have to link the global.
|
||||||
@ -487,7 +488,9 @@ static bool LinkGlobals(Module *Dest, Module *Src,
|
|||||||
new GlobalVariable(SGV->getType()->getElementType(),
|
new GlobalVariable(SGV->getType()->getElementType(),
|
||||||
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
|
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
|
||||||
SGV->getName(), Dest);
|
SGV->getName(), Dest);
|
||||||
|
// Propagate alignment info.
|
||||||
|
NewDGV->setAlignment(SGV->getAlignment());
|
||||||
|
|
||||||
// If the LLVM runtime renamed the global, but it is an externally visible
|
// If the LLVM runtime renamed the global, but it is an externally visible
|
||||||
// symbol, DGV must be an existing global with internal linkage. Rename
|
// symbol, DGV must be an existing global with internal linkage. Rename
|
||||||
// it.
|
// it.
|
||||||
@ -509,12 +512,18 @@ static bool LinkGlobals(Module *Dest, Module *Src,
|
|||||||
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
|
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
|
||||||
"", Dest);
|
"", Dest);
|
||||||
|
|
||||||
|
// Propagate alignment info.
|
||||||
|
NewDGV->setAlignment(std::max(DGV->getAlignment(), SGV->getAlignment()));
|
||||||
|
|
||||||
// Make sure to remember this mapping...
|
// Make sure to remember this mapping...
|
||||||
ValueMap.insert(std::make_pair(SGV, NewDGV));
|
ValueMap.insert(std::make_pair(SGV, NewDGV));
|
||||||
|
|
||||||
// Keep track that this is an appending variable...
|
// Keep track that this is an appending variable...
|
||||||
AppendingVars.insert(std::make_pair(SGV->getName(), NewDGV));
|
AppendingVars.insert(std::make_pair(SGV->getName(), NewDGV));
|
||||||
} else {
|
} else {
|
||||||
|
// Propagate alignment info.
|
||||||
|
DGV->setAlignment(std::max(DGV->getAlignment(), SGV->getAlignment()));
|
||||||
|
|
||||||
// Otherwise, perform the mapping as instructed by GetLinkageResult. If
|
// Otherwise, perform the mapping as instructed by GetLinkageResult. If
|
||||||
// the types don't match, and if we are to link from the source, nuke DGV
|
// the types don't match, and if we are to link from the source, nuke DGV
|
||||||
// and create a new one of the appropriate type.
|
// and create a new one of the appropriate type.
|
||||||
@ -522,6 +531,7 @@ static bool LinkGlobals(Module *Dest, Module *Src,
|
|||||||
GlobalVariable *NewDGV =
|
GlobalVariable *NewDGV =
|
||||||
new GlobalVariable(SGV->getType()->getElementType(),
|
new GlobalVariable(SGV->getType()->getElementType(),
|
||||||
DGV->isConstant(), DGV->getLinkage());
|
DGV->isConstant(), DGV->getLinkage());
|
||||||
|
NewDGV->setAlignment(DGV->getAlignment());
|
||||||
Dest->getGlobalList().insert(DGV, NewDGV);
|
Dest->getGlobalList().insert(DGV, NewDGV);
|
||||||
DGV->replaceAllUsesWith(ConstantExpr::getCast(NewDGV, DGV->getType()));
|
DGV->replaceAllUsesWith(ConstantExpr::getCast(NewDGV, DGV->getType()));
|
||||||
DGV->eraseFromParent();
|
DGV->eraseFromParent();
|
||||||
@ -560,7 +570,8 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src,
|
|||||||
std::string *Err) {
|
std::string *Err) {
|
||||||
|
|
||||||
// Loop over all of the globals in the src module, mapping them over as we go
|
// Loop over all of the globals in the src module, mapping them over as we go
|
||||||
for (Module::const_global_iterator I = Src->global_begin(), E = Src->global_end(); I != E; ++I){
|
for (Module::const_global_iterator I = Src->global_begin(),
|
||||||
|
E = Src->global_end(); I != E; ++I) {
|
||||||
const GlobalVariable *SGV = I;
|
const GlobalVariable *SGV = I;
|
||||||
|
|
||||||
if (SGV->hasInitializer()) { // Only process initialized GV's
|
if (SGV->hasInitializer()) { // Only process initialized GV's
|
||||||
@ -709,7 +720,8 @@ static bool LinkFunctionBody(Function *Dest, Function *Src,
|
|||||||
*OI = RemapOperand(*OI, GlobalMap);
|
*OI = RemapOperand(*OI, GlobalMap);
|
||||||
|
|
||||||
// There is no need to map the arguments anymore.
|
// There is no need to map the arguments anymore.
|
||||||
for (Function::arg_iterator I = Src->arg_begin(), E = Src->arg_end(); I != E; ++I)
|
for (Function::arg_iterator I = Src->arg_begin(), E = Src->arg_end();
|
||||||
|
I != E; ++I)
|
||||||
GlobalMap.erase(I);
|
GlobalMap.erase(I);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -892,7 +904,8 @@ Linker::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) {
|
|||||||
// it's functionality here.
|
// it's functionality here.
|
||||||
std::map<std::string, GlobalValue*> GlobalsByName;
|
std::map<std::string, GlobalValue*> GlobalsByName;
|
||||||
|
|
||||||
for (Module::global_iterator I = Dest->global_begin(), E = Dest->global_end(); I != E; ++I) {
|
for (Module::global_iterator I = Dest->global_begin(), E = Dest->global_end();
|
||||||
|
I != E; ++I) {
|
||||||
// Add all of the appending globals already in the Dest module to
|
// Add all of the appending globals already in the Dest module to
|
||||||
// AppendingVars.
|
// AppendingVars.
|
||||||
if (I->hasAppendingLinkage())
|
if (I->hasAppendingLinkage())
|
||||||
|
Loading…
Reference in New Issue
Block a user