return isPre ? IncVal : InVal;
}
-void CodeGenFunction::EmitAlignmentAssumption(llvm::Value *PtrValue,
- unsigned Alignment,
- llvm::Value *OffsetValue) {
- llvm::Value *PtrIntValue =
- Builder.CreatePtrToInt(PtrValue, IntPtrTy, "ptrint");
-
- llvm::Value *Mask = llvm::ConstantInt::get(IntPtrTy,
- Alignment > 0 ? Alignment - 1 : 0);
- if (OffsetValue) {
- bool IsOffsetZero = false;
- if (llvm::ConstantInt *CI = dyn_cast<llvm::ConstantInt>(OffsetValue))
- IsOffsetZero = CI->isZero();
-
- if (!IsOffsetZero) {
- if (OffsetValue->getType() != IntPtrTy)
- OffsetValue = Builder.CreateIntCast(OffsetValue, IntPtrTy,
- /*isSigned*/true, "offsetcast");
- PtrIntValue = Builder.CreateSub(PtrIntValue, OffsetValue, "offsetptr");
- }
- }
-
- llvm::Value *Zero = llvm::ConstantInt::get(IntPtrTy, 0);
- llvm::Value *MaskedPtr = Builder.CreateAnd(PtrIntValue, Mask, "maskedptr");
- llvm::Value *InvCond = Builder.CreateICmpEQ(MaskedPtr, Zero, "maskcond");
-
- llvm::Value *FnAssume = CGM.getIntrinsic(llvm::Intrinsic::assume);
- Builder.CreateCall(FnAssume, InvCond);
-}
-
//===----------------------------------------------------------------------===//
// LValue Expression Emission
//===----------------------------------------------------------------------===//
bool isInc, bool isPre);
void EmitAlignmentAssumption(llvm::Value *PtrValue, unsigned Alignment,
- llvm::Value *OffsetValue = nullptr);
+ llvm::Value *OffsetValue = nullptr) {
+ Builder.CreateAlignmentAssumption(CGM.getDataLayout(), PtrValue, Alignment,
+ OffsetValue);
+ }
//===--------------------------------------------------------------------===//
// Declaration Emission