aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/LLVMContextImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VMCore/LLVMContextImpl.cpp')
-rw-r--r--lib/VMCore/LLVMContextImpl.cpp111
1 files changed, 0 insertions, 111 deletions
diff --git a/lib/VMCore/LLVMContextImpl.cpp b/lib/VMCore/LLVMContextImpl.cpp
index 858ed15..72e415c 100644
--- a/lib/VMCore/LLVMContextImpl.cpp
+++ b/lib/VMCore/LLVMContextImpl.cpp
@@ -21,14 +21,6 @@ using namespace llvm;
static char getValType(ConstantAggregateZero *CPZ) { return 0; }
-static std::vector<Constant*> getValType(ConstantArray *CA) {
- std::vector<Constant*> Elements;
- Elements.reserve(CA->getNumOperands());
- for (unsigned i = 0, e = CA->getNumOperands(); i != e; ++i)
- Elements.push_back(cast<Constant>(CA->getOperand(i)));
- return Elements;
-}
-
static std::vector<Constant*> getValType(ConstantVector *CP) {
std::vector<Constant*> Elements;
Elements.reserve(CP->getNumOperands());
@@ -85,25 +77,6 @@ LLVMContextImpl::getConstantAggregateZero(const Type *Ty) {
return AggZeroConstants.getOrCreate(Ty, 0);
}
-Constant *LLVMContextImpl::getConstantArray(const ArrayType *Ty,
- const std::vector<Constant*> &V) {
- // If this is an all-zero array, return a ConstantAggregateZero object
- if (!V.empty()) {
- Constant *C = V[0];
- if (!C->isNullValue()) {
- // Implicitly locked.
- return ArrayConstants.getOrCreate(Ty, V);
- }
- for (unsigned i = 1, e = V.size(); i != e; ++i)
- if (V[i] != C) {
- // Implicitly locked.
- return ArrayConstants.getOrCreate(Ty, V);
- }
- }
-
- return Context.getConstantAggregateZero(Ty);
-}
-
Constant *LLVMContextImpl::getConstantVector(const VectorType *Ty,
const std::vector<Constant*> &V) {
assert(!V.empty() && "Vectors can't be empty");
@@ -146,90 +119,6 @@ void LLVMContextImpl::erase(ConstantAggregateZero *Z) {
AggZeroConstants.remove(Z);
}
-void LLVMContextImpl::erase(ConstantArray *C) {
- ArrayConstants.remove(C);
-}
-
void LLVMContextImpl::erase(ConstantVector *V) {
VectorConstants.remove(V);
}
-
-// *** RAUW helpers ***
-
-Constant *LLVMContextImpl::replaceUsesOfWithOnConstant(ConstantArray *CA,
- Value *From, Value *To, Use *U) {
- assert(isa<Constant>(To) && "Cannot make Constant refer to non-constant!");
- Constant *ToC = cast<Constant>(To);
-
- std::pair<ArrayConstantsTy::MapKey, Constant*> Lookup;
- Lookup.first.first = CA->getType();
- Lookup.second = CA;
-
- std::vector<Constant*> &Values = Lookup.first.second;
- Values.reserve(CA->getNumOperands()); // Build replacement array.
-
- // Fill values with the modified operands of the constant array. Also,
- // compute whether this turns into an all-zeros array.
- bool isAllZeros = false;
- unsigned NumUpdated = 0;
- if (!ToC->isNullValue()) {
- for (Use *O = CA->OperandList, *E = CA->OperandList + CA->getNumOperands();
- O != E; ++O) {
- Constant *Val = cast<Constant>(O->get());
- if (Val == From) {
- Val = ToC;
- ++NumUpdated;
- }
- Values.push_back(Val);
- }
- } else {
- isAllZeros = true;
- for (Use *O = CA->OperandList, *E = CA->OperandList + CA->getNumOperands();
- O != E; ++O) {
- Constant *Val = cast<Constant>(O->get());
- if (Val == From) {
- Val = ToC;
- ++NumUpdated;
- }
- Values.push_back(Val);
- if (isAllZeros) isAllZeros = Val->isNullValue();
- }
- }
-
- Constant *Replacement = 0;
- if (isAllZeros) {
- Replacement = Context.getConstantAggregateZero(CA->getType());
- } else {
- // Check to see if we have this array type already.
- sys::SmartScopedWriter<true> Writer(ConstantsLock);
- bool Exists;
- ArrayConstantsTy::MapTy::iterator I =
- ArrayConstants.InsertOrGetItem(Lookup, Exists);
-
- if (Exists) {
- Replacement = I->second;
- } else {
- // Okay, the new shape doesn't exist in the system yet. Instead of
- // creating a new constant array, inserting it, replaceallusesof'ing the
- // old with the new, then deleting the old... just update the current one
- // in place!
- ArrayConstants.MoveConstantToNewSlot(CA, I);
-
- // Update to the new value. Optimize for the case when we have a single
- // operand that we're changing, but handle bulk updates efficiently.
- if (NumUpdated == 1) {
- unsigned OperandToUpdate = U - CA->OperandList;
- assert(CA->getOperand(OperandToUpdate) == From &&
- "ReplaceAllUsesWith broken!");
- CA->setOperand(OperandToUpdate, ToC);
- } else {
- for (unsigned i = 0, e = CA->getNumOperands(); i != e; ++i)
- if (CA->getOperand(i) == From)
- CA->setOperand(i, ToC);
- }
- return 0;
- }
- }
-
- return Replacement;
-} \ No newline at end of file