Skip to content

Commit be0e9ee

Browse files
committed
!fixup skip for args, no context instr.
1 parent bfd0c02 commit be0e9ee

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3255,24 +3255,18 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
32553255
if (!RK || RK.AttrKind != Attribute::Alignment ||
32563256
!isPowerOf2_64(RK.ArgValue))
32573257
continue;
3258-
auto *C = dyn_cast<Constant>(RK.WasOn);
3259-
if (C && C->isNullValue()) {
3260-
} else {
3261-
Value *UO = getUnderlyingObject(RK.WasOn);
3262-
if (!UO || isa<Argument>(UO))
3263-
continue;
3264-
3265-
// Try to get the instruction before the assumption to use as
3266-
// context.
3267-
Instruction *CtxI = nullptr;
3268-
if (CtxI && II->getParent()->begin() != II->getIterator())
3269-
CtxI = II->getPrevNode();
3270-
3271-
auto Known = computeKnownBits(RK.WasOn, 1, CtxI);
3272-
unsigned KnownAlign = 1 << Known.countMinTrailingZeros();
3273-
if (KnownAlign < RK.ArgValue)
3274-
continue;
3275-
}
3258+
3259+
// Don't try to remove align assumptions for pointers derived from
3260+
// arguments. We might lose information if the function gets inline and
3261+
// the align argument attribute disappears.
3262+
Value *UO = getUnderlyingObject(RK.WasOn);
3263+
if (!UO || isa<Argument>(UO))
3264+
continue;
3265+
3266+
auto Known = computeKnownBits(RK.WasOn, 0, nullptr);
3267+
unsigned KnownAlign = 1 << Known.countMinTrailingZeros();
3268+
if (KnownAlign < RK.ArgValue)
3269+
continue;
32763270
auto *New = CallBase::removeOperandBundle(II, OBU.getTagID());
32773271
return New;
32783272
}

0 commit comments

Comments
 (0)