22 return isa<ConstantExpr>(U) || isa<ConstantAggregate>(U);
28 if (
auto *CE = dyn_cast<ConstantExpr>(
C)) {
30 ConstInst->
insertBefore(*InsertPt->getParent(), InsertPt);
32 }
else if (isa<ConstantStruct>(
C) || isa<ConstantArray>(
C)) {
38 }
else if (isa<ConstantVector>(
C)) {
54 bool RemoveDeadConstants,
63 for (
User *U :
C->users())
65 Stack.push_back(cast<Constant>(U));
71 while (!Stack.empty()) {
76 for (
auto *Nested :
C->users())
78 Stack.push_back(cast<Constant>(Nested));
84 for (
User *U :
C->users())
85 if (
auto *
I = dyn_cast<Instruction>(U))
86 if (!RestrictToFunc ||
I->getFunction() == RestrictToFunc)
94 for (
Use &U :
I->operands()) {
96 if (
auto *Phi = dyn_cast<PHINode>(
I)) {
99 assert(BI != BB->
end() &&
"Unexpected empty basic block");
102 if (
auto *
C = dyn_cast<Constant>(U.get())) {
106 for (
auto *NI : NewInsts)
107 NI->setDebugLoc(Loc);
109 U.set(NewInsts.back());
115 if (RemoveDeadConstants)
117 C->removeDeadConstantUsers();
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements a set that has insertion order iteration characteristics.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
InstListType::iterator iterator
Instruction iterators...
This is an important base class in LLVM.
This class represents an Operation in the Expression.
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
InstructionWorklist - This is the worklist management logic for InstCombine and other simplification ...
void insertBefore(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified instruction.
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
A vector that has set insertion semantics.
bool insert(const value_type &X)
Insert a new element into the SetVector.
bool contains(const key_type &key) const
Check if the SetVector contains the given key.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
The instances of the Type class are immutable: once they are created, they are never changed.
static IntegerType * getInt32Ty(LLVMContext &C)
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
static SmallVector< Instruction *, 4 > expandUser(BasicBlock::iterator InsertPt, Constant *C)
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
static bool isExpandableUser(User *U)
bool convertUsersOfConstantsToInstructions(ArrayRef< Constant * > Consts, Function *RestrictToFunc=nullptr, bool RemoveDeadConstants=true, bool IncludeSelf=false)
Replace constant expressions users of the given constants with instructions.