================ @@ -1985,6 +1985,28 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) { {InnerPtr, NewMask})); } } + bool Changed = false; + KnownBits Known = computeKnownBits(II, /*Depth*/ 0, II); + // 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; + } + + // Known bits will capture if we had alignment information assosiated with + // the pointer argument. + if (Known.countMinTrailingZeros() > Log2(CI.getRetAlign().valueOrOne())) { + if (CI.hasRetAttr(Attribute::Alignment)) + CI.removeRetAttr(Attribute::Alignment); + CI.addRetAttr( + Attribute::get(CI.getContext(), Attribute::Alignment, + uint64_t(1) << Known.countMinTrailingZeros())); ---------------- nikic wrote:
Attribute::getWithAlignment(). Also you need to protect against MaximumAlignment here. 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