<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 06/27/2014 02:46 PM, Reid Kleckner
wrote:<br>
</div>
<blockquote
cite="mid:CACs=tyKthdEnYGUm9GH8xfzCsFia0OgNNsyh45syYeAitvxrtQ@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<div dir="ltr">This generated a .s file in the source tree which
is getting picked up in subsequent builds:
<div><a moz-do-not-send="true"
href="http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/4876">http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/4876</a><br>
</div>
<div><br>
</div>
<div>We need to commit this line for an hour and then roll it
back in an hour or so to fix the bots:</div>
<div>; RUN: rm %S/private-memory-broken.s</div>
</div>
<div class="gmail_extra"><br>
</div>
</blockquote>
Ok, I can do that. I was hoping the bots would eventually clean
themselves out<br>
<br>
<blockquote
cite="mid:CACs=tyKthdEnYGUm9GH8xfzCsFia0OgNNsyh45syYeAitvxrtQ@mail.gmail.com"
type="cite">
<div class="gmail_extra"><br>
<div class="gmail_quote">
On Fri, Jun 27, 2014 at 9:52 AM, Matt Arsenault <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:Matthew.Arsenault@amd.com" target="_blank">Matthew.Arsenault@amd.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: arsenm<br>
Date: Fri Jun 27 11:52:49 2014<br>
New Revision: 211906<br>
<br>
URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project?rev=211906&view=rev"
target="_blank">http://llvm.org/viewvc/llvm-project?rev=211906&view=rev</a><br>
Log:<br>
R600: Don't crash on unhandled instruction in promote alloca<br>
<br>
Added:<br>
llvm/trunk/test/CodeGen/R600/private-memory-atomics.ll<br>
llvm/trunk/test/CodeGen/R600/private-memory-broken.ll<br>
Modified:<br>
llvm/trunk/lib/Target/R600/AMDGPUPromoteAlloca.cpp<br>
llvm/trunk/test/CodeGen/R600/private-memory.ll<br>
<br>
Modified: llvm/trunk/lib/Target/R600/AMDGPUPromoteAlloca.cpp<br>
URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/AMDGPUPromoteAlloca.cpp?rev=211906&r1=211905&r2=211906&view=diff"
target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/AMDGPUPromoteAlloca.cpp?rev=211906&r1=211905&r2=211906&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Target/R600/AMDGPUPromoteAlloca.cpp
(original)<br>
+++ llvm/trunk/lib/Target/R600/AMDGPUPromoteAlloca.cpp Fri
Jun 27 11:52:49 2014<br>
@@ -129,6 +129,22 @@ static Value*
GEPToVectorIndex(GetElemen<br>
return GEP->getOperand(2);<br>
}<br>
<br>
+// Not an instruction handled below to turn into a vector.<br>
+//<br>
+// TODO: Check isTriviallyVectorizable for calls and handle
other<br>
+// instructions.<br>
+static bool canVectorizeInst(Instruction *Inst) {<br>
+ switch (Inst->getOpcode()) {<br>
+ case Instruction::Load:<br>
+ case Instruction::Store:<br>
+ case Instruction::BitCast:<br>
+ case Instruction::AddrSpaceCast:<br>
+ return true;<br>
+ default:<br>
+ return false;<br>
+ }<br>
+}<br>
+<br>
static bool tryPromoteAllocaToVector(AllocaInst *Alloca) {<br>
Type *AllocaTy = Alloca->getAllocatedType();<br>
<br>
@@ -149,6 +165,9 @@ static bool tryPromoteAllocaToVector(All<br>
for (User *AllocaUser : Alloca->users()) {<br>
GetElementPtrInst *GEP =
dyn_cast<GetElementPtrInst>(AllocaUser);<br>
if (!GEP) {<br>
+ if
(!canVectorizeInst(cast<Instruction>(AllocaUser)))<br>
+ return false;<br>
+<br>
WorkList.push_back(AllocaUser);<br>
continue;<br>
}<br>
@@ -164,6 +183,9 @@ static bool tryPromoteAllocaToVector(All<br>
<br>
GEPVectorIdx[GEP] = Index;<br>
for (User *GEPUser : AllocaUser->users()) {<br>
+ if
(!canVectorizeInst(cast<Instruction>(GEPUser)))<br>
+ return false;<br>
+<br>
WorkList.push_back(GEPUser);<br>
}<br>
}<br>
@@ -201,12 +223,12 @@ static bool
tryPromoteAllocaToVector(All<br>
break;<br>
}<br>
case Instruction::BitCast:<br>
+ case Instruction::AddrSpaceCast:<br>
break;<br>
<br>
default:<br>
Inst->dump();<br>
- llvm_unreachable("Do not know how to replace this
instruction "<br>
- "with vector op");<br>
+ llvm_unreachable("Inconsistency in instructions
promotable to vector");<br>
}<br>
}<br>
return true;<br>
<br>
Added:
llvm/trunk/test/CodeGen/R600/private-memory-atomics.ll<br>
URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/R600/private-memory-atomics.ll?rev=211906&view=auto"
target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/R600/private-memory-atomics.ll?rev=211906&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/CodeGen/R600/private-memory-atomics.ll
(added)<br>
+++ llvm/trunk/test/CodeGen/R600/private-memory-atomics.ll
Fri Jun 27 11:52:49 2014<br>
@@ -0,0 +1,31 @@<br>
+; RUN: llc -verify-machineinstrs -march=r600 -mcpu=SI <
%s<br>
+<br>
+; This works because promote allocas pass replaces these
with LDS atomics.<br>
+<br>
+; Private atomics have no real use, but at least shouldn't
crash on it.<br>
+define void @atomicrmw_private(i32 addrspace(1)* %out, i32
%in) nounwind {<br>
+entry:<br>
+ %tmp = alloca [2 x i32]<br>
+ %tmp1 = getelementptr [2 x i32]* %tmp, i32 0, i32 0<br>
+ %tmp2 = getelementptr [2 x i32]* %tmp, i32 0, i32 1<br>
+ store i32 0, i32* %tmp1<br>
+ store i32 1, i32* %tmp2<br>
+ %tmp3 = getelementptr [2 x i32]* %tmp, i32 0, i32 %in<br>
+ %tmp4 = atomicrmw add i32* %tmp3, i32 7 acq_rel<br>
+ store i32 %tmp4, i32 addrspace(1)* %out<br>
+ ret void<br>
+}<br>
+<br>
+define void @cmpxchg_private(i32 addrspace(1)* %out, i32
%in) nounwind {<br>
+entry:<br>
+ %tmp = alloca [2 x i32]<br>
+ %tmp1 = getelementptr [2 x i32]* %tmp, i32 0, i32 0<br>
+ %tmp2 = getelementptr [2 x i32]* %tmp, i32 0, i32 1<br>
+ store i32 0, i32* %tmp1<br>
+ store i32 1, i32* %tmp2<br>
+ %tmp3 = getelementptr [2 x i32]* %tmp, i32 0, i32 %in<br>
+ %tmp4 = cmpxchg i32* %tmp3, i32 0, i32 1 acq_rel
monotonic<br>
+ %val = extractvalue { i32, i1 } %tmp4, 0<br>
+ store i32 %val, i32 addrspace(1)* %out<br>
+ ret void<br>
+}<br>
<br>
Added: llvm/trunk/test/CodeGen/R600/private-memory-broken.ll<br>
URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/R600/private-memory-broken.ll?rev=211906&view=auto"
target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/R600/private-memory-broken.ll?rev=211906&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/CodeGen/R600/private-memory-broken.ll
(added)<br>
+++ llvm/trunk/test/CodeGen/R600/private-memory-broken.ll
Fri Jun 27 11:52:49 2014<br>
@@ -0,0 +1,20 @@<br>
+; RUN: not llc -verify-machineinstrs -march=r600 -mcpu=SI
%s 2>&1 | FileCheck %s<br>
+<br>
+; Make sure promote alloca pass doesn't crash<br>
+<br>
+; CHECK: unsupported call<br>
+<br>
+declare i32 @foo(i32*) nounwind<br>
+<br>
+define void @call_private(i32 addrspace(1)* %out, i32 %in)
nounwind {<br>
+entry:<br>
+ %tmp = alloca [2 x i32]<br>
+ %tmp1 = getelementptr [2 x i32]* %tmp, i32 0, i32 0<br>
+ %tmp2 = getelementptr [2 x i32]* %tmp, i32 0, i32 1<br>
+ store i32 0, i32* %tmp1<br>
+ store i32 1, i32* %tmp2<br>
+ %tmp3 = getelementptr [2 x i32]* %tmp, i32 0, i32 %in<br>
+ %val = call i32 @foo(i32* %tmp3) nounwind<br>
+ store i32 %val, i32 addrspace(1)* %out<br>
+ ret void<br>
+}<br>
<br>
Modified: llvm/trunk/test/CodeGen/R600/private-memory.ll<br>
URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/R600/private-memory.ll?rev=211906&r1=211905&r2=211906&view=diff"
target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/R600/private-memory.ll?rev=211906&r1=211905&r2=211906&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/CodeGen/R600/private-memory.ll
(original)<br>
+++ llvm/trunk/test/CodeGen/R600/private-memory.ll Fri Jun
27 11:52:49 2014<br>
@@ -267,5 +267,19 @@ entry:<br>
%load = load i32* %gep2<br>
store i32 %load, i32 addrspace(1)* %out<br>
ret void<br>
+}<br>
<br>
+define void @select_private(i32 addrspace(1)* %out, i32
%in) nounwind {<br>
+entry:<br>
+ %tmp = alloca [2 x i32]<br>
+ %tmp1 = getelementptr [2 x i32]* %tmp, i32 0, i32 0<br>
+ %tmp2 = getelementptr [2 x i32]* %tmp, i32 0, i32 1<br>
+ store i32 0, i32* %tmp1<br>
+ store i32 1, i32* %tmp2<br>
+ %cmp = icmp eq i32 %in, 0<br>
+ %sel = select i1 %cmp, i32* %tmp1, i32* %tmp2<br>
+ %load = load i32* %sel<br>
+ store i32 %load, i32 addrspace(1)* %out<br>
+ ret void<br>
}<br>
+<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a moz-do-not-send="true"
href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a moz-do-not-send="true"
href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits"
target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>