LLVM: lib/Transforms/Scalar/LowerConstantIntrinsics.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
34#include
35
36using namespace llvm;
38
39#define DEBUG_TYPE "lower-is-constant-intrinsic"
40
42 "Number of 'is.constant' intrinsic calls handled");
44 "Number of 'objectsize' intrinsic calls handled");
45
48 if (C->isManifestConstant())
51}
52
56 bool HasDeadBlocks = false;
59 &UnsimplifiedUsers);
60
61
62
64 UnsimplifiedUsers.end());
65
66 for (auto &VH : Worklist) {
68 if (!BI)
69 continue;
71 continue;
72
80 } else {
83 }
86 Other->removePredecessor(Source);
87
91
92 if (DTU)
95 HasDeadBlocks = true;
96 }
97 }
98 return HasDeadBlocks;
99}
100
103 std::optional DTU;
104 if (DT)
105 DTU.emplace(DT, DomTreeUpdater::UpdateStrategy::Lazy);
106
107 bool HasDeadBlocks = false;
108 const auto &DL = F.getDataLayout();
110
115 if ()
116 continue;
117 switch (II->getIntrinsicID()) {
118 default:
119 break;
120 case Intrinsic::is_constant:
121 case Intrinsic::objectsize:
123 break;
124 }
125 }
126 }
128
129
130
131 if (!VH)
132 continue;
134 if ()
135 continue;
137 switch (II->getIntrinsicID()) {
138 default:
139 continue;
140 case Intrinsic::is_constant:
142 LLVM_DEBUG(dbgs() << "Folding " << *II << " to " << *NewValue << "\n");
143 IsConstantIntrinsicsHandled++;
144 break;
145 case Intrinsic::objectsize:
147 LLVM_DEBUG(dbgs() << "Folding " << *II << " to " << *NewValue << "\n");
148 ObjectSizeIntrinsicsHandled++;
149 break;
150 }
152 II, NewValue, DTU ? &*DTU : nullptr);
153 }
154 if (HasDeadBlocks)
156 return !Worklist.empty();
157}
158
165 return PA;
166 }
167
169}
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This is the interface for a simple mod/ref and alias analysis over globals.
static bool replaceConditionalBranchesOnConstant(Instruction *II, Value *NewValue, DomTreeUpdater *DTU)
Definition LowerConstantIntrinsics.cpp:53
static Value * lowerIsConstantIntrinsic(IntrinsicInst *II)
Definition LowerConstantIntrinsics.cpp:46
The header file for the LowerConstantIntrinsics pass as used by the new pass manager.
uint64_t IntrinsicInst * II
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
This file implements a set that has insertion order iteration characteristics.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
PassT::Result * getCachedResult(IRUnitT &IR) const
Get the cached result of an analysis pass for a given IR unit.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
LLVM Basic Block Representation.
Conditional or Unconditional Branch instruction.
static BranchInst * Create(BasicBlock *IfTrue, InsertPosition InsertBefore=nullptr)
BasicBlock * getSuccessor(unsigned i) const
bool isUnconditional() const
static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)
static LLVM_ABI ConstantInt * getFalse(LLVMContext &Context)
Analysis pass which computes a DominatorTree.
static constexpr UpdateKind Delete
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
void applyUpdates(ArrayRef< UpdateT > Updates)
Submit updates to all available trees.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
A wrapper class for inspecting calls to intrinsic functions.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserve()
Mark an analysis as preserved.
iterator end()
Get an iterator to the end of the SetVector.
iterator begin()
Get an iterator to the beginning of the SetVector.
A SetVector that performs no allocations if smaller than a certain size.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Analysis pass providing the TargetLibraryInfo.
Provides information about what library functions are available for the current target.
Target - Wrapper for Target specific information.
Value * getOperand(unsigned i) const
LLVM Value Representation.
Value handle that is nullable, but tries to track the Value.
const ParentTy * getParent() const
@ C
The default llvm calling convention, compatible with C.
bool match(Val *V, const Pattern &P)
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
is_zero m_Zero()
Match any null constant or a vector with all elements equal to 0.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
bool lowerConstantIntrinsics(Function &F, const TargetLibraryInfo &TLI, DominatorTree *DT)
Definition LowerConstantIntrinsics.cpp:101
LLVM_ABI Value * lowerObjectSizeCall(IntrinsicInst *ObjectSize, const DataLayout &DL, const TargetLibraryInfo *TLI, bool MustSucceed)
Try to turn a call to @llvm.objectsize into an integer value of the given Type.
auto dyn_cast_or_null(const Y &Val)
LLVM_ABI bool replaceAndRecursivelySimplify(Instruction *I, Value *SimpleV, const TargetLibraryInfo *TLI=nullptr, const DominatorTree *DT=nullptr, AssumptionCache *AC=nullptr, SmallSetVector< Instruction *, 8 > *UnsimplifiedUsers=nullptr)
Replace all uses of 'I' with 'SimpleV' and simplify the uses recursively.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool pred_empty(const BasicBlock *BB)
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
LLVM_ABI bool removeUnreachableBlocks(Function &F, DomTreeUpdater *DTU=nullptr, MemorySSAUpdater *MSSAU=nullptr)
Remove all blocks that can not be reached from the function's entry.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &)
Run the pass over the function.
Definition LowerConstantIntrinsics.cpp:160