Go to the documentation of this file.
37 dyn_cast<GetElementPtrInst>(GV.
use_begin()->getUser());
38 if (!
GEP || !
GEP->hasOneUse() ||
44 Load->getType() !=
GEP->getResultElementType())
61 if (!Array || !Array->getType()->getElementType()->isPointerTy())
65 for (
const Use &
Op : Array->operands()) {
76 auto *GlovalVarOp = dyn_cast<GlobalVariable>(GVOp);
77 if (!GlovalVarOp || !GlovalVarOp->isConstant())
80 if (!GlovalVarOp->hasLocalLinkage() ||
81 !GlovalVarOp->isDSOLocal() ||
82 !GlovalVarOp->isImplicitDSOLocal())
100 nullptr,
"reltable." + Func.getName(), &LookupTable,
108 Constant *Element = cast<Constant>(Operand);
109 Type *IntPtrTy =
M.getDataLayout().getIntPtrType(
M.getContext());
115 RelLookupTableContents[Idx++] = RelOffset;
123 return RelLookupTable;
128 cast<GetElementPtrInst>(LookupTable.
use_begin()->getUser());
142 IntegerType *IntTy = cast<IntegerType>(Index->getType());
151 &
M, Intrinsic::load_relative, {Index->getType()});
157 "reltable.intrinsic");
161 Result =
Builder.CreateBitCast(Result,
Load->getType(),
"reltable.bitcast");
164 Load->replaceAllUsesWith(Result);
166 Load->eraseFromParent();
167 GEP->eraseFromParent();
174 if (
F.isDeclaration())
178 if (!GetTTI(
F).shouldBuildRelLookupTables())
185 bool Changed =
false;
194 GV.eraseFromParent();
A set of analyses that are preserved following a run of a transformation pass.
Analysis pass providing the TargetTransformInfo.
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
A parsed version of the target data layout string in and methods for querying it.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
bool hasOneUse() const
Return true if there is exactly one use of this value.
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
LinkageTypes getLinkage() const
bool isImplicitDSOLocal() const
static bool convertToRelativeLookupTables(Module &M, function_ref< TargetTransformInfo &(Function &)> GetTTI)
Target - Wrapper for Target specific information.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
bool isExternallyInitialized() const
FunctionAnalysisManager FAM
static void convertToRelLookupTable(GlobalVariable &LookupTable)
The instances of the Type class are immutable: once they are created, they are never changed.
void setUnnamedAddr(UnnamedAddr Val)
Class to represent array types.
static IntegerType * getInt32Ty(LLVMContext &C)
bool hasInitializer() const
Definitions have initializers, declarations don't.
LLVM Basic Block Representation.
bool IsConstantOffsetFromGlobal(Constant *C, GlobalValue *&GV, APInt &Offset, const DataLayout &DL, DSOLocalEquivalent **DSOEquiv=nullptr)
If this constant is a constant offset from a global, return the global and the constant.
static Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
uint64_t getNumElements() const
ThreadLocalMode getThreadLocalMode() const
static bool shouldConvertToRelLookupTable(Module &M, GlobalVariable &GV)
static Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Class to represent integer types.
ConstantArray - Constant Array Declarations.
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
This struct is a compact representation of a valid (non-zero power of two) alignment.
An efficient, type-erasing, non-owning reference to a callable.
ArrayType * getType() const
Specialize the getType() method to always return an ArrayType, which reduces the amount of casting ne...
static Constant * getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced=false)
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
This is an important base class in LLVM.
Module * getParent()
Get the module that this global value is contained inside of...
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
bool hasLocalLinkage() const
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
A Module instance is used to store all the information related to an LLVM module.
Class for arbitrary precision integers.
Represents analyses that only rely on functions' control flow.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
An instruction for reading from memory.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
unsigned getAddressSpace() const
void preserveSet()
Mark an analysis set as preserved.
static GlobalVariable * createRelLookupTable(Function &Func, GlobalVariable &LookupTable)
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
A container for analyses that lazily runs them and caches their results.
Type * getValueType() const
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
void setAlignment(MaybeAlign Align)
LLVM Value Representation.
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
A Use represents the edge between a Value definition and its users.