mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-03 13:31:05 +00:00
bug 122:
- Replace ConstantPointerRef usage with GlobalValue usage - Minimize redundant isa<GlobalValue> usage - Correct isa<Constant> for GlobalValue subclass - Delete ConstantPointerRef member function implementations git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14928 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7970396014
commit
1c9c8e64d2
@ -14,6 +14,7 @@
|
|||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "ConstantFolding.h"
|
#include "ConstantFolding.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
|
#include "llvm/GlobalValue.h"
|
||||||
#include "llvm/iMemory.h"
|
#include "llvm/iMemory.h"
|
||||||
#include "llvm/SymbolTable.h"
|
#include "llvm/SymbolTable.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
@ -54,8 +55,8 @@ void Constant::destroyConstantImpl() {
|
|||||||
<< *V << "\n\n";
|
<< *V << "\n\n";
|
||||||
#endif
|
#endif
|
||||||
assert(isa<Constant>(V) && "References remain to Constant being destroyed");
|
assert(isa<Constant>(V) && "References remain to Constant being destroyed");
|
||||||
Constant *CPV = cast<Constant>(V);
|
Constant *CV = cast<Constant>(V);
|
||||||
CPV->destroyConstant();
|
CV->destroyConstant();
|
||||||
|
|
||||||
// The constant should remove itself from our use list...
|
// The constant should remove itself from our use list...
|
||||||
assert((use_empty() || use_back() != V) && "Constant not removed!");
|
assert((use_empty() || use_back() != V) && "Constant not removed!");
|
||||||
@ -267,12 +268,6 @@ ConstantStruct::ConstantStruct(const StructType *T,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstantPointerRef::ConstantPointerRef(GlobalValue *GV)
|
|
||||||
: Constant(GV->getType()) {
|
|
||||||
Operands.reserve(1);
|
|
||||||
Operands.push_back(Use(GV, this));
|
|
||||||
}
|
|
||||||
|
|
||||||
ConstantExpr::ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty)
|
ConstantExpr::ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty)
|
||||||
: Constant(Ty), iType(Opcode) {
|
: Constant(Ty), iType(Opcode) {
|
||||||
Operands.reserve(1);
|
Operands.reserve(1);
|
||||||
@ -420,16 +415,10 @@ bool ConstantStruct::classof(const Constant *CPV) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ConstantPointerNull::classof(const Constant *CPV) {
|
bool ConstantPointerNull::classof(const Constant *CPV) {
|
||||||
return isa<PointerType>(CPV->getType()) && !isa<ConstantExpr>(CPV) &&
|
return !isa<GlobalValue>(CPV) && isa<PointerType>(CPV->getType()) && !isa<ConstantExpr>(CPV) &&
|
||||||
CPV->getNumOperands() == 0;
|
CPV->getNumOperands() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConstantPointerRef::classof(const Constant *CPV) {
|
|
||||||
return isa<PointerType>(CPV->getType()) && !isa<ConstantExpr>(CPV) &&
|
|
||||||
CPV->getNumOperands() == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// isValueValidForType implementations
|
// isValueValidForType implementations
|
||||||
@ -532,31 +521,6 @@ void ConstantStruct::replaceUsesOfWithOnConstant(Value *From, Value *To,
|
|||||||
destroyConstant();
|
destroyConstant();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConstantPointerRef::replaceUsesOfWithOnConstant(Value *From, Value *To,
|
|
||||||
bool DisableChecking) {
|
|
||||||
if (isa<GlobalValue>(To)) {
|
|
||||||
assert(From == getOperand(0) && "Doesn't contain from!");
|
|
||||||
ConstantPointerRef *Replacement =
|
|
||||||
ConstantPointerRef::get(cast<GlobalValue>(To));
|
|
||||||
|
|
||||||
// Everyone using this now uses the replacement...
|
|
||||||
if (DisableChecking)
|
|
||||||
uncheckedReplaceAllUsesWith(Replacement);
|
|
||||||
else
|
|
||||||
replaceAllUsesWith(Replacement);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// Just replace ourselves with the To value specified.
|
|
||||||
if (DisableChecking)
|
|
||||||
uncheckedReplaceAllUsesWith(To);
|
|
||||||
else
|
|
||||||
replaceAllUsesWith(To);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete the old constant!
|
|
||||||
destroyConstant();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV,
|
void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV,
|
||||||
bool DisableChecking) {
|
bool DisableChecking) {
|
||||||
assert(isa<Constant>(ToV) && "Cannot make Constant refer to non-constant!");
|
assert(isa<Constant>(ToV) && "Cannot make Constant refer to non-constant!");
|
||||||
@ -1050,23 +1014,6 @@ void ConstantPointerNull::destroyConstant() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//---- ConstantPointerRef::get() implementation...
|
|
||||||
//
|
|
||||||
ConstantPointerRef *ConstantPointerRef::get(GlobalValue *GV) {
|
|
||||||
assert(GV->getParent() && "Global Value must be attached to a module!");
|
|
||||||
|
|
||||||
// The Module handles the pointer reference sharing...
|
|
||||||
return GV->getParent()->getConstantPointerRef(GV);
|
|
||||||
}
|
|
||||||
|
|
||||||
// destroyConstant - Remove the constant from the constant table...
|
|
||||||
//
|
|
||||||
void ConstantPointerRef::destroyConstant() {
|
|
||||||
getValue()->getParent()->destroyConstantPointerRef(this);
|
|
||||||
destroyConstantImpl();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//---- ConstantExpr::get() implementations...
|
//---- ConstantExpr::get() implementations...
|
||||||
//
|
//
|
||||||
typedef std::pair<unsigned, std::vector<Constant*> > ExprMapKeyType;
|
typedef std::pair<unsigned, std::vector<Constant*> > ExprMapKeyType;
|
||||||
@ -1259,3 +1206,4 @@ void ConstantExpr::destroyConstant() {
|
|||||||
const char *ConstantExpr::getOpcodeName() const {
|
const char *ConstantExpr::getOpcodeName() const {
|
||||||
return Instruction::getOpcodeName(getOpcode());
|
return Instruction::getOpcodeName(getOpcode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user