summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/IR/Instruction.cpp2
-rw-r--r--llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ds.gws.init.ll2
-rw-r--r--llvm/test/Transforms/EarlyCSE/writeonly.ll15
3 files changed, 17 insertions, 2 deletions
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index ba5629d1662..b157c7bb34b 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -524,7 +524,7 @@ bool Instruction::mayReadFromMemory() const {
case Instruction::Call:
case Instruction::Invoke:
case Instruction::CallBr:
- return !cast<CallBase>(this)->doesNotAccessMemory();
+ return !cast<CallBase>(this)->doesNotReadMemory();
case Instruction::Store:
return !cast<StoreInst>(this)->isUnordered();
}
diff --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ds.gws.init.ll b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ds.gws.init.ll
index a7a8fa7f2cc..9c39593d903 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ds.gws.init.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ds.gws.init.ll
@@ -114,7 +114,7 @@ define amdgpu_kernel void @gws_init_vgpr_offset_add(i32 %val) #0 {
; LOOP: s_mov_b32 m0, -1
; LOOP: ds_write_b32
define amdgpu_kernel void @gws_init_save_m0_init_constant_offset(i32 %val) #0 {
- store i32 1, i32 addrspace(3)* @lds
+ store volatile i32 1, i32 addrspace(3)* @lds
call void @llvm.amdgcn.ds.gws.init(i32 %val, i32 10)
store i32 2, i32 addrspace(3)* @lds
ret void
diff --git a/llvm/test/Transforms/EarlyCSE/writeonly.ll b/llvm/test/Transforms/EarlyCSE/writeonly.ll
new file mode 100644
index 00000000000..0a3cd1c7401
--- /dev/null
+++ b/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
+ 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
+}
OpenPOWER on IntegriCloud