Skip to content

Commit

Permalink
Add invariant start call creation in IRBuilder.NFC
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D22700

llvm-svn: 276471
  • Loading branch information
annamthomas committed Jul 22, 2016
1 parent fea2139 commit 58d1192
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions llvm/include/llvm/IR/IRBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@ class IRBuilderBase {
/// If the pointer isn't i8* it will be converted.
CallInst *CreateLifetimeEnd(Value *Ptr, ConstantInt *Size = nullptr);

/// Create a call to invariant.start intrinsic.
///
/// If the pointer isn't i8* it will be converted.
CallInst *CreateInvariantStart(Value *Ptr, ConstantInt *Size = nullptr);

/// \brief Create a call to Masked Load intrinsic
CallInst *CreateMaskedLoad(Value *Ptr, unsigned Align, Value *Mask,
Value *PassThru = nullptr, const Twine &Name = "");
Expand Down
20 changes: 20 additions & 0 deletions llvm/lib/IR/IRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,26 @@ CallInst *IRBuilderBase::CreateLifetimeEnd(Value *Ptr, ConstantInt *Size) {
return createCallHelper(TheFn, Ops, this);
}

CallInst *IRBuilderBase::CreateInvariantStart(Value *Ptr, ConstantInt *Size) {

assert(isa<PointerType>(Ptr->getType()) &&
"invariant.start only applies to pointers.");
Ptr = getCastedInt8PtrValue(Ptr);
if (!Size)
Size = getInt64(-1);
else
assert(Size->getType() == getInt64Ty() &&
"invariant.start requires the size to be an i64");

Value *Ops[] = {Size, Ptr};
// Fill in the single overloaded type: memory object type.
Type *ObjectPtr[1] = {Ptr->getType()};
Module *M = BB->getParent()->getParent();
Value *TheFn =
Intrinsic::getDeclaration(M, Intrinsic::invariant_start, ObjectPtr);
return createCallHelper(TheFn, Ops, this);
}

CallInst *IRBuilderBase::CreateAssumption(Value *Cond) {
assert(Cond->getType() == getInt1Ty() &&
"an assumption condition must be of type i1");
Expand Down

0 comments on commit 58d1192

Please sign in to comment.