llvm.org GIT mirror llvm / 3453e8b
[opaque pointer type] Store the value type of an alloca git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236175 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 4 years ago
3 changed file(s) with 18 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
7272 /// AllocaInst - an instruction to allocate memory on the stack
7373 ///
7474 class AllocaInst : public UnaryInstruction {
75 Type *AllocatedType;
76
7577 protected:
7678 AllocaInst *clone_impl() const override;
7779 public:
112114 /// getAllocatedType - Return the type that is being allocated by the
113115 /// instruction.
114116 ///
115 Type *getAllocatedType() const;
117 Type *getAllocatedType() const { return AllocatedType; }
118 /// \brief for use only in special circumstances that need to generically
119 /// transform a whole instruction (eg: IR linking and vectorization).
120 void setAllocatedType(Type *Ty) { AllocatedType = Ty; }
116121
117122 /// getAlignment - Return the alignment of the memory that is being allocated
118123 /// by the instruction.
863863
864864 AllocaInst::AllocaInst(Type *Ty, Value *ArraySize, unsigned Align,
865865 const Twine &Name, Instruction *InsertBefore)
866 : UnaryInstruction(PointerType::getUnqual(Ty), Alloca,
867 getAISize(Ty->getContext(), ArraySize), InsertBefore) {
866 : UnaryInstruction(PointerType::getUnqual(Ty), Alloca,
867 getAISize(Ty->getContext(), ArraySize), InsertBefore),
868 AllocatedType(Ty) {
868869 setAlignment(Align);
869870 assert(!Ty->isVoidTy() && "Cannot allocate void!");
870871 setName(Name);
872873
873874 AllocaInst::AllocaInst(Type *Ty, Value *ArraySize, unsigned Align,
874875 const Twine &Name, BasicBlock *InsertAtEnd)
875 : UnaryInstruction(PointerType::getUnqual(Ty), Alloca,
876 getAISize(Ty->getContext(), ArraySize), InsertAtEnd) {
876 : UnaryInstruction(PointerType::getUnqual(Ty), Alloca,
877 getAISize(Ty->getContext(), ArraySize), InsertAtEnd),
878 AllocatedType(Ty) {
877879 setAlignment(Align);
878880 assert(!Ty->isVoidTy() && "Cannot allocate void!");
879881 setName(Name);
896898 if (ConstantInt *CI = dyn_cast(getOperand(0)))
897899 return !CI->isOne();
898900 return true;
899 }
900
901 Type *AllocaInst::getAllocatedType() const {
902 return getType()->getElementType();
903901 }
904902
905903 /// isStaticAlloca - Return true if this alloca is in the entry block of the
395395 Tys.push_back(TypeMapper->remapType(Ty));
396396 CS.mutateFunctionType(FunctionType::get(
397397 TypeMapper->remapType(I->getType()), Tys, FTy->isVarArg()));
398 } else
399 I->mutateType(TypeMapper->remapType(I->getType()));
400 }
398 return;
399 }
400 if (auto *AI = dyn_cast(I))
401 AI->setAllocatedType(TypeMapper->remapType(AI->getAllocatedType()));
402 I->mutateType(TypeMapper->remapType(I->getType()));
403 }