17 std::unique_ptr<Value> Erased;
20 auto *Val = It->second.release();
21 Erased = std::unique_ptr<Value>(Val);
28 assert(V->getSubclassID() != Value::ClassID::Constant &&
29 "Can't detach a constant!");
30 assert(V->getSubclassID() != Value::ClassID::User &&
"Can't detach a user!");
35 assert(VPtr->getSubclassID() != Value::ClassID::User &&
36 "Can't register a user!");
38 Value *V = VPtr.get();
39 [[maybe_unused]]
auto Pair =
41 assert(Pair.second &&
"Already exists!");
47 if (
auto *
I = dyn_cast<Instruction>(V)) {
59 return It->second.get();
61 if (
auto *
C = dyn_cast<llvm::Constant>(LLVMV)) {
62 switch (
C->getValueID()) {
63 case llvm::Value::ConstantIntVal:
64 It->second = std::unique_ptr<ConstantInt>(
66 return It->second.get();
67 case llvm::Value::ConstantFPVal:
68 It->second = std::unique_ptr<ConstantFP>(
70 return It->second.get();
71 case llvm::Value::BlockAddressVal:
72 It->second = std::unique_ptr<BlockAddress>(
74 return It->second.get();
75 case llvm::Value::ConstantTokenNoneVal:
76 It->second = std::unique_ptr<ConstantTokenNone>(
78 return It->second.get();
79 case llvm::Value::ConstantAggregateZeroVal: {
80 auto *CAZ = cast<llvm::ConstantAggregateZero>(
C);
81 It->second = std::unique_ptr<ConstantAggregateZero>(
83 auto *Ret = It->second.get();
85 auto EC = CAZ->getElementCount();
87 for (
auto ElmIdx : seq<unsigned>(0, EC.getFixedValue()))
92 case llvm::Value::ConstantPointerNullVal:
93 It->second = std::unique_ptr<ConstantPointerNull>(
95 return It->second.get();
96 case llvm::Value::PoisonValueVal:
97 It->second = std::unique_ptr<PoisonValue>(
99 return It->second.get();
100 case llvm::Value::UndefValueVal:
101 It->second = std::unique_ptr<UndefValue>(
103 return It->second.get();
104 case llvm::Value::DSOLocalEquivalentVal: {
105 auto *DSOLE = cast<llvm::DSOLocalEquivalent>(
C);
106 It->second = std::unique_ptr<DSOLocalEquivalent>(
108 auto *Ret = It->second.get();
112 case llvm::Value::ConstantArrayVal:
113 It->second = std::unique_ptr<ConstantArray>(
116 case llvm::Value::ConstantStructVal:
117 It->second = std::unique_ptr<ConstantStruct>(
120 case llvm::Value::ConstantVectorVal:
121 It->second = std::unique_ptr<ConstantVector>(
124 case llvm::Value::FunctionVal:
125 It->second = std::unique_ptr<Function>(
126 new Function(cast<llvm::Function>(
C), *
this));
128 case llvm::Value::GlobalIFuncVal:
129 It->second = std::unique_ptr<GlobalIFunc>(
132 case llvm::Value::GlobalVariableVal:
133 It->second = std::unique_ptr<GlobalVariable>(
136 case llvm::Value::GlobalAliasVal:
137 It->second = std::unique_ptr<GlobalAlias>(
140 case llvm::Value::NoCFIValueVal:
141 It->second = std::unique_ptr<NoCFIValue>(
144 case llvm::Value::ConstantPtrAuthVal:
145 It->second = std::unique_ptr<ConstantPtrAuth>(
148 case llvm::Value::ConstantExprVal:
149 It->second = std::unique_ptr<ConstantExpr>(
153 It->second = std::unique_ptr<Constant>(
new Constant(
C, *
this));
156 auto *NewC = It->second.get();
161 if (
auto *Arg = dyn_cast<llvm::Argument>(LLVMV)) {
162 It->second = std::unique_ptr<Argument>(
new Argument(Arg, *
this));
163 return It->second.get();
165 if (
auto *BB = dyn_cast<llvm::BasicBlock>(LLVMV)) {
166 assert(isa<llvm::BlockAddress>(U) &&
167 "This won't create a SBBB, don't call this function directly!");
172 assert(isa<llvm::Instruction>(LLVMV) &&
"Expected Instruction");
174 switch (cast<llvm::Instruction>(LLVMV)->
getOpcode()) {
175 case llvm::Instruction::VAArg: {
176 auto *
LLVMVAArg = cast<llvm::VAArgInst>(LLVMV);
178 return It->second.get();
180 case llvm::Instruction::Freeze: {
181 auto *
LLVMFreeze = cast<llvm::FreezeInst>(LLVMV);
183 return It->second.get();
185 case llvm::Instruction::Fence: {
186 auto *
LLVMFence = cast<llvm::FenceInst>(LLVMV);
188 return It->second.get();
190 case llvm::Instruction::Select: {
191 auto *LLVMSel = cast<llvm::SelectInst>(LLVMV);
192 It->second = std::unique_ptr<SelectInst>(
new SelectInst(LLVMSel, *
this));
193 return It->second.get();
195 case llvm::Instruction::ExtractElement: {
196 auto *LLVMIns = cast<llvm::ExtractElementInst>(LLVMV);
197 It->second = std::unique_ptr<ExtractElementInst>(
199 return It->second.get();
201 case llvm::Instruction::InsertElement: {
202 auto *LLVMIns = cast<llvm::InsertElementInst>(LLVMV);
203 It->second = std::unique_ptr<InsertElementInst>(
205 return It->second.get();
207 case llvm::Instruction::ShuffleVector: {
208 auto *LLVMIns = cast<llvm::ShuffleVectorInst>(LLVMV);
209 It->second = std::unique_ptr<ShuffleVectorInst>(
211 return It->second.get();
213 case llvm::Instruction::ExtractValue: {
214 auto *LLVMIns = cast<llvm::ExtractValueInst>(LLVMV);
217 return It->second.get();
219 case llvm::Instruction::InsertValue: {
220 auto *LLVMIns = cast<llvm::InsertValueInst>(LLVMV);
223 return It->second.get();
225 case llvm::Instruction::Br: {
226 auto *
LLVMBr = cast<llvm::BranchInst>(LLVMV);
228 return It->second.get();
230 case llvm::Instruction::Load: {
231 auto *LLVMLd = cast<llvm::LoadInst>(LLVMV);
232 It->second = std::unique_ptr<LoadInst>(
new LoadInst(LLVMLd, *
this));
233 return It->second.get();
235 case llvm::Instruction::Store: {
236 auto *LLVMSt = cast<llvm::StoreInst>(LLVMV);
237 It->second = std::unique_ptr<StoreInst>(
new StoreInst(LLVMSt, *
this));
238 return It->second.get();
240 case llvm::Instruction::Ret: {
241 auto *
LLVMRet = cast<llvm::ReturnInst>(LLVMV);
243 return It->second.get();
245 case llvm::Instruction::Call: {
246 auto *
LLVMCall = cast<llvm::CallInst>(LLVMV);
248 return It->second.get();
250 case llvm::Instruction::Invoke: {
251 auto *
LLVMInvoke = cast<llvm::InvokeInst>(LLVMV);
253 return It->second.get();
255 case llvm::Instruction::CallBr: {
256 auto *
LLVMCallBr = cast<llvm::CallBrInst>(LLVMV);
258 return It->second.get();
260 case llvm::Instruction::LandingPad: {
261 auto *LLVMLPad = cast<llvm::LandingPadInst>(LLVMV);
263 std::unique_ptr<LandingPadInst>(
new LandingPadInst(LLVMLPad, *
this));
264 return It->second.get();
266 case llvm::Instruction::CatchPad: {
267 auto *LLVMCPI = cast<llvm::CatchPadInst>(LLVMV);
269 std::unique_ptr<CatchPadInst>(
new CatchPadInst(LLVMCPI, *
this));
270 return It->second.get();
272 case llvm::Instruction::CleanupPad: {
273 auto *LLVMCPI = cast<llvm::CleanupPadInst>(LLVMV);
275 std::unique_ptr<CleanupPadInst>(
new CleanupPadInst(LLVMCPI, *
this));
276 return It->second.get();
278 case llvm::Instruction::CatchRet: {
279 auto *LLVMCRI = cast<llvm::CatchReturnInst>(LLVMV);
282 return It->second.get();
284 case llvm::Instruction::CleanupRet: {
285 auto *LLVMCRI = cast<llvm::CleanupReturnInst>(LLVMV);
286 It->second = std::unique_ptr<CleanupReturnInst>(
288 return It->second.get();
290 case llvm::Instruction::GetElementPtr: {
291 auto *LLVMGEP = cast<llvm::GetElementPtrInst>(LLVMV);
292 It->second = std::unique_ptr<GetElementPtrInst>(
294 return It->second.get();
296 case llvm::Instruction::CatchSwitch: {
297 auto *LLVMCatchSwitchInst = cast<llvm::CatchSwitchInst>(LLVMV);
298 It->second = std::unique_ptr<CatchSwitchInst>(
300 return It->second.get();
302 case llvm::Instruction::Resume: {
303 auto *LLVMResumeInst = cast<llvm::ResumeInst>(LLVMV);
305 std::unique_ptr<ResumeInst>(
new ResumeInst(LLVMResumeInst, *
this));
306 return It->second.get();
308 case llvm::Instruction::Switch: {
309 auto *LLVMSwitchInst = cast<llvm::SwitchInst>(LLVMV);
311 std::unique_ptr<SwitchInst>(
new SwitchInst(LLVMSwitchInst, *
this));
312 return It->second.get();
314 case llvm::Instruction::FNeg: {
315 auto *LLVMUnaryOperator = cast<llvm::UnaryOperator>(LLVMV);
316 It->second = std::unique_ptr<UnaryOperator>(
318 return It->second.get();
320 case llvm::Instruction::Add:
321 case llvm::Instruction::FAdd:
322 case llvm::Instruction::Sub:
323 case llvm::Instruction::FSub:
324 case llvm::Instruction::Mul:
325 case llvm::Instruction::FMul:
326 case llvm::Instruction::UDiv:
327 case llvm::Instruction::SDiv:
328 case llvm::Instruction::FDiv:
329 case llvm::Instruction::URem:
330 case llvm::Instruction::SRem:
331 case llvm::Instruction::FRem:
332 case llvm::Instruction::Shl:
333 case llvm::Instruction::LShr:
334 case llvm::Instruction::AShr:
335 case llvm::Instruction::And:
336 case llvm::Instruction::Or:
337 case llvm::Instruction::Xor: {
338 auto *LLVMBinaryOperator = cast<llvm::BinaryOperator>(LLVMV);
339 It->second = std::unique_ptr<BinaryOperator>(
341 return It->second.get();
343 case llvm::Instruction::AtomicRMW: {
347 return It->second.get();
349 case llvm::Instruction::AtomicCmpXchg: {
351 It->second = std::unique_ptr<AtomicCmpXchgInst>(
353 return It->second.get();
355 case llvm::Instruction::Alloca: {
356 auto *
LLVMAlloca = cast<llvm::AllocaInst>(LLVMV);
358 return It->second.get();
360 case llvm::Instruction::ZExt:
361 case llvm::Instruction::SExt:
362 case llvm::Instruction::FPToUI:
363 case llvm::Instruction::FPToSI:
364 case llvm::Instruction::FPExt:
365 case llvm::Instruction::PtrToInt:
366 case llvm::Instruction::IntToPtr:
367 case llvm::Instruction::SIToFP:
368 case llvm::Instruction::UIToFP:
369 case llvm::Instruction::Trunc:
370 case llvm::Instruction::FPTrunc:
371 case llvm::Instruction::BitCast:
372 case llvm::Instruction::AddrSpaceCast: {
373 auto *LLVMCast = cast<llvm::CastInst>(LLVMV);
374 It->second = std::unique_ptr<CastInst>(
new CastInst(LLVMCast, *
this));
375 return It->second.get();
377 case llvm::Instruction::PHI: {
378 auto *LLVMPhi = cast<llvm::PHINode>(LLVMV);
379 It->second = std::unique_ptr<PHINode>(
new PHINode(LLVMPhi, *
this));
380 return It->second.get();
382 case llvm::Instruction::ICmp: {
383 auto *
LLVMICmp = cast<llvm::ICmpInst>(LLVMV);
385 return It->second.get();
387 case llvm::Instruction::FCmp: {
388 auto *
LLVMFCmp = cast<llvm::FCmpInst>(LLVMV);
390 return It->second.get();
392 case llvm::Instruction::Unreachable: {
394 It->second = std::unique_ptr<UnreachableInst>(
396 return It->second.get();
402 It->second = std::unique_ptr<OpaqueInst>(
403 new OpaqueInst(cast<llvm::Instruction>(LLVMV), *
this));
404 return It->second.get();
409 auto It = Pair.first;
411 It->second = std::unique_ptr<Argument>(
new Argument(LLVMArg, *
this));
412 return cast<Argument>(It->second.get());
414 return cast<Argument>(It->second.get());
423 auto NewBBPtr = std::unique_ptr<BasicBlock>(
new BasicBlock(LLVMBB, *
this));
424 auto *BB = cast<BasicBlock>(
registerValue(std::move(NewBBPtr)));
426 BB->buildBasicBlockFromLLVMIR(LLVMBB);
431 auto NewPtr = std::unique_ptr<VAArgInst>(
new VAArgInst(SI, *
this));
436 auto NewPtr = std::unique_ptr<FreezeInst>(
new FreezeInst(SI, *
this));
441 auto NewPtr = std::unique_ptr<FenceInst>(
new FenceInst(SI, *
this));
446 auto NewPtr = std::unique_ptr<SelectInst>(
new SelectInst(SI, *
this));
454 return cast<ExtractElementInst>(
registerValue(std::move(NewPtr)));
461 return cast<InsertElementInst>(
registerValue(std::move(NewPtr)));
468 return cast<ShuffleVectorInst>(
registerValue(std::move(NewPtr)));
474 return cast<ExtractValueInst>(
registerValue(std::move(NewPtr)));
480 return cast<InsertValueInst>(
registerValue(std::move(NewPtr)));
484 auto NewPtr = std::unique_ptr<BranchInst>(
new BranchInst(BI, *
this));
489 auto NewPtr = std::unique_ptr<LoadInst>(
new LoadInst(LI, *
this));
494 auto NewPtr = std::unique_ptr<StoreInst>(
new StoreInst(SI, *
this));
499 auto NewPtr = std::unique_ptr<ReturnInst>(
new ReturnInst(
I, *
this));
504 auto NewPtr = std::unique_ptr<CallInst>(
new CallInst(
I, *
this));
509 auto NewPtr = std::unique_ptr<InvokeInst>(
new InvokeInst(
I, *
this));
514 auto NewPtr = std::unique_ptr<CallBrInst>(
new CallBrInst(
I, *
this));
521 return cast<UnreachableInst>(
registerValue(std::move(NewPtr)));
524 auto NewPtr = std::unique_ptr<LandingPadInst>(
new LandingPadInst(
I, *
this));
525 return cast<LandingPadInst>(
registerValue(std::move(NewPtr)));
528 auto NewPtr = std::unique_ptr<CatchPadInst>(
new CatchPadInst(
I, *
this));
532 auto NewPtr = std::unique_ptr<CleanupPadInst>(
new CleanupPadInst(
I, *
this));
533 return cast<CleanupPadInst>(
registerValue(std::move(NewPtr)));
536 auto NewPtr = std::unique_ptr<CatchReturnInst>(
new CatchReturnInst(
I, *
this));
537 return cast<CatchReturnInst>(
registerValue(std::move(NewPtr)));
543 return cast<CleanupReturnInst>(
registerValue(std::move(NewPtr)));
549 return cast<GetElementPtrInst>(
registerValue(std::move(NewPtr)));
552 auto NewPtr = std::unique_ptr<CatchSwitchInst>(
new CatchSwitchInst(
I, *
this));
553 return cast<CatchSwitchInst>(
registerValue(std::move(NewPtr)));
556 auto NewPtr = std::unique_ptr<ResumeInst>(
new ResumeInst(
I, *
this));
560 auto NewPtr = std::unique_ptr<SwitchInst>(
new SwitchInst(
I, *
this));
564 auto NewPtr = std::unique_ptr<UnaryOperator>(
new UnaryOperator(
I, *
this));
565 return cast<UnaryOperator>(
registerValue(std::move(NewPtr)));
568 auto NewPtr = std::unique_ptr<BinaryOperator>(
new BinaryOperator(
I, *
this));
569 return cast<BinaryOperator>(
registerValue(std::move(NewPtr)));
572 auto NewPtr = std::unique_ptr<AtomicRMWInst>(
new AtomicRMWInst(
I, *
this));
573 return cast<AtomicRMWInst>(
registerValue(std::move(NewPtr)));
579 return cast<AtomicCmpXchgInst>(
registerValue(std::move(NewPtr)));
582 auto NewPtr = std::unique_ptr<AllocaInst>(
new AllocaInst(
I, *
this));
586 auto NewPtr = std::unique_ptr<CastInst>(
new CastInst(
I, *
this));
590 auto NewPtr = std::unique_ptr<PHINode>(
new PHINode(
I, *
this));
594 auto NewPtr = std::unique_ptr<ICmpInst>(
new ICmpInst(
I, *
this));
598 auto NewPtr = std::unique_ptr<FCmpInst>(
new FCmpInst(
I, *
this));
604 return It->second.get();
609 : LLVMCtx(LLVMCtx), IRTracker(*this),
617 return It->second.get();
623 auto It = Pair.first;
625 return It->second.get();
626 It->second = std::unique_ptr<Module>(
new Module(*LLVMM, *
this));
627 return It->second.get();
637 auto NewFPtr = std::unique_ptr<Function>(
new Function(
F, *
this));
638 auto *SBF = cast<Function>(
registerValue(std::move(NewFPtr)));
640 for (
auto &Arg :
F->args())
651 for (
auto &LLVMF : *LLVMM)
657 for (
auto &Alias : LLVMM->
aliases())
660 for (
auto &IFunc : LLVMM->
ifuncs())
678 CBEntry.second(
I, WhereIt);
688 "EraseInstrCallbacks size limit exceeded");
696 "Callback ID not found in EraseInstrCallbacks during deregistration");
702 "CreateInstrCallbacks size limit exceeded");
710 "Callback ID not found in CreateInstrCallbacks during deregistration");
715 "MoveInstrCallbacks size limit exceeded");
723 "Callback ID not found in MoveInstrCallbacks during deregistration");
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static std::optional< unsigned > getOpcode(ArrayRef< VPValue * > Values)
Returns the opcode of Values or ~0 if they do not all agree.
an instruction to allocate memory on the stack
This class represents an incoming formal argument to a Function.
An instruction that atomically checks whether a specified value is in a memory location,...
an instruction that atomically reads a memory location, combines it with another value,...
LLVM Basic Block Representation.
Conditional or Unconditional Branch instruction.
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
This class represents a function call, abstracting a target machine's calling convention.
This is the base class for all instructions that perform data casts.
ConstantFolder - Create constants with minimum, target independent, folding.
This is an important base class in LLVM.
This instruction compares its operands according to the predicate given to the constructor.
An instruction for ordering other memory operations.
This class represents a freeze function that returns random concrete value if an operand is either a ...
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
This instruction compares its operands according to the predicate given to the constructor.
This instruction inserts a single (scalar) element into a VectorType value.
This instruction inserts a struct field of array element value into an aggregate value.
This is an important class for using LLVM in a threaded context.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
An instruction for reading from memory.
A Module instance is used to store all the information related to an LLVM module.
iterator_range< ifunc_iterator > ifuncs()
iterator_range< alias_iterator > aliases()
iterator_range< global_iterator > globals()
Resume the propagation of an exception.
Return a value (possibly void), from a function.
This class represents the LLVM 'select' instruction.
This instruction constructs a fixed permutation of two input vectors.
An instruction for storing to memory.
This function has undefined behavior.
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
LLVM Value Representation.
Argument of a sandboxir::Function.
Iterator for Instructions in a `BasicBlock.
Contains a list of sandboxir::Instruction's.
BasicBlock * createBasicBlock(llvm::BasicBlock *BB)
Create a sandboxir::BasicBlock for an existing LLVM IR BB.
std::function< void(Instruction *)> CreateInstrCallback
GetElementPtrInst * createGetElementPtrInst(llvm::GetElementPtrInst *I)
MapVector< CallbackID, CreateInstrCallback > CreateInstrCallbacks
Callbacks called when an IR instruction is about to get created.
CallBrInst * createCallBrInst(llvm::CallBrInst *I)
Module * createModule(llvm::Module *LLVMM)
Create a sandboxir::Module corresponding to LLVMM.
MapVector< CallbackID, EraseInstrCallback > EraseInstrCallbacks
Callbacks called when an IR instruction is about to get erased.
sandboxir::Value * getValue(llvm::Value *V) const
Argument * getOrCreateArgument(llvm::Argument *LLVMArg)
Get or create a sandboxir::Argument for an existing LLVM IR LLVMArg.
ReturnInst * createReturnInst(llvm::ReturnInst *I)
void runEraseInstrCallbacks(Instruction *I)
Module * getModule(llvm::Module *LLVMM) const
friend ExtractElementInst
VAArgInst * createVAArgInst(llvm::VAArgInst *SI)
CleanupReturnInst * createCleanupReturnInst(llvm::CleanupReturnInst *I)
AllocaInst * createAllocaInst(llvm::AllocaInst *I)
void runCreateInstrCallbacks(Instruction *I)
AtomicRMWInst * createAtomicRMWInst(llvm::AtomicRMWInst *I)
InsertValueInst * createInsertValueInst(llvm::InsertValueInst *IVI)
FCmpInst * createFCmpInst(llvm::FCmpInst *I)
std::function< void(Instruction *)> EraseInstrCallback
std::function< void(Instruction *, const BBIterator &)> MoveInstrCallback
ExtractElementInst * createExtractElementInst(llvm::ExtractElementInst *EEI)
Constant * getOrCreateConstant(llvm::Constant *LLVMC)
Get or create a sandboxir::Constant from an existing LLVM IR LLVMC.
BranchInst * createBranchInst(llvm::BranchInst *I)
ShuffleVectorInst * createShuffleVectorInst(llvm::ShuffleVectorInst *SVI)
BinaryOperator * createBinaryOperator(llvm::BinaryOperator *I)
Module * getOrCreateModule(llvm::Module *LLVMM)
LoadInst * createLoadInst(llvm::LoadInst *LI)
DenseMap< llvm::Value *, std::unique_ptr< Value > > LLVMValueToValueMap
Maps LLVM Value to the corresponding sandboxir::Value.
FreezeInst * createFreezeInst(llvm::FreezeInst *SI)
PHINode * createPHINode(llvm::PHINode *I)
CallbackID registerCreateInstrCallback(CreateInstrCallback CB)
Register a callback that gets called right after a SandboxIR instruction is created.
Context(LLVMContext &LLVMCtx)
CatchPadInst * createCatchPadInst(llvm::CatchPadInst *I)
ICmpInst * createICmpInst(llvm::ICmpInst *I)
MapVector< CallbackID, MoveInstrCallback > MoveInstrCallbacks
Callbacks called when an IR instruction is about to get moved.
std::unique_ptr< Value > detach(Value *V)
Remove SBV from all SandboxIR maps and stop owning it.
void unregisterCreateInstrCallback(CallbackID ID)
ExtractValueInst * createExtractValueInst(llvm::ExtractValueInst *IVI)
uint64_t CallbackID
An ID for a registered callback.
CastInst * createCastInst(llvm::CastInst *I)
DenseMap< llvm::Module *, std::unique_ptr< Module > > LLVMModuleToModuleMap
Maps an LLVM Module to the corresponding sandboxir::Module.
CallbackID NextCallbackID
A counter used for assigning callback IDs during registration.
StoreInst * createStoreInst(llvm::StoreInst *SI)
CatchReturnInst * createCatchReturnInst(llvm::CatchReturnInst *I)
CatchSwitchInst * createCatchSwitchInst(llvm::CatchSwitchInst *I)
void unregisterMoveInstrCallback(CallbackID ID)
CleanupPadInst * createCleanupPadInst(llvm::CleanupPadInst *I)
Value * getOrCreateValue(llvm::Value *LLVMV)
Get or create a sandboxir::Value for an existing LLVM IR LLVMV.
FenceInst * createFenceInst(llvm::FenceInst *SI)
CallInst * createCallInst(llvm::CallInst *I)
SwitchInst * createSwitchInst(llvm::SwitchInst *I)
void runMoveInstrCallbacks(Instruction *I, const BBIterator &Where)
UnaryOperator * createUnaryOperator(llvm::UnaryOperator *I)
Value * getOrCreateValueInternal(llvm::Value *V, llvm::User *U=nullptr)
This is the actual function that creates sandboxir values for V, and among others handles all instruc...
InvokeInst * createInvokeInst(llvm::InvokeInst *I)
Value * registerValue(std::unique_ptr< Value > &&VPtr)
Take ownership of VPtr and store it in LLVMValueToValueMap.
LandingPadInst * createLandingPadInst(llvm::LandingPadInst *I)
InsertElementInst * createInsertElementInst(llvm::InsertElementInst *IEI)
Function * createFunction(llvm::Function *F)
Create a sandboxir::Function for an existing LLVM IR F, including all blocks and instructions.
SelectInst * createSelectInst(llvm::SelectInst *SI)
ResumeInst * createResumeInst(llvm::ResumeInst *I)
void unregisterEraseInstrCallback(CallbackID ID)
friend class BasicBlock
Various leaf nodes.
CallbackID registerMoveInstrCallback(MoveInstrCallback CB)
Register a callback that gets called when a SandboxIR instruction is about to be moved.
UnreachableInst * createUnreachableInst(llvm::UnreachableInst *UI)
AtomicCmpXchgInst * createAtomicCmpXchgInst(llvm::AtomicCmpXchgInst *I)
CallbackID registerEraseInstrCallback(EraseInstrCallback CB)
Register a callback that gets called when a SandboxIR instruction is about to be removed from its par...
std::unique_ptr< Value > detachLLVMValue(llvm::Value *V)
Remove V from the maps and returns the unique_ptr.
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
In SandboxIR the Module is mainly used to access the list of global objects.
An LLLVM Instruction that has no SandboxIR equivalent class gets mapped to an OpaqueInstr.
bool emplaceIfTracking(ArgsT... Args)
A convenience wrapper for track() that constructs and tracks the Change object if tracking is enabled...
A SandboxIR Value has users. This is the base class.
@ C
The default llvm calling convention, compatible with C.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
static constexpr int MaxRegisteredCallbacks
@ Global
Append to llvm.global_dtors.