[llvm-branch-commits] [cfe-branch] r111417 - in /cfe/branches/Apple/williamson: lib/Analysis/CFG.cpp lib/Analysis/CFG.cpp.orig test/Analysis/dead-stores.c
Daniel Dunbar
daniel at zuster.org
Wed Aug 18 13:33:56 PDT 2010
Author: ddunbar
Date: Wed Aug 18 15:33:55 2010
New Revision: 111417
URL: http://llvm.org/viewvc/llvm-project?rev=111417&view=rev
Log:
Merge r111283:
--
Author: Ted Kremenek <kremenek at apple.com>
Date: Tue Aug 17 21:00:06 2010 +0000
Fix horrible CFG bug caused by a series of NullStmts appearing at the beginning of a do...while loop. This would cause
the body of the DoStmt to be disconnected from the preceding code.
Added:
cfe/branches/Apple/williamson/lib/Analysis/CFG.cpp.orig
- copied, changed from r111416, cfe/branches/Apple/williamson/lib/Analysis/CFG.cpp
Modified:
cfe/branches/Apple/williamson/lib/Analysis/CFG.cpp
cfe/branches/Apple/williamson/test/Analysis/dead-stores.c
Modified: cfe/branches/Apple/williamson/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/williamson/lib/Analysis/CFG.cpp?rev=111417&r1=111416&r2=111417&view=diff
==============================================================================
--- cfe/branches/Apple/williamson/lib/Analysis/CFG.cpp (original)
+++ cfe/branches/Apple/williamson/lib/Analysis/CFG.cpp Wed Aug 18 15:33:55 2010
@@ -691,7 +691,10 @@
for (CompoundStmt::reverse_body_iterator I=C->body_rbegin(), E=C->body_rend();
I != E; ++I ) {
- LastBlock = addStmt(*I);
+ // If we hit a segment of code just containing ';' (NullStmts), we can
+ // get a null block back. In such cases, just use the LastBlock
+ if (CFGBlock *newBlock = addStmt(*I))
+ LastBlock = newBlock;
if (badCFG)
return NULL;
Copied: cfe/branches/Apple/williamson/lib/Analysis/CFG.cpp.orig (from r111416, cfe/branches/Apple/williamson/lib/Analysis/CFG.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/williamson/lib/Analysis/CFG.cpp.orig?p2=cfe/branches/Apple/williamson/lib/Analysis/CFG.cpp.orig&p1=cfe/branches/Apple/williamson/lib/Analysis/CFG.cpp&r1=111416&r2=111417&rev=111417&view=diff
==============================================================================
(empty)
Modified: cfe/branches/Apple/williamson/test/Analysis/dead-stores.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/williamson/test/Analysis/dead-stores.c?rev=111417&r1=111416&r2=111417&view=diff
==============================================================================
--- cfe/branches/Apple/williamson/test/Analysis/dead-stores.c (original)
+++ cfe/branches/Apple/williamson/test/Analysis/dead-stores.c Wed Aug 18 15:33:55 2010
@@ -462,3 +462,27 @@
}
}
+// <rdar://problem/8320674> NullStmts followed by do...while() can lead to disconnected CFG
+//
+// This previously caused bogus dead-stores warnings because the body of the first do...while was
+// disconnected from the entry of the function.
+typedef struct { float r; float i; } s_rdar8320674;
+typedef struct { s_rdar8320674 x[1]; } s2_rdar8320674;
+
+void rdar8320674(s_rdar8320674 *z, unsigned y, s2_rdar8320674 *st, int m)
+{
+ s_rdar8320674 * z2;
+ s_rdar8320674 * tw1 = st->x;
+ s_rdar8320674 t;
+ z2 = z + m;
+ do{
+ ; ;
+ do{ (t).r = (*z2).r*(*tw1).r - (*z2).i*(*tw1).i; (t).i = (*z2).r*(*tw1).i + (*z2).i*(*tw1).r; }while(0);
+ tw1 += y;
+ do { (*z2).r=(*z).r-(t).r; (*z2).i=(*z).i-(t).i; }while(0);
+ do { (*z).r += (t).r; (*z).i += (t).i; }while(0);
+ ++z2;
+ ++z;
+ }while (--m);
+}
+
More information about the llvm-branch-commits
mailing list