Represent a constant reference to an array (0 or more elements consecutively in memory), i.e. a start pointer and a length. It allows various APIs to take consecutive elements easily and conveniently.

Synopsis

Declared in <llvm/ADT/ArrayRef.h>

template<typename T>
class [[nodiscard]] ArrayRef;

Description

This class does not own the underlying data, it is expected to be used in situations where the data resides in some other buffer, whose lifetime extends past that of the ArrayRef. For this reason, it is not in general safe to store an ArrayRef.

This is intended to be trivially copyable, so it should be passed by value.

Type Aliases

Name

Description

const_iterator

Const iterator over the referenced array elements.

const_pointer

Pointer to a const element.

const_reference

Const reference to an element.

const_reverse_iterator

Const reverse iterator over the referenced array elements.

difference_type

Signed type used to express distances between iterators.

iterator

Iterator over the referenced array elements.

pointer

Mutable pointer to an element.

reference

Mutable reference to an element.

reverse_iterator

Reverse iterator over the referenced array elements.

size_type

Unsigned type used to express the size of the array.

value_type

Element type stored in the referenced array.

Member Functions

Name

Description

ArrayRef [constructor]

Constructors

operator=

Disallow accidental assignment from a temporary.

back

Get the last element.

begin

Return an iterator to the first element.

consume_back

consume_back() ‐ Returns the last element and drops it from ArrayRef.

consume_front

consume_front() ‐ Returns the first element and drops it from ArrayRef.

copy

Allocate a mutable copy in A and return a reference to it.

data

Return a pointer to the first element of the array.

drop_back

Drop the last N elements of the array.

drop_front

Drop the first N elements of the array.

drop_until

Return a copy of *this with the first N elements not satisfying the given predicate removed.

drop_while

Return a copy of *this with the first N elements satisfying the given predicate removed.

empty

Check if the array is empty.

end

Return an iterator past the last element.

equals

Check for element‐wise equality.

front

Get the first element.

operator[]

@}

rbegin

Return a reverse iterator to the last element.

rend

Return a reverse iterator to the element before the first element.

size

Get the array size.

slice

slice overloads

take_back

Return a copy of *this with only the last N elements.

take_front

Return a copy of *this with only the first N elements.

take_until

Return the first N elements of this Array that don't satisfy the given predicate.

take_while

Return the first N elements of this Array that satisfy the given predicate.

vec

@}

operator std::vector<T>

@}

Specializations

Name

Description

ArrayRef<unsigned char>

Represent a constant reference to an array (0 or more elements consecutively in memory), i.e. a start pointer and a length. It allows various APIs to take consecutive elements easily and conveniently.

ArrayRef<unsigned long>

Represent a constant reference to an array (0 or more elements consecutively in memory), i.e. a start pointer and a length. It allows various APIs to take consecutive elements easily and conveniently.

ArrayRef<FuncDescEntry<llvm::endianness::big>>

Represent a constant reference to an array (0 or more elements consecutively in memory), i.e. a start pointer and a length. It allows various APIs to take consecutive elements easily and conveniently.

ArrayRef<FuncDescEntry<llvm::endianness::little>>

Represent a constant reference to an array (0 or more elements consecutively in memory), i.e. a start pointer and a length. It allows various APIs to take consecutive elements easily and conveniently.

ArrayRef<BasicBlock*>

ArrayRef<MachineBasicBlock*>

ArrayRef<MachineMemOperand*>

ArrayRef<IntrinsicInst const*>

Deduction Guides

Name

Description

ArrayRef<T>

Deduction guide to construct an ArrayRef from an ArrayRef

ArrayRef<T>

