@@ -1640,7 +1640,7 @@ static PointerBounds expandBounds(const RuntimeCheckingPtrGroup *CG,
16401640 Loop *TheLoop, Instruction *Loc,
16411641 SCEVExpander &Exp) {
16421642 LLVMContext &Ctx = Loc->getContext ();
1643- Type *PtrArithTy = Type::getInt8PtrTy (Ctx, CG->AddressSpace );
1643+ Type *PtrArithTy = PointerType::get (Ctx, CG->AddressSpace );
16441644
16451645 Value *Start = nullptr , *End = nullptr ;
16461646 LLVM_DEBUG (dbgs () << " LAA: Adding RT check for range:\n " );
@@ -1693,21 +1693,13 @@ Value *llvm::addRuntimeChecks(
16931693 const PointerBounds &A = Check.first , &B = Check.second ;
16941694 // Check if two pointers (A and B) conflict where conflict is computed as:
16951695 // start(A) <= end(B) && start(B) <= end(A)
1696- unsigned AS0 = A.Start ->getType ()->getPointerAddressSpace ();
1697- unsigned AS1 = B.Start ->getType ()->getPointerAddressSpace ();
16981696
1699- assert ((AS0 == B.End ->getType ()->getPointerAddressSpace ()) &&
1700- (AS1 == A.End ->getType ()->getPointerAddressSpace ()) &&
1697+ assert ((A.Start ->getType ()->getPointerAddressSpace () ==
1698+ B.End ->getType ()->getPointerAddressSpace ()) &&
1699+ (B.Start ->getType ()->getPointerAddressSpace () ==
1700+ A.End ->getType ()->getPointerAddressSpace ()) &&
17011701 " Trying to bounds check pointers with different address spaces" );
17021702
1703- Type *PtrArithTy0 = Type::getInt8PtrTy (Ctx, AS0);
1704- Type *PtrArithTy1 = Type::getInt8PtrTy (Ctx, AS1);
1705-
1706- Value *Start0 = ChkBuilder.CreateBitCast (A.Start , PtrArithTy0, " bc" );
1707- Value *Start1 = ChkBuilder.CreateBitCast (B.Start , PtrArithTy1, " bc" );
1708- Value *End0 = ChkBuilder.CreateBitCast (A.End , PtrArithTy1, " bc" );
1709- Value *End1 = ChkBuilder.CreateBitCast (B.End , PtrArithTy0, " bc" );
1710-
17111703 // [A|B].Start points to the first accessed byte under base [A|B].
17121704 // [A|B].End points to the last accessed byte, plus one.
17131705 // There is no conflict when the intervals are disjoint:
@@ -1716,8 +1708,8 @@ Value *llvm::addRuntimeChecks(
17161708 // bound0 = (B.Start < A.End)
17171709 // bound1 = (A.Start < B.End)
17181710 // IsConflict = bound0 & bound1
1719- Value *Cmp0 = ChkBuilder.CreateICmpULT (Start0, End1 , " bound0" );
1720- Value *Cmp1 = ChkBuilder.CreateICmpULT (Start1, End0 , " bound1" );
1711+ Value *Cmp0 = ChkBuilder.CreateICmpULT (A. Start , B. End , " bound0" );
1712+ Value *Cmp1 = ChkBuilder.CreateICmpULT (B. Start , A. End , " bound1" );
17211713 Value *IsConflict = ChkBuilder.CreateAnd (Cmp0, Cmp1, " found.conflict" );
17221714 if (MemoryRuntimeCheck) {
17231715 IsConflict =
0 commit comments