Skip to content

Commit

Permalink
fix LowerPrivatePointerPHIPass (#1242)
Browse files Browse the repository at this point in the history
Use proper type for ptr offset
  • Loading branch information
rjodinchr authored Sep 28, 2023
1 parent 06d2446 commit c9ca692
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/LowerPrivatePointerPHIPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,13 @@ void clspv::LowerPrivatePointerPHIPass::runOnFunction(Function &F) {
IRBuilder<> B(icmp);
if (intToPtr) {
icmp->setOperand(otherOpIsIntToPtr, intToPtr->getOperand(0));
Type *PtrOffTy = clspv::PointersAre64Bit(*F.getParent())
? B.getInt64Ty()
: B.getInt32Ty();
if (DynVal == nullptr) {
DynVal = B.getInt32(CstVal);
DynVal = ConstantInt::get(PtrOffTy, CstVal);
} else if (CstVal != 0) {
DynVal = B.CreateAdd(DynVal, B.getInt32(CstVal));
DynVal = B.CreateAdd(DynVal, ConstantInt::get(PtrOffTy, CstVal));
}
icmp->setOperand(opId, DynVal);
if (intToPtr->getNumUses() == 0) {
Expand Down

0 comments on commit c9ca692

Please sign in to comment.