diff options
author | Ricky Zhou <ricky@rzhou.org> | 2021-12-18 18:49:17 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2021-12-18 18:49:17 +0100 |
commit | 9927a06f74bb48e1e5a53fb686301c71f0dec46a (patch) | |
tree | fe31605c3a0762c7dcbd3800c254ee667a1804a1 /llvm/lib/Analysis/AliasAnalysis.cpp | |
parent | 474b20b45053aa790bb425528b3f98ebd2f75120 (diff) | |
download | llvm-9927a06f74bb48e1e5a53fb686301c71f0dec46a.zip llvm-9927a06f74bb48e1e5a53fb686301c71f0dec46a.tar.gz llvm-9927a06f74bb48e1e5a53fb686301c71f0dec46a.tar.bz2 |
[AA] Handle callbr instructions in alias analysis
Before this change, AAResults::getModRefInfo() was missing a case for
callbr instructions (asm goto), which may read/write memory. In PR52735,
this led to a miscompile where a load was incorrect eliminated.
Add this missing case, as well as an assert verifying that all
memory-accessing instructions are handled properly.
Fixes #52735.
Differential Revision: https://reviews.llvm.org/D115992
Diffstat (limited to 'llvm/lib/Analysis/AliasAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/AliasAnalysis.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp index af63692..4919906 100644 --- a/llvm/lib/Analysis/AliasAnalysis.cpp +++ b/llvm/lib/Analysis/AliasAnalysis.cpp @@ -696,14 +696,16 @@ ModRefInfo AAResults::getModRefInfo(const Instruction *I, case Instruction::AtomicRMW: return getModRefInfo((const AtomicRMWInst *)I, Loc, AAQIP); case Instruction::Call: - return getModRefInfo((const CallInst *)I, Loc, AAQIP); + case Instruction::CallBr: case Instruction::Invoke: - return getModRefInfo((const InvokeInst *)I, Loc, AAQIP); + return getModRefInfo((const CallBase *)I, Loc, AAQIP); case Instruction::CatchPad: return getModRefInfo((const CatchPadInst *)I, Loc, AAQIP); case Instruction::CatchRet: return getModRefInfo((const CatchReturnInst *)I, Loc, AAQIP); default: + assert(!I->mayReadOrWriteMemory() && + "Unhandled memory access instruction!"); return ModRefInfo::NoModRef; } } |