[PATCH] D69086: [IR] Fix mayReadFromMemory() for writeonly calls

Yevgeny Rouban via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 18 02:29:05 PDT 2019


yrouban updated this revision to Diff 225579.
yrouban added a comment.
Herald added subscribers: nhaehnle, jvesely.

Fixed llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ds.gws.init.ll as Matt suggested


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69086/new/

https://reviews.llvm.org/D69086

Files:
  llvm/lib/IR/Instruction.cpp
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ds.gws.init.ll
  llvm/test/Transforms/EarlyCSE/writeonly.ll


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
+
+ at 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
+}
Index: llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ds.gws.init.ll
===================================================================
--- llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ds.gws.init.ll
+++ llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ds.gws.init.ll
@@ -114,7 +114,7 @@
 ; 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
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<CallBase>(this)->doesNotAccessMemory();
+    return !cast<CallBase>(this)->doesNotReadMemory();
   case Instruction::Store:
     return !cast<StoreInst>(this)->isUnordered();
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69086.225579.patch
Type: text/x-patch
Size: 1593 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191018/449661ee/attachment.bin>


More information about the llvm-commits mailing list