Index: llvm/lib/IR/Instruction.cpp =================================================================== --- llvm/lib/IR/Instruction.cpp +++ llvm/lib/IR/Instruction.cpp @@ -524,7 +524,7 @@ case Instruction::Call: case Instruction::Invoke: case Instruction::CallBr: - return !cast(this)->doesNotAccessMemory(); + return !cast(this)->doesNotReadMemory(); case Instruction::Store: return !cast(this)->isUnordered(); } Index: llvm/test/Transforms/EarlyCSE/writeonly.ll =================================================================== --- /dev/null +++ llvm/test/Transforms/EarlyCSE/writeonly.ll @@ -0,0 +1,15 @@ +; RUN: opt -S -early-cse < %s | FileCheck %s + +@var = global i32 undef +declare void @foo() nounwind + +define void @test() { +; CHECK-LABEL: @test( +; CHECK-NOT: store i32 1, i32* @var + store i32 1, i32* @var +; CHECK: call void @foo() + call void @foo() writeonly +; CHECK: store i32 2, i32* @var + store i32 2, i32* @var + ret void +}