[llvm-commits] [test-suite] r90916 - /test-suite/trunk/SingleSource/UnitTests/2009-12-07-StructReturn.c
Stuart Hastings
stuart at apple.com
Tue Dec 8 16:56:54 PST 2009
Author: stuart
Date: Tue Dec 8 18:56:54 2009
New Revision: 90916
URL: http://llvm.org/viewvc/llvm-project?rev=90916&view=rev
Log:
Test case for r90914.
Added:
test-suite/trunk/SingleSource/UnitTests/2009-12-07-StructReturn.c
Added: test-suite/trunk/SingleSource/UnitTests/2009-12-07-StructReturn.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/2009-12-07-StructReturn.c?rev=90916&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/2009-12-07-StructReturn.c (added)
+++ test-suite/trunk/SingleSource/UnitTests/2009-12-07-StructReturn.c Tue Dec 8 18:56:54 2009
@@ -0,0 +1,35 @@
+/* <rdar://problem/7437022> */
+/* Just enough complexity to frighten the optimizer and expose a bug
+ in an ugly one-file testcase. */
+extern int printf(const char * __restrict, ...);
+extern void abort(void);
+typedef struct {
+ float ary[3];
+} foostruct;
+typedef struct {
+ foostruct foo;
+ float safe;
+} barstruct;
+barstruct bar_ary[4];
+float * __attribute__ ((__noinline__))
+ spooky(int i) {
+ bar_ary[i].safe = 142.0;
+ return &bar_ary[i].safe;
+}
+foostruct __attribute__ ((__noinline__))
+foobify(void) {
+ static barstruct my_static_foo = { {42.0, 42.0, 42.0}, /*safe=*/42.0 };
+ return my_static_foo.foo;
+}
+int
+main(int argc, char *argv[]) {
+ float *pf = spooky(0);
+ /* This should store exactly 96 bits. Some compilers stored 128
+ bits, clobbering beyond the end of the "foo" struct. */
+ bar_ary[0].foo = foobify();
+ if (*pf != 142.0) {
+ printf("error: store clobbered memory outside destination\n");
+ abort();
+ }
+ return 0;
+}
More information about the llvm-commits
mailing list