define void @main(i8* %a) {
call i8 @foo(i8* %a) ret void
}
declare void @llvm.assume(i1 %cond)
define i8 @foo(i8* align 8 %a) {
call void @llvm.assume(i1 1) %res = load i8, i8* %a ret i8 %res
}
opt -S -inline for the piece of code above fails with an assertion:
opt: /home/apilipenko/llvm-upstream/llvm/lib/Analysis/ValueTracking.cpp:719: void computeKnownBitsFromAssume(llvm::Value*, llvm::APInt&, llvm::APInt&, const llvm::DataLayout&, unsigned int, const {anonymous}::Query&): Assertion `I->getParent()->getParent() == Q.CxtI->getParent()->getParent() && "Got assumption for the wrong function!"' failed.
That happens because InlineFunction AddAlignmentAssumptions passes incorrect assumption cache to getKnownAlignment. It asks about caller's value alignment, but passes callee AC. Caller's AC must be passed instead.
This bug was introduced by "[PM] Split the AssumptionTracker immutable pass into two separate APIs" patch (http://reviews.llvm.org/rL225131)