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:
Rafael Espindola
2014-05-16 13:02:18 +00:00
parent 2b3ef615ca
commit 21cfedee05
20 changed files with 68 additions and 448 deletions

View File

@@ -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;
}