22 void operator=(
const ConstantPlaceHolder &) =
delete;
26 void *
operator new(
size_t s) {
return User::operator
new(s, 1); }
33 static bool classof(
const Value *V) {
34 return isa<ConstantExpr>(V) &&
35 cast<ConstantExpr>(V)->getOpcode() == Instruction::UserOp1;
61 WeakVH &OldV = ValuePtrs[Idx];
69 if (
Constant *PHC = dyn_cast<Constant>(&*OldV)) {
70 ResolveConstants.push_back(std::make_pair(PHC, Idx));
74 Value *PrevVal = OldV;
75 OldV->replaceAllUsesWith(V);
84 if (
Value *V = ValuePtrs[Idx]) {
85 if (Ty != V->getType())
87 return cast<Constant>(V);
91 Constant *
C =
new ConstantPlaceHolder(Ty, Context);
98 if (Idx == std::numeric_limits<unsigned>::max())
104 if (
Value *V = ValuePtrs[Idx]) {
106 if (Ty && Ty != V->getType())
130 std::sort(ResolveConstants.begin(), ResolveConstants.end());
134 while (!ResolveConstants.empty()) {
136 Constant *Placeholder = ResolveConstants.back().first;
137 ResolveConstants.pop_back();
142 while (!Placeholder->use_empty()) {
143 auto UI = Placeholder->user_begin();
148 if (!isa<Constant>(U) || isa<GlobalValue>(U)) {
149 UI.getUse().set(RealVal);
155 Constant *UserC = cast<Constant>(U);
159 if (!isa<ConstantPlaceHolder>(*
I)) {
162 }
else if (*
I == Placeholder) {
167 ResolveConstantsTy::iterator It = std::lower_bound(
168 ResolveConstants.begin(), ResolveConstants.end(),
169 std::pair<Constant *, unsigned>(cast<Constant>(*I), 0));
170 assert(It != ResolveConstants.end() && It->first == *
I);
174 NewOps.push_back(cast<Constant>(NewOp));
179 if (
ConstantArray *UserCA = dyn_cast<ConstantArray>(UserC)) {
181 }
else if (
ConstantStruct *UserCS = dyn_cast<ConstantStruct>(UserC)) {
183 }
else if (isa<ConstantVector>(UserC)) {
186 assert(isa<ConstantExpr>(UserC) &&
"Must be a ConstantExpr.");
187 NewC = cast<ConstantExpr>(UserC)->getWithOperands(NewOps);
196 Placeholder->replaceAllUsesWith(RealVal);
LLVM Argument representation.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Value * getValueFwdRef(unsigned Idx, Type *Ty)
A Use represents the edge between a Value definition and its users.
static Constant * get(ArrayRef< Constant * > V)
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
A constant value that is initialized with an expression using other constant values.
Value handle that is nullable, but tries to track the Value.
void assignValue(Value *V, unsigned Idx)
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
Value * operator[](unsigned i) const
void resolveConstantForwardRefs()
Once all constants are read, this method bulk resolves any forward references.
static Constant * get(StructType *T, ArrayRef< Constant * > V)
#define DECLARE_TRANSPARENT_OPERAND_ACCESSORS(VALUECLASS)
Macro for generating in-class operand accessor declarations.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Constant * getConstantFwdRef(unsigned Idx, Type *Ty)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
ConstantArray - Constant Array Declarations.
static IntegerType * getInt32Ty(LLVMContext &C)
Compile-time customization of User operands.
void destroyConstant()
Called if some element of this constant is no longer valid.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...