================ @@ -1973,6 +1978,28 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) { *II, Builder.CreateIntrinsic(InnerPtr->getType(), Intrinsic::ptrmask, {InnerPtr, NewMask})); } + bool Changed = false; + // See if we can deduce non-null. + if (!CI.hasRetAttr(Attribute::NonNull) && + (Known.isNonZero() || + isKnownNonZero(II, DL, /*Depth*/ 0, &AC, II, &DT))) { + CI.addRetAttr(Attribute::NonNull); + Changed = true; + } + + unsigned NewAlignmentLog = + std::min(Value::MaxAlignmentExponent, + std::min(BitWidth - 1, Known.countMinTrailingZeros())); + // Known bits will capture if we had alignment information associated with + // the pointer argument. + if (NewAlignmentLog > Log2(CI.getRetAlign().valueOrOne())) { + CI.removeRetAttr(Attribute::Alignment); ---------------- nikic wrote:
No need to explicitly remove the old attribute. https://github.com/llvm/llvm-project/pull/67166 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits