26 (
F.isVarArg() &&
Args.size() >=
F.arg_size())) &&
27 "Expected enough arguments to call the function.");
28 BB = &
Func.getEntryBlock();
42void ExecutorBase::reportImmediateUBString(
StringRef Msg) {
60std::pair<MemoryObject *, uint64_t>
62 Align Alignment,
bool IsStore) {
70 <<
"Invalid memory access via a pointer with nullary provenance.";
74 if (MO->isInaccessible()) {
85 Address.toStringUnsigned(AddrStr, 16);
91 if (IsStore && MO->isConstant()) {
99 Address.toStringUnsigned(AddrStr, 16);
101 <<
", Required alignment: " << Alignment.value() <<
".";
105 if (AccessSize > MO->getSize() ||
Address.ult(MO->getAddress())) {
107 Address.toStringUnsigned(AddrStr, 16);
109 << AccessSize <<
", Address: 0x" << AddrStr
110 <<
", Object base: 0x"
112 <<
", Object size: " << MO->getSize() <<
".";
118 if (
Offset.ugt(MO->getSize() - AccessSize)) {
120 Address.toStringUnsigned(AddrStr, 16);
122 << AccessSize <<
", Address: 0x" << AddrStr
123 <<
", Object base: 0x"
125 <<
", Object size: " << MO->getSize() <<
".";
129 return {MO,
Offset.getZExtValue()};
140 PtrVal,
Ctx.getEffectiveTypeStoreSize(ValTy), Alignment,
143 bool ContainsUndefinedBits =
false;
145 NoUndef ? &ContainsUndefinedBits :
nullptr);
146 if (NoUndef && ContainsUndefinedBits)
161 PtrVal,
Ctx.getEffectiveTypeStoreSize(ValTy), Alignment,
170 assert((IID == Intrinsic::memcpy || IID == Intrinsic::memcpy_inline ||
171 IID == Intrinsic::memmove) &&
172 "Unexpected memory transfer intrinsic");
173 const bool IsMemMove = IID == Intrinsic::memmove;
174 const StringRef Name = IsMemMove ?
"memmove" :
"memcpy";
181 const std::optional<uint64_t> LenOpt =
Length.asInteger().tryZExtValue();
195 if (Src.isPoison()) {
201 const Pointer &SrcPtr = Src.asPointer();
204 auto [SrcMO, SrcOffset] =
209 auto [DstMO, DstOffset] =
214 if (!IsMemMove && SrcMO == DstMO) {
215 const uint64_t SrcEnd = SrcOffset + Len;
216 const uint64_t DstEnd = DstOffset + Len;
219 if (SrcOffset < DstEnd && DstOffset < SrcEnd &&
220 (IsLibCall || SrcOffset != DstOffset)) {
228 std::memmove(DstBytes.
data(), SrcBytes.
data(), Len *
sizeof(
Byte));
238 const std::optional<uint64_t> LenOpt =
Length.asInteger().tryZExtValue();
255 auto [DstMO, DstOffset] =
263 fill(DstMO->getBytes().slice(DstOffset, Len), FillByte);
287 errs() <<
"Stacktrace:\n";
291 StringRef ModuleFileName =
Ctx.getModule().getModuleIdentifier();
292 while (TheFrame !=
nullptr) {
295 errs() <<
"#" << Index++ <<
" " << Inst <<
" at ";
299 errs() <<
' ' << ModuleFileName <<
':' <<
Loc->Start.Line + 1;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Class for arbitrary precision integers.
uint64_t getZExtValue() const
Get zero extended value.
This class represents an incoming formal argument to a Function.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
Registry of file location information for LLVM IR constructs.
LLVM_ABI std::optional< FileLocRange > getInstructionOrArgumentLocation(const Value *) const
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
LLVM_ABI const Function * getFunction() const
Return the function this instruction belongs to.
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
MutableArrayRef< T > slice(size_t N, size_t M) const
Chop off the first N elements of the array, and keep M elements in the array.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Represent a constant reference to a string, i.e.
Implementation of the target library information.
static Twine utohexstr(uint64_t Val)
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM_ABI void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
static LLVM_ABI AnyValue getPoisonValue(Context &Ctx, Type *Ty)
const Pointer & asPointer() const
const APInt & asInteger() const
virtual void onError(StringRef Msg)
virtual void onImmediateUB(StringRef Msg)
unsigned getIntSize() const
DiagnosticReporter reportError()
std::pair< MemoryObject *, uint64_t > verifyMemAccess(const Pointer &Ptr, uint64_t AccessSize, Align Alignment, bool IsStore)
Check if the upcoming memory access is valid.
friend class DiagnosticReporter
void dumpStackTrace() const
void executeMemSet(const AnyValue &Dest, const AnyValue &Val, const AnyValue &Length)
Fill Length bytes at Dest with Val.
bool hasProgramExited() const
std::optional< ProgramExitInfo > ExitInfo
std::optional< ProgramExitInfo > getExitInfo() const
void requestProgramExit(ProgramExitInfo::ProgramExitKind Kind, uint64_t ExitCode=0)
DiagnosticReporter reportImmediateUB()
void store(const AnyValue &Ptr, Align Alignment, const AnyValue &Val, Type *ValTy)
void executeMemTransfer(const AnyValue &Dest, const AnyValue &Src, const AnyValue &Length, Intrinsic::ID IID, bool IsLibCall)
Copy Length bytes from Src to Dest according to the intrinsic IID.
AnyValue load(const AnyValue &Ptr, Align Alignment, Type *ValTy, bool NoUndef)
const APInt & address() const
Components of a pointer excluding address.
void fill(R &&Range, T &&Value)
Provide wrappers to std::fill which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
unsigned Log2(Align A)
Returns the log2 of the alignment.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Representation of a byte in memory.
static Byte concrete(uint8_t Val)
Context for a function call.
Frame(Function &F, CallBase *CallSite, Frame *LastFrame, ArrayRef< AnyValue > Args, AnyValue &RetVal, const TargetLibraryInfoImpl &TLIImpl)
ArrayRef< AnyValue > Args
DenseMap< Value *, AnyValue > ValueMap