为什么 LLVM AliasAnalysis 无法精确确定两次取消引用的指针之间的别名关系?

Aet*_*etX 5 c c++ llvm strict-aliasing

我对 LLVM AliasAnalysis 实现感到非常困惑。假设我有这个程序:

int* key = malloc(4);
*key = 10;
*key = 11;
Run Code Online (Sandbox Code Playgroud)

它被转换为 IR 代码,如下所示:

  %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
Run Code Online (Sandbox Code Playgroud)

然后我要求 LLVM使用该函数打印出%5和之间的别名关系。然后它表明它们可能彼此别名(如 )。为什么 LLVM 无法检测到它们必须互相别名?我有什么办法可以修复它吗?%6static_cast<uint16_t>(AA_->getModRefInfo(FirstStore, MemoryLocation(SecondStorePointer)))ModRefInfo::Mod