@{ Deduction guide to construct an ArrayRef from a single element.

ArrayRef<T>

Deduction guide to construct an ArrayRef from an ArrayRef (const)

ArrayRef<T>

Deduction guide to construct an ArrayRef from a SmallVector

ArrayRef<T>

Deduction guide to construct an ArrayRef from a std::vector

ArrayRef<T>

Deduction guide to construct an ArrayRef from a SmallVector

ArrayRef<T>

Deduction guide to construct an ArrayRef from a std::array

ArrayRef<T>

Deduction guide to construct an ArrayRef from a C array.

ArrayRef<T>

Deduction guide to construct an ArrayRef from a pointer and length

ArrayRef<T>

Deduction guide to construct an ArrayRef from a range

Non-Member Functions

Name

Description

ComputeEditDistance

Determine the edit distance between two sequences.

ComputeMappedEditDistance

Determine the edit distance between two sequences.

ConvertCostTableLookup

Find in type conversion cost table.

CostTableLookup

Find in cost table.

DeleteDeadBlocks

Delete the specified blocks from BB. The set of deleted blocks must have no predecessors that are not being deleted themselves. BBs must have no duplicating blocks. If there are loops among this set of blocks, all relevant loop info updates should be done before this function is called. If KeepOneInputPHIs is true, one‐input Phis in successors of blocks being deleted will be preserved.

PromoteMemToReg

Promote the specified list of alloca instructions into scalar registers, inserting PHI nodes as appropriate.

arrayRefFromStringRef

Construct an array ref of bytes from a string ref.

canConvertToMinOrMaxIntrinsic

Check if the values in VL are select instructions that can be converted to a min or max (vector) intrinsic. Returns the intrinsic ID, if such a conversion is possible, together with a bool indicating whether all select conditions are only used by the selects. Otherwise return Intrinsic::not_intrinsic.

cloneAndAdaptNoAliasScopes

Clone the specified noalias decl scopes. Then adapt all instructions in the [IStart, IEnd]included !) range to the cloned versions. 'Ext' will be added to the duplicate scope names.

cloneAndAdaptNoAliasScopes

Clone the specified noalias decl scopes. Then adapt all instructions in the NewBlocks basicblocks to the cloned versions. 'Ext' will be added to the duplicate scope names.

cloneNoAliasScopes

Duplicate the specified list of noalias decl scopes. The 'Ext' string is added as an extension to the name. Afterwards, the ClonedScopes contains the mapping of the original scope MDNode onto the cloned scope. Be aware that the cloned scopes are still part of the original scope domain.

collectGlobalObjectNameStrings

Given a vector of strings (names of global objects like functions or, virtual tables) NameStrs, the method generates a combined string Result that is ready to be serialized. The Result string is comprised of three fields: The first field is the length of the uncompressed strings, and the the second field is the length of the zlib‐compressed string. Both fields are encoded in ULEB128. If doCompress is false, the third field is the uncompressed strings; otherwise it is the compressed string. When the string compression is off, the second field will have value zero.

collectPGOFuncNameStrings

Produce Result string with the same format described above. The input is vector of PGO function name variables that are referenced. The global variable element in 'NameVars' is a string containing the pgo name of a function. See createPGOFuncNameVar that creates these global variables.

computeMinimumValueSizes

Compute a map of integer instructions to their minimum legal type size.

convertUTF16ToUTF8String

Converts a UTF16 string into a UTF8 std::string.

convertUTF16ToUTF8String

Converts a stream of raw bytes assumed to be UTF16 into a UTF8 std::string.

convertUTF32ToUTF8String

Converts a stream of raw bytes assumed to be UTF32 into a UTF8 std::string.

convertUTF32ToUTF8String

Converts a UTF32 string into a UTF8 std::string.

convertUsersOfConstantsToInstructions

Replace constant expressions users of the given constants with instructions. Return whether anything was changed.

createMacroFusionDAGMutation

Create a DAG scheduling mutation to pair instructions back to back for instructions that benefit according to the target‐specific predicate functions. shouldScheduleAdjacent will be true if any of the provided predicates are true. If BranchOnly is true, only branch instructions with one of their predecessors will be fused.

createPHIsForSplitLoopExit

When a loop exit edge is split, LCSSA form may require new PHIs in the new exit block. This function inserts the new PHIs, as needed. Preds is a list of preds inside the loop, SplitBB is the new loop exit block, and DestBB is the old loop exit, now the successor of SplitBB.

createUnaryMask

Given a shuffle mask for a binary shuffle, create the equivalent shuffle mask assuming both operands are identical. This assumes that the unary shuffle will use elements from operand 0 (operand 1 will be unused).

