[PATCH] D84085: [SROA][Mem2Reg] Do not crash on alloca + addrspacecast
Johannes Doerfert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 17 19:53:12 PDT 2020
jdoerfert created this revision.
jdoerfert added reviewers: arsenm, fhahn, lebedev.ri, spatel, nicholas.
Herald added subscribers: bollu, hiraditya, wdng.
Herald added a project: LLVM.
SROA knows that it can look through addrspacecast but
PromoteMemoryToRegister did not handle them. This caused an assertion
error for the test case, exposed while running
`Transforms/PhaseOrdering/inlining-alignment-assumptions.ll` with D83978 <https://reviews.llvm.org/D83978>
applied.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D84085
Files:
llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
llvm/test/Transforms/SROA/alloca_addrspace.ll
Index: llvm/test/Transforms/SROA/alloca_addrspace.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/SROA/alloca_addrspace.ll
@@ -0,0 +1,21 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -sroa -S | FileCheck %s
+; RUN: opt < %s -passes=sroa -S | FileCheck %s
+; RUN: opt < %s -mem2reg -S | FileCheck %s
+; RUN: opt < %s -passes=mem2reg -S | FileCheck %s
+
+; Do not crash ;)
+
+target datalayout = "e-p:64:64-p5:32:32-A5"
+
+define amdgpu_kernel void @addressspace_alloca() {
+; CHECK-LABEL: @addressspace_alloca(
+; CHECK-NEXT: ret void
+;
+ %alloca = alloca i8, align 8, addrspace(5)
+ %cast = addrspacecast i8 addrspace(5)* %alloca to i8*
+ call void @llvm.lifetime.start.p0i8(i64 2, i8* %cast)
+ ret void
+}
+
+declare void @llvm.lifetime.start.p0i8(i64 %size, i8* nocapture %ptr)
Index: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
===================================================================
--- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -95,6 +95,9 @@
return false;
if (!onlyUsedByLifetimeMarkers(GEPI))
return false;
+ } else if (const AddrSpaceCastInst *ASCI = dyn_cast<AddrSpaceCastInst>(U)) {
+ if (!onlyUsedByLifetimeMarkers(ASCI))
+ return false;
} else {
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84085.278963.patch
Type: text/x-patch
Size: 1445 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200718/591e84ba/attachment.bin>
More information about the llvm-commits
mailing list