diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp --- a/llvm/lib/IR/Instruction.cpp +++ b/llvm/lib/IR/Instruction.cpp @@ -553,8 +553,10 @@ return true; case Instruction::Call: case Instruction::Invoke: - case Instruction::CallBr: - return !cast(this)->doesNotReadMemory(); + case Instruction::CallBr: { + const CallBase &CB = *cast(this); + return !CB.doesNotReadMemory() && !CB.onlyAccessesInaccessibleMemory(); + } case Instruction::Store: return !cast(this)->isUnordered(); } @@ -573,8 +575,10 @@ return true; case Instruction::Call: case Instruction::Invoke: - case Instruction::CallBr: - return !cast(this)->onlyReadsMemory(); + case Instruction::CallBr: { + const CallBase &CB = *cast(this); + return !CB.onlyReadsMemory() && !CB.onlyAccessesInaccessibleMemory(); + } case Instruction::Load: return !cast(this)->isUnordered(); }