detachDeadBlocks

Replace contents of every block in BBs with single unreachable instruction. If Updates is specified, collect all necessary DT updates into this vector. If KeepOneInputPHIs is true, one‐input Phis in successors of blocks being deleted will be preserved.

downscaleWeights

downscale the given weights preserving the ratio. If the maximum value is not already known and not provided via

dumpBytes

Convert `Bytes' to a hex string and output to `OS'

fitWeights

Push the weights right to fit in uint32_t.

format_bytes

Format Bytes as a hex dump without an ASCII column.

format_bytes_with_ascii

Format Bytes as hex with an ASCII column.

fullyRecomputeLiveIns

Convenience function for recomputing live‐in's for a set of MBBs until the computation converges.

getContainedTypes

Returns the types contained in Ty. For struct types, it returns the elements, all other types are returned directly.

getShuffleMaskWithWidestElts

Repetitively apply widenShuffleMaskElts() for as long as it succeeds, to get the shuffle mask with widest possible elements.

getSipHash_2_4_128

Computes a SipHash‐2‐4 128‐bit result.

getSipHash_2_4_64

Computes a SipHash‐2‐4 64‐bit result.

getSplatIndex

If all non‐negative Mask elements are the same value, return that value. If all elements are negative (undefined) or Mask contains different non‐negative values, return ‐1.

hasUTF16ByteOrderMark

Returns true if a blob of text starts with a UTF‐16 big or little endian byte order mark.

hash_value

@}

identifyNoAliasScopesToClone

Find the 'llvm.experimental.noalias.scope.decl' intrinsics in the specified basic blocks and extract their scope. These are candidates for duplication when cloning.

isMaskedSlidePair

Does this shuffle mask represent either one slide shuffle or a pair of two slide shuffles, combined with a select on some constant vector mask? A slide is a shuffle mask which shifts some set of elements up or down the vector, with all other elements being undefined. An identity shuffle will be matched a slide by 0. The output parameter provides the source (‐1 means no source), and slide direction for each slide.

operator!=

Return true if LHS and RHS differ in length or element values.

operator<

Lexicographically compare two `ArrayRef`s.

operator<=

Return true if LHS is lexicographically less than or equal to RHS.

operator==

Return true if LHS and RHS contain equal elements.

operator>

Lexicographically compare two `ArrayRef`s.

operator>=

Return true if LHS is lexicographically greater than or equal to RHS.

processShuffleMasks

Splits and processes shuffle mask depending on the number of input and output registers. The function does 2 main things: 1) splits the source/destination vectors into real registers; 2) do the mask analysis to identify which real registers are permuted. Then the function processes resulting registers mask using provided action items. If no input register is defined, NoInputAction action is used. If only 1 input register is used, SingleInputAction is used, otherwise ManyInputsAction is used to process > 2 input registers and masks.

remapInstructionsInBlocks

Remaps instructions in Blocks using the mapping in VMap.

sortPtrAccesses

Attempt to sort the pointers in VL and return the sorted indices in SortedIndices, if reordering is required.

stable_hash_combine

Combine the hashes in Buffer into a single stable hash.

toHex

Convert buffer Input to its hexadecimal representation. The returned string is double the size of Input.

toHex

Convert the bytes in Input to a hexadecimal string.

toStringRef

Construct a string ref from an array ref of unsigned chars.

toStringRef

Construct a string ref from an array ref of chars.

widenShuffleMaskElts

A variant of the previous method which is specialized for Scale=2, and treats ‐1 as undef and allows widening when a wider element is partially undef in the narrow form of the mask. This transformation discards information about which bytes in the original shuffle were undef.

xxh3_128bits

Compute the XXH3 128‐bit hash of the bytes in data.

xxh3_64bits

Inline ArrayRef overloads of the xxhash entry points declared out‐of‐line in llvm/Support/xxhash.h. They live here so xxhash.h can stay free of ADT dependencies.

BBAddrMapYAML::encodePayload

Encodes the BBAddrMap payload into CBA. AddressSize must be 4 or 8. If non‐null, PGOAnalyses must have the same length as Entries.

