mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-30 17:25:21 +00:00
Revert "Implement global merge optimization for global variables."
This reverts commit r208934. The patch depends on aliases to GEPs with non zero offsets. That is not supported and fairly broken. The good news is that GlobalAlias is being redesigned and will have support for offsets, so this patch should be a nice match for it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208978 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
#include "llvm/IR/GlobalValue.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/IR/Constants.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/IR/DerivedTypes.h"
|
||||
#include "llvm/IR/GlobalAlias.h"
|
||||
#include "llvm/IR/GlobalVariable.h"
|
||||
@@ -283,27 +282,3 @@ GlobalObject *GlobalAlias::getAliasedGlobal() {
|
||||
return cast<GlobalObject>(GV);
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t GlobalAlias::calculateOffset(const DataLayout &DL) const {
|
||||
uint64_t Offset = 0;
|
||||
const Constant *C = this;
|
||||
while (C) {
|
||||
if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(C)) {
|
||||
C = GA->getAliasee();
|
||||
} else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
|
||||
if (CE->getOpcode() == Instruction::GetElementPtr) {
|
||||
std::vector<Value*> Args;
|
||||
for (unsigned I = 1; I < CE->getNumOperands(); ++I)
|
||||
Args.push_back(CE->getOperand(I));
|
||||
Offset += DL.getIndexedOffset(CE->getOperand(0)->getType(), Args);
|
||||
}
|
||||
C = CE->getOperand(0);
|
||||
} else if (isa<GlobalValue>(C)) {
|
||||
return Offset;
|
||||
} else {
|
||||
assert(0 && "Unexpected type in alias chain!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return Offset;
|
||||
}
|
||||
|
Reference in New Issue
Block a user