[llvm] [SandboxIR] Implement AllocaInst (PR #102027)
Thorsten Schütt via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 5 11:05:05 PDT 2024
================
@@ -1212,6 +1212,80 @@ static llvm::Instruction::CastOps getLLVMCastOp(Instruction::Opcode Opc) {
}
}
+AllocaInst *AllocaInst::create(Type *Ty, unsigned AddrSpace, BBIterator WhereIt,
+ BasicBlock *WhereBB, Context &Ctx,
+ Value *ArraySize, const Twine &Name) {
+ auto &Builder = Ctx.getLLVMIRBuilder();
+ if (WhereIt == WhereBB->end())
+ Builder.SetInsertPoint(cast<llvm::BasicBlock>(WhereBB->Val));
+ else
+ Builder.SetInsertPoint((*WhereIt).getTopmostLLVMInstruction());
+ auto *NewAlloca = Builder.CreateAlloca(Ty, AddrSpace, ArraySize->Val, Name);
+ return Ctx.createAllocaInst(NewAlloca);
+}
+
+AllocaInst *AllocaInst::create(Type *Ty, unsigned AddrSpace,
+ Instruction *InsertBefore, Context &Ctx,
+ Value *ArraySize, const Twine &Name) {
+ return create(Ty, AddrSpace, InsertBefore->getIterator(),
+ InsertBefore->getParent(), Ctx, ArraySize, Name);
+}
+
+AllocaInst *AllocaInst::create(Type *Ty, unsigned AddrSpace,
+ BasicBlock *InsertAtEnd, Context &Ctx,
+ Value *ArraySize, const Twine &Name) {
+ return create(Ty, AddrSpace, InsertAtEnd->end(), InsertAtEnd, Ctx, ArraySize,
+ Name);
+}
+
+void AllocaInst::setAllocatedType(Type *Ty) {
+ auto &Tracker = Ctx.getTracker();
+ if (Tracker.isTracking())
+ Tracker.track(std::make_unique<AllocaSetAllocatedType>(
+ cast<AllocaInst>(this), Tracker));
----------------
tschuett wrote:
I may be blind, but why is this not a AllocaInst?
https://github.com/llvm/llvm-project/pull/102027
More information about the llvm-commits
mailing list