IntegerInclusiveIntervalUtils::contains

Check if a value is contained in any of the intervals.

IntegerInclusiveIntervalUtils::mergeAdjacentIntervals

Merge adjacent/consecutive intervals into single intervals. Example: [1‐3, 4‐6, 8‐10]‐> [1‐6, 8‐10].

Intrinsic::getIntrinsicInfoTableEntries

Fill the IIT table descriptor for the intrinsic id into an array of IITDescriptors. Returns a tuple of 3 values: ‐ ArrayRef for the descriptor table (for convenience). ‐ Number of arguments. ‐ if it's a variable argument intrinsic.

Win64EH::decodeUnwindInfoV3

Parse a V3 UNWIND_INFO from raw bytes. Returns an error on malformed data.

Win64EH::decodeWOD

Decode one WOD from the pool at the given byte offset. Returns an error on malformed data.

cgdata::mergeCodeGenData

Merge the codegen data from the scratch objects ObjectFiles from the first codegen round.

cl::HideUnrelatedOptions

Mark all options not part of the categories as cl::ReallyHidden.

cl::getCompilerBuildConfig

An array of optional enabled settings in the LLVM build configuration, which may be of interest to compiler developers. For example, includes "+assertions" if assertions are enabled. Used by printBuildConfig.

codelayout::calcExtTspScore

Estimate the "quality" of a given node order in CFG. The higher the score, the better the order is. The score is designed to reflect the locality of the given order, which is anti‐correlated with the number of I‐cache misses in a typical execution of the function.

codelayout::calcExtTspScore

Estimate the "quality" of the current node order in CFG.

codelayout::computeCacheDirectedLayout

Apply a Cache‐Directed Sort for functions represented by a call graph. The placement is done by optimizing the call locality by co‐locating frequently executed functions. FuncSizes The sizes of the nodes (in bytes). FuncCounts The execution counts of the nodes in the profile. CallCounts The execution counts of every edge (jump) in the profile. The map also defines the edges in CFG and should include 0‐count edges. CallOffsets The offsets of the calls from their source nodes.

codelayout::computeExtTspLayout

Find a layout of nodes (basic blocks) of a given CFG optimizing jump locality and thus processor I‐cache utilization. This is achieved via increasing the number of fall‐through jumps and co‐locating frequently executed nodes together. The nodes are assumed to be indexed by integers from [0, |V|) so that the] current order is the identity permutation. NodeSizes The sizes of the nodes (in bytes). NodeCounts The execution counts of the nodes in the profile. EdgeCounts The execution counts of every edge (jump) in the profile. The map also defines the edges in CFG and should include 0‐count edges.

codeview::getBytesAsCharacters

Reinterpret a byte array as an array of characters. Does not interpret as a C string, as StringRef has several helpers (split) that make that easy.

dwarf::toBlock

Take an optional DWARFFormValue and try to extract block data.

irsymtab::build

Fills in Symtab and StrtabBuilder with a valid symbol and string table for Mods.

lto::generateModulesOrdering

Produces a container ordering for optimal multi‐threaded processing. Returns ordered indices to elements in the input array.

memprof::buildCallstackMetadata

Build callstack metadata from the provided list of call stack ids. Returns the resulting metadata node.

memprof::computeFullStackId

Helper to generate a single hash id for a given callstack, used for emitting matching statistics and useful for uniquing such statistics across modules. Also used to dedup contexts when computing the summary.

orc::makeJITDylibSearchOrder

Convenience function for creating a search order from an ArrayRef of JITDylib*, all with the same flags.

offloading::sycl::writeSymbolTable

Serialize Names into Out.

orc::shared::runDeallocActions

Run deallocation actions. Dealloc actions will be run in reverse order (from last element of DAs to first).

Derived Classes

Name

Description

MutableArrayRef

Represent a mutable reference to an array (0 or more elements consecutively in memory), i.e. a start pointer and a length. It allows various APIs to take and modify consecutive elements easily and conveniently.

Return Value

Note

The return value should not be discarded.

Created with MrDocs