]> granicus.if.org Git - llvm/commitdiff
Merging r258537:
authorTom Stellard <thomas.stellard@amd.com>
Thu, 2 Jun 2016 04:32:15 +0000 (04:32 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Thu, 2 Jun 2016 04:32:15 +0000 (04:32 +0000)
------------------------------------------------------------------------
r258537 | Matthew.Arsenault | 2016-01-22 11:47:54 -0800 (Fri, 22 Jan 2016) | 6 lines

AMDGPU: Fix crash with invariant markers

The promote alloca pass didn't handle these intrinsics and crashed.
These intrinsics should accept any address space, but for now just
erase them to avoid breaking.

------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_38@271484 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
test/CodeGen/AMDGPU/promote-alloca-invariant-markers.ll [new file with mode: 0644]

index 87d50d5870598726b0e86e371d0ad2e3022f9d70..ce2a4529d10d60140feef4f037590706f85602a0 100644 (file)
@@ -413,6 +413,14 @@ void AMDGPUPromoteAlloca::visitAlloca(AllocaInst &I) {
       Intr->eraseFromParent();
       continue;
     }
+    case Intrinsic::invariant_start:
+    case Intrinsic::invariant_end:
+    case Intrinsic::invariant_group_barrier:
+      Intr->eraseFromParent();
+      // FIXME: I think the invariant marker should still theoretically apply,
+      // but the intrinsics need to be changed to accept pointers with any
+      // address space.
+      continue;
     default:
       Intr->dump();
       llvm_unreachable("Don't know how to promote alloca intrinsic use.");
diff --git a/test/CodeGen/AMDGPU/promote-alloca-invariant-markers.ll b/test/CodeGen/AMDGPU/promote-alloca-invariant-markers.ll
new file mode 100644 (file)
index 0000000..6a9ec31
--- /dev/null
@@ -0,0 +1,25 @@
+; RUN: llc -march=amdgcn -mattr=+promote-alloca -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
+
+declare {}* @llvm.invariant.start(i64, i8* nocapture) #0
+declare void @llvm.invariant.end({}*, i64, i8* nocapture) #0
+declare i8* @llvm.invariant.group.barrier(i8*) #1
+
+; GCN-LABEL: {{^}}use_invariant_promotable_lds:
+; GCN: buffer_load_dword
+; GCN: ds_write_b32
+define void @use_invariant_promotable_lds(i32 addrspace(1)* %arg) #2 {
+bb:
+  %tmp = alloca i32, align 4
+  %tmp1 = bitcast i32* %tmp to i8*
+  %tmp2 = getelementptr inbounds i32, i32 addrspace(1)* %arg, i64 1
+  %tmp3 = load i32, i32 addrspace(1)* %tmp2
+  store i32 %tmp3, i32* %tmp
+  %tmp4 = call {}* @llvm.invariant.start(i64 4, i8* %tmp1) #0
+  call void @llvm.invariant.end({}* %tmp4, i64 4, i8* %tmp1) #0
+  %tmp5 = call i8* @llvm.invariant.group.barrier(i8* %tmp1) #1
+  ret void
+}
+
+attributes #0 = { argmemonly nounwind }
+attributes #1 = { nounwind readnone }
+attributes #2 = { nounwind }