[PATCH] D54588: [llvm][IRBuilder] Introspection for CreateAlignmentAssumption*() functions
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 14 11:13:13 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351104: [llvm][IRBuilder] Introspection for CreateAlignmentAssumption*() functions (authored by lebedevri, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D54588?vs=181607&id=181612#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D54588/new/
https://reviews.llvm.org/D54588
Files:
llvm/trunk/include/llvm/IR/IRBuilder.h
Index: llvm/trunk/include/llvm/IR/IRBuilder.h
===================================================================
--- llvm/trunk/include/llvm/IR/IRBuilder.h
+++ llvm/trunk/include/llvm/IR/IRBuilder.h
@@ -2126,11 +2126,12 @@
private:
/// Helper function that creates an assume intrinsic call that
/// represents an alignment assumption on the provided Ptr, Mask, Type
- /// and Offset.
+ /// and Offset. It may be sometimes useful to do some other logic
+ /// based on this alignment check, thus it can be stored into 'TheCheck'.
CallInst *CreateAlignmentAssumptionHelper(const DataLayout &DL,
Value *PtrValue, Value *Mask,
- Type *IntPtrTy,
- Value *OffsetValue) {
+ Type *IntPtrTy, Value *OffsetValue,
+ Value **TheCheck) {
Value *PtrIntValue = CreatePtrToInt(PtrValue, IntPtrTy, "ptrint");
if (OffsetValue) {
@@ -2149,6 +2150,9 @@
Value *Zero = ConstantInt::get(IntPtrTy, 0);
Value *MaskedPtr = CreateAnd(PtrIntValue, Mask, "maskedptr");
Value *InvCond = CreateICmpEQ(MaskedPtr, Zero, "maskcond");
+ if (TheCheck)
+ *TheCheck = InvCond;
+
return CreateAssumption(InvCond);
}
@@ -2159,9 +2163,13 @@
/// An optional offset can be provided, and if it is provided, the offset
/// must be subtracted from the provided pointer to get the pointer with the
/// specified alignment.
+ ///
+ /// It may be sometimes useful to do some other logic
+ /// based on this alignment check, thus it can be stored into 'TheCheck'.
CallInst *CreateAlignmentAssumption(const DataLayout &DL, Value *PtrValue,
unsigned Alignment,
- Value *OffsetValue = nullptr) {
+ Value *OffsetValue = nullptr,
+ Value **TheCheck = nullptr) {
assert(isa<PointerType>(PtrValue->getType()) &&
"trying to create an alignment assumption on a non-pointer?");
auto *PtrTy = cast<PointerType>(PtrValue->getType());
@@ -2169,7 +2177,7 @@
Value *Mask = ConstantInt::get(IntPtrTy, Alignment > 0 ? Alignment - 1 : 0);
return CreateAlignmentAssumptionHelper(DL, PtrValue, Mask, IntPtrTy,
- OffsetValue);
+ OffsetValue, TheCheck);
}
/// Create an assume intrinsic call that represents an alignment
@@ -2179,11 +2187,15 @@
/// must be subtracted from the provided pointer to get the pointer with the
/// specified alignment.
///
+ /// It may be sometimes useful to do some other logic
+ /// based on this alignment check, thus it can be stored into 'TheCheck'.
+ ///
/// This overload handles the condition where the Alignment is dependent
/// on an existing value rather than a static value.
CallInst *CreateAlignmentAssumption(const DataLayout &DL, Value *PtrValue,
Value *Alignment,
- Value *OffsetValue = nullptr) {
+ Value *OffsetValue = nullptr,
+ Value **TheCheck = nullptr) {
assert(isa<PointerType>(PtrValue->getType()) &&
"trying to create an alignment assumption on a non-pointer?");
auto *PtrTy = cast<PointerType>(PtrValue->getType());
@@ -2201,7 +2213,7 @@
ConstantInt::get(IntPtrTy, 0), "mask");
return CreateAlignmentAssumptionHelper(DL, PtrValue, Mask, IntPtrTy,
- OffsetValue);
+ OffsetValue, TheCheck);
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54588.181612.patch
Type: text/x-patch
Size: 3865 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190114/22ad1cce/attachment-0001.bin>
More information about the llvm-commits
mailing list