[PATCH] Fix Bug in SROA transformation [PR18615]
Karthik Bhat
kv.bhat at samsung.com
Sun Feb 16 22:10:11 PST 2014
Hi Duncan,
Thanks for having a look at the patch. Added a test case to capture PR18615 in clang/test/CodeGen/ Please let me know if this the right place for this test case as i'm a bit new to llvm.
Please let me know your inputs about the patch.
Thanks
Karthik Bhat
Hi chandlerc,
http://llvm-reviews.chandlerc.com/D2759
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D2759?vs=7045&id=7154#toc
Files:
lib/Transforms/Scalar/SROA.cpp
test/CodeGen/pr18615.c
Index: lib/Transforms/Scalar/SROA.cpp
===================================================================
--- lib/Transforms/Scalar/SROA.cpp
+++ lib/Transforms/Scalar/SROA.cpp
@@ -524,6 +524,10 @@
// Insert the use now that we've fixed up the splittable nature.
insertUse(II, Offset, Size, /*IsSplittable=*/Inserted && Length);
+ //If the insert resulted in marking the instruction as dead
+ //i.e. we didn't end up pushing the usage into map then return
+ if (VisitedDeadInsts.count(&II))
+ return;
// Check that we ended up with a valid index in the map.
assert(S.Slices[PrevIdx].getUse()->getUser() == &II &&
"Map index doesn't point back to a slice with this user.");
Index: test/CodeGen/pr18615.c
===================================================================
--- test/CodeGen/pr18615.c
+++ test/CodeGen/pr18615.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm -O1 %s -o /dev/null
+int a;
+
+struct S0
+{
+ int f0;
+ int f1;
+ int f2;
+};
+
+void
+fn1 ()
+{
+ int b = -1;
+ struct S0 f[1];
+ if (a)
+ f[0] = f[b];
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2759.2.patch
Type: text/x-patch
Size: 1087 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140216/779045ba/attachment.bin>
More information about the llvm-commits
mailing list