I'm very confused by the LLVM AliasAnalysis implementation. Say I have this program:
int* key = malloc(4);
*key = 10;
*key = 11;
It gets transformed to IR code like this:
%3 = call noalias i8* @malloc(i64 4) #2
%4 = bitcast i8* %3 to i32*
store i32* %4, i32** %2, align 8
%5 = load i32*, i32** %2, align 8
store i32 10, i32* %5, align 4
%6 = load i32*, i32** %2, align 8
store i32 11, i32* %6, align 4
Than I ask LLVM to print out the alias relationship between %5 and %6, by using the function static_cast<uint16_t>(AA_->getModRefInfo(FirstStore, MemoryLocation(SecondStorePointer))). It then shows that they may alias (as ModRefInfo::Mod) with each other. Why is LLVM unable to detect that they must alias each other? Is there any way I can fix it?