diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -1262,11 +1262,15 @@ } static Align computeAllocaDefaultAlign(Type *Ty, BasicBlock *BB) { + assert(BB && "Insertion BB cannot be null when alignment not provided!"); + assert(BB->getParent() && + "BB must be in a Function when alignment not provided!"); const DataLayout &DL = BB->getModule()->getDataLayout(); return DL.getPrefTypeAlign(Ty); } static Align computeAllocaDefaultAlign(Type *Ty, Instruction *I) { + assert(I && "Insertion position cannot be null when alignment not provided!"); return computeAllocaDefaultAlign(Ty, I->getParent()); } @@ -1342,11 +1346,15 @@ } static Align computeLoadStoreDefaultAlign(Type *Ty, BasicBlock *BB) { + assert(BB && "Insertion BB cannot be null when alignment not provided!"); + assert(BB->getParent() && + "BB must be in a Function when alignment not provided!"); const DataLayout &DL = BB->getModule()->getDataLayout(); return DL.getABITypeAlign(Ty); } static Align computeLoadStoreDefaultAlign(Type *Ty, Instruction *I) { + assert(I && "Insertion position cannot be null when alignment not provided!"); return computeLoadStoreDefaultAlign(Ty, I->getParent()); }