mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-23 16:19:52 +00:00
Devirtualize Constant::replaceUsesOfWithOnConstant.
This is part of the work to devirtualize Value. The old pattern was to call replaceUsesOfWithOnConstant which was overridden by subclasses. Those could then call replaceUsesOfWithOnConstantImpl on Constant to handle deleting the current value. To be consistent with other parts of the code, this has been changed so that we call the method on Constant, and that dispatches to an Impl on subclasses. As part of this, it made sense to rename the methods to be more descriptive. The new name is Constant::handleOperandChange, and it requires that all subclasses of Constant implement handleOperandChangeImpl, even if they just throw an error if they shouldn't be called. Reviewed by Duncan Exon Smith. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240567 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -47,8 +47,6 @@ protected:
|
||||
Constant(Type *ty, ValueTy vty, Use *Ops, unsigned NumOps)
|
||||
: User(ty, vty, Ops, NumOps) {}
|
||||
|
||||
void replaceUsesOfWithOnConstantImpl(Constant *Replacement);
|
||||
|
||||
public:
|
||||
/// isNullValue - Return true if this is the value that would be returned by
|
||||
/// getNullValue.
|
||||
@@ -140,8 +138,8 @@ public:
|
||||
V->getValueID() <= ConstantLastVal;
|
||||
}
|
||||
|
||||
/// replaceUsesOfWithOnConstant - This method is a special form of
|
||||
/// User::replaceUsesOfWith (which does not work on constants) that does work
|
||||
/// This method is a special form of User::replaceUsesOfWith
|
||||
/// (which does not work on constants) that does work
|
||||
/// on constants. Basically this method goes through the trouble of building
|
||||
/// a new constant that is equivalent to the current one, with all uses of
|
||||
/// From replaced with uses of To. After this construction is completed, all
|
||||
@@ -150,15 +148,7 @@ public:
|
||||
/// use Value::replaceAllUsesWith, which automatically dispatches to this
|
||||
/// method as needed.
|
||||
///
|
||||
virtual void replaceUsesOfWithOnConstant(Value *, Value *, Use *) {
|
||||
// Provide a default implementation for constants (like integers) that
|
||||
// cannot use any other values. This cannot be called at runtime, but needs
|
||||
// to be here to avoid link errors.
|
||||
assert(getNumOperands() == 0 && "replaceUsesOfWithOnConstant must be "
|
||||
"implemented for all constants that have operands!");
|
||||
llvm_unreachable("Constants that do not have operands cannot be using "
|
||||
"'From'!");
|
||||
}
|
||||
void handleOperandChange(Value *, Value *, Use *);
|
||||
|
||||
static Constant *getNullValue(Type* Ty);
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ class ConstantInt : public Constant {
|
||||
|
||||
friend class Constant;
|
||||
void destroyConstantImpl();
|
||||
Value *handleOperandChangeImpl(Value *From, Value *To, Use *U);
|
||||
|
||||
protected:
|
||||
// allocate space for exactly zero operands
|
||||
@@ -238,6 +239,7 @@ class ConstantFP : public Constant {
|
||||
|
||||
friend class Constant;
|
||||
void destroyConstantImpl();
|
||||
Value *handleOperandChangeImpl(Value *From, Value *To, Use *U);
|
||||
|
||||
protected:
|
||||
ConstantFP(Type *Ty, const APFloat& V);
|
||||
@@ -308,6 +310,7 @@ class ConstantAggregateZero : public Constant {
|
||||
|
||||
friend class Constant;
|
||||
void destroyConstantImpl();
|
||||
Value *handleOperandChangeImpl(Value *From, Value *To, Use *U);
|
||||
|
||||
protected:
|
||||
explicit ConstantAggregateZero(Type *ty)
|
||||
@@ -356,6 +359,7 @@ class ConstantArray : public Constant {
|
||||
|
||||
friend class Constant;
|
||||
void destroyConstantImpl();
|
||||
Value *handleOperandChangeImpl(Value *From, Value *To, Use *U);
|
||||
|
||||
protected:
|
||||
ConstantArray(ArrayType *T, ArrayRef<Constant *> Val);
|
||||
@@ -377,8 +381,6 @@ public:
|
||||
return cast<ArrayType>(Value::getType());
|
||||
}
|
||||
|
||||
void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) override;
|
||||
|
||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||
static bool classof(const Value *V) {
|
||||
return V->getValueID() == ConstantArrayVal;
|
||||
@@ -401,6 +403,7 @@ class ConstantStruct : public Constant {
|
||||
|
||||
friend class Constant;
|
||||
void destroyConstantImpl();
|
||||
Value *handleOperandChangeImpl(Value *From, Value *To, Use *U);
|
||||
|
||||
protected:
|
||||
ConstantStruct(StructType *T, ArrayRef<Constant *> Val);
|
||||
@@ -438,8 +441,6 @@ public:
|
||||
return cast<StructType>(Value::getType());
|
||||
}
|
||||
|
||||
void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) override;
|
||||
|
||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||
static bool classof(const Value *V) {
|
||||
return V->getValueID() == ConstantStructVal;
|
||||
@@ -463,6 +464,7 @@ class ConstantVector : public Constant {
|
||||
|
||||
friend class Constant;
|
||||
void destroyConstantImpl();
|
||||
Value *handleOperandChangeImpl(Value *From, Value *To, Use *U);
|
||||
|
||||
protected:
|
||||
ConstantVector(VectorType *T, ArrayRef<Constant *> Val);
|
||||
@@ -492,8 +494,6 @@ public:
|
||||
/// elements have the same value, return that value. Otherwise return NULL.
|
||||
Constant *getSplatValue() const;
|
||||
|
||||
void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) override;
|
||||
|
||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||
static bool classof(const Value *V) {
|
||||
return V->getValueID() == ConstantVectorVal;
|
||||
@@ -516,6 +516,7 @@ class ConstantPointerNull : public Constant {
|
||||
|
||||
friend class Constant;
|
||||
void destroyConstantImpl();
|
||||
Value *handleOperandChangeImpl(Value *From, Value *To, Use *U);
|
||||
|
||||
protected:
|
||||
explicit ConstantPointerNull(PointerType *T)
|
||||
@@ -569,6 +570,7 @@ class ConstantDataSequential : public Constant {
|
||||
|
||||
friend class Constant;
|
||||
void destroyConstantImpl();
|
||||
Value *handleOperandChangeImpl(Value *From, Value *To, Use *U);
|
||||
|
||||
protected:
|
||||
explicit ConstantDataSequential(Type *ty, ValueTy VT, const char *Data)
|
||||
@@ -804,6 +806,7 @@ class BlockAddress : public Constant {
|
||||
|
||||
friend class Constant;
|
||||
void destroyConstantImpl();
|
||||
Value *handleOperandChangeImpl(Value *From, Value *To, Use *U);
|
||||
|
||||
public:
|
||||
/// get - Return a BlockAddress for the specified function and basic block.
|
||||
@@ -825,8 +828,6 @@ public:
|
||||
Function *getFunction() const { return (Function*)Op<0>().get(); }
|
||||
BasicBlock *getBasicBlock() const { return (BasicBlock*)Op<1>().get(); }
|
||||
|
||||
void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) override;
|
||||
|
||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||
static inline bool classof(const Value *V) {
|
||||
return V->getValueID() == BlockAddressVal;
|
||||
@@ -853,6 +854,7 @@ class ConstantExpr : public Constant {
|
||||
|
||||
friend class Constant;
|
||||
void destroyConstantImpl();
|
||||
Value *handleOperandChangeImpl(Value *From, Value *To, Use *U);
|
||||
|
||||
protected:
|
||||
ConstantExpr(Type *ty, unsigned Opcode, Use *Ops, unsigned NumOps)
|
||||
@@ -1185,8 +1187,6 @@ public:
|
||||
/// would make it harder to remove ConstantExprs altogether.
|
||||
Instruction *getAsInstruction();
|
||||
|
||||
void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) override;
|
||||
|
||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||
static inline bool classof(const Value *V) {
|
||||
return V->getValueID() == ConstantExprVal;
|
||||
@@ -1223,6 +1223,7 @@ class UndefValue : public Constant {
|
||||
|
||||
friend class Constant;
|
||||
void destroyConstantImpl();
|
||||
Value *handleOperandChangeImpl(Value *From, Value *To, Use *U);
|
||||
|
||||
protected:
|
||||
explicit UndefValue(Type *T) : Constant(T, UndefValueVal, nullptr, 0) {}
|
||||
|
||||
@@ -92,7 +92,7 @@ private:
|
||||
|
||||
friend class Constant;
|
||||
void destroyConstantImpl();
|
||||
void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) override;
|
||||
Value *handleOperandChangeImpl(Value *From, Value *To, Use *U);
|
||||
|
||||
protected:
|
||||
/// \brief The intrinsic ID for this subclass (which must be a Function).
|
||||
|
||||
@@ -45,7 +45,6 @@ class GlobalVariable : public GlobalObject, public ilist_node<GlobalVariable> {
|
||||
// can change from its initial
|
||||
// value before global
|
||||
// initializers are run?
|
||||
|
||||
public:
|
||||
// allocate space for exactly one operand
|
||||
void *operator new(size_t s) {
|
||||
|
||||
Reference in New Issue
Block a user