================ @@ -154,11 +154,20 @@ llvm::Value *CodeGen::emitRoundPointerUpToAlignment(CodeGenFunction &CGF, llvm::Value *Ptr, CharUnits Align) { // OverflowArgArea = (OverflowArgArea + Align - 1) & -Align; + Ptr = CGF.Builder.CreateAddrSpaceCast(Ptr, CGF.AllocaInt8PtrTy, + Ptr->getName() + ".addrcast"); llvm::Value *RoundUp = CGF.Builder.CreateConstInBoundsGEP1_32( CGF.Builder.getInt8Ty(), Ptr, Align.getQuantity() - 1); + + // ptrmask is sensitive to the bitwidth of the mask + unsigned IndexTypeSize = + CGF.CGM.getDataLayout().getIndexTypeSizeInBits(RoundUp->getType()); + llvm::IntegerType *MaskType = + llvm::IntegerType::get(CGF.getLLVMContext(), IndexTypeSize); + return CGF.Builder.CreateIntrinsic( - llvm::Intrinsic::ptrmask, {CGF.AllocaInt8PtrTy, CGF.IntPtrTy}, - {RoundUp, llvm::ConstantInt::get(CGF.IntPtrTy, -Align.getQuantity())}, + llvm::Intrinsic::ptrmask, {CGF.AllocaInt8PtrTy, MaskType}, ---------------- arsenm wrote:
This seems like it was bad to begin with, I think this should have just been using Ptr->getType() instead of the CFG types https://github.com/llvm/llvm-project/pull/89007 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits