Index: lib/Transforms/Utils/InlineFunction.cpp =================================================================== --- lib/Transforms/Utils/InlineFunction.cpp +++ lib/Transforms/Utils/InlineFunction.cpp @@ -741,7 +741,7 @@ // caller, then don't bother inserting the assumption. Value *Arg = CS.getArgument(I->getArgNo()); if (getKnownAlignment(Arg, DL, CS.getInstruction(), - &IFI.ACT->getAssumptionCache(*CalledFunc), + &IFI.ACT->getAssumptionCache(*CS.getCaller()), &DT) >= Align) continue; Index: test/Transforms/Inline/align.ll =================================================================== --- test/Transforms/Inline/align.ll +++ test/Transforms/Inline/align.ll @@ -96,3 +96,20 @@ attributes #0 = { nounwind uwtable } +; This is a regression test. It checks that InlineFunction AddAlignmentAssumptions +; passes correct assumption cache to getKnownAlignment. Otherwise this code will +; fail with an assertion in computeKnownBitsFromAssume. + +; CHECK: define void @caller +; CHECK-NOT: call i8 @callee +define void @caller(i8* %a) { + call i8 @callee(i8* %a) + ret void +} + +declare void @llvm.assume(i1 %cond) +define i8 @callee(i8* align 8 %a) { + call void @llvm.assume(i1 1) + %res = load i8, i8* %a + ret i8 %res +} \ No newline at end of file