[cfe-commits] r134698 - in /cfe/trunk/INPUTS: cfg-big-switch.c cfg-long-chain1.c cfg-long-chain2.c cfg-long-chain3.c cfg-nested-switches.c

Chandler Carruth chandlerc at gmail.com
Fri Jul 8 04:20:52 PDT 2011


Author: chandlerc
Date: Fri Jul  8 06:20:51 2011
New Revision: 134698

URL: http://llvm.org/viewvc/llvm-project?rev=134698&view=rev
Log:
Add several CFG-stress-testing input source files. These use the
preprocessor to build up very large CFGs in various shapes that can
produce different algorithmic behavior in CFG-walking code.

Added:
    cfe/trunk/INPUTS/cfg-big-switch.c
    cfe/trunk/INPUTS/cfg-long-chain1.c
    cfe/trunk/INPUTS/cfg-long-chain2.c
    cfe/trunk/INPUTS/cfg-long-chain3.c
    cfe/trunk/INPUTS/cfg-nested-switches.c

Added: cfe/trunk/INPUTS/cfg-big-switch.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/INPUTS/cfg-big-switch.c?rev=134698&view=auto
==============================================================================
--- cfe/trunk/INPUTS/cfg-big-switch.c (added)
+++ cfe/trunk/INPUTS/cfg-big-switch.c Fri Jul  8 06:20:51 2011
@@ -0,0 +1,27 @@
+#define EXPAND_2_CASES(i, x, y)    CASE(i, x, y);             CASE(i + 1, x, y);
+#define EXPAND_4_CASES(i, x, y)    EXPAND_2_CASES(i, x, y)    EXPAND_2_CASES(i + 2, x, y)
+#define EXPAND_8_CASES(i, x, y)    EXPAND_4_CASES(i, x, y)    EXPAND_4_CASES(i + 4, x, y)
+#define EXPAND_16_CASES(i, x, y)   EXPAND_8_CASES(i, x, y)    EXPAND_8_CASES(i + 8, x, y)
+#define EXPAND_32_CASES(i, x, y)   EXPAND_16_CASES(i, x, y)   EXPAND_16_CASES(i + 16, x, y)
+#define EXPAND_64_CASES(i, x, y)   EXPAND_32_CASES(i, x, y)   EXPAND_32_CASES(i + 32, x, y)
+#define EXPAND_128_CASES(i, x, y)  EXPAND_64_CASES(i, x, y)   EXPAND_64_CASES(i + 64, x, y)
+#define EXPAND_256_CASES(i, x, y)  EXPAND_128_CASES(i, x, y)  EXPAND_128_CASES(i + 128, x, y)
+#define EXPAND_512_CASES(i, x, y)  EXPAND_256_CASES(i, x, y)  EXPAND_256_CASES(i + 256, x, y)
+#define EXPAND_1024_CASES(i, x, y) EXPAND_512_CASES(i, x, y)  EXPAND_512_CASES(i + 512, x, y)
+#define EXPAND_2048_CASES(i, x, y) EXPAND_1024_CASES(i, x, y) EXPAND_1024_CASES(i + 1024, x, y)
+#define EXPAND_4096_CASES(i, x, y) EXPAND_2048_CASES(i, x, y) EXPAND_2048_CASES(i + 2048, x, y)
+
+// This has a *monstrous* single fan-out in the CFG, across 8000 blocks inside
+// the while loop.
+unsigned cfg_big_switch(int x) {
+  unsigned y = 0;
+  while (x > 0) {
+    switch(x) {
+#define CASE(i, x, y) \
+      case i: { int case_var = 3*x + i; y += case_var - 1; break; }
+EXPAND_4096_CASES(0, x, y);
+    }
+    --x;
+  }
+  return y;
+}

Added: cfe/trunk/INPUTS/cfg-long-chain1.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/INPUTS/cfg-long-chain1.c?rev=134698&view=auto
==============================================================================
--- cfe/trunk/INPUTS/cfg-long-chain1.c (added)
+++ cfe/trunk/INPUTS/cfg-long-chain1.c Fri Jul  8 06:20:51 2011
@@ -0,0 +1,20 @@
+#define EXPAND_2_BRANCHES(i, x, y)    BRANCH(i, x, y);              BRANCH(i + 1, x, y);
+#define EXPAND_4_BRANCHES(i, x, y)    EXPAND_2_BRANCHES(i, x, y)    EXPAND_2_BRANCHES(i + 2, x, y)
+#define EXPAND_8_BRANCHES(i, x, y)    EXPAND_4_BRANCHES(i, x, y)    EXPAND_4_BRANCHES(i + 4, x, y)
+#define EXPAND_16_BRANCHES(i, x, y)   EXPAND_8_BRANCHES(i, x, y)    EXPAND_8_BRANCHES(i + 8, x, y)
+#define EXPAND_32_BRANCHES(i, x, y)   EXPAND_16_BRANCHES(i, x, y)   EXPAND_16_BRANCHES(i + 16, x, y)
+#define EXPAND_64_BRANCHES(i, x, y)   EXPAND_32_BRANCHES(i, x, y)   EXPAND_32_BRANCHES(i + 32, x, y)
+#define EXPAND_128_BRANCHES(i, x, y)  EXPAND_64_BRANCHES(i, x, y)   EXPAND_64_BRANCHES(i + 64, x, y)
+#define EXPAND_256_BRANCHES(i, x, y)  EXPAND_128_BRANCHES(i, x, y)  EXPAND_128_BRANCHES(i + 128, x, y)
+#define EXPAND_512_BRANCHES(i, x, y)  EXPAND_256_BRANCHES(i, x, y)  EXPAND_256_BRANCHES(i + 256, x, y)
+#define EXPAND_1024_BRANCHES(i, x, y) EXPAND_512_BRANCHES(i, x, y)  EXPAND_512_BRANCHES(i + 512, x, y)
+#define EXPAND_2048_BRANCHES(i, x, y) EXPAND_1024_BRANCHES(i, x, y) EXPAND_1024_BRANCHES(i + 1024, x, y)
+#define EXPAND_4096_BRANCHES(i, x, y) EXPAND_2048_BRANCHES(i, x, y) EXPAND_2048_BRANCHES(i + 2048, x, y)
+
+unsigned cfg_long_chain_single_exit(unsigned x) {
+  unsigned y = 0;
+#define BRANCH(i, x, y) if ((x % 13171) < i) { int var = x / 13171; y ^= var; }
+  EXPAND_4096_BRANCHES(1, x, y);
+#undef BRANCH
+  return y;
+}

Added: cfe/trunk/INPUTS/cfg-long-chain2.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/INPUTS/cfg-long-chain2.c?rev=134698&view=auto
==============================================================================
--- cfe/trunk/INPUTS/cfg-long-chain2.c (added)
+++ cfe/trunk/INPUTS/cfg-long-chain2.c Fri Jul  8 06:20:51 2011
@@ -0,0 +1,20 @@
+#define EXPAND_2_BRANCHES(i, x, y)    BRANCH(i, x, y);              BRANCH(i + 1, x, y);
+#define EXPAND_4_BRANCHES(i, x, y)    EXPAND_2_BRANCHES(i, x, y)    EXPAND_2_BRANCHES(i + 2, x, y)
+#define EXPAND_8_BRANCHES(i, x, y)    EXPAND_4_BRANCHES(i, x, y)    EXPAND_4_BRANCHES(i + 4, x, y)
+#define EXPAND_16_BRANCHES(i, x, y)   EXPAND_8_BRANCHES(i, x, y)    EXPAND_8_BRANCHES(i + 8, x, y)
+#define EXPAND_32_BRANCHES(i, x, y)   EXPAND_16_BRANCHES(i, x, y)   EXPAND_16_BRANCHES(i + 16, x, y)
+#define EXPAND_64_BRANCHES(i, x, y)   EXPAND_32_BRANCHES(i, x, y)   EXPAND_32_BRANCHES(i + 32, x, y)
+#define EXPAND_128_BRANCHES(i, x, y)  EXPAND_64_BRANCHES(i, x, y)   EXPAND_64_BRANCHES(i + 64, x, y)
+#define EXPAND_256_BRANCHES(i, x, y)  EXPAND_128_BRANCHES(i, x, y)  EXPAND_128_BRANCHES(i + 128, x, y)
+#define EXPAND_512_BRANCHES(i, x, y)  EXPAND_256_BRANCHES(i, x, y)  EXPAND_256_BRANCHES(i + 256, x, y)
+#define EXPAND_1024_BRANCHES(i, x, y) EXPAND_512_BRANCHES(i, x, y)  EXPAND_512_BRANCHES(i + 512, x, y)
+#define EXPAND_2048_BRANCHES(i, x, y) EXPAND_1024_BRANCHES(i, x, y) EXPAND_1024_BRANCHES(i + 1024, x, y)
+#define EXPAND_4096_BRANCHES(i, x, y) EXPAND_2048_BRANCHES(i, x, y) EXPAND_2048_BRANCHES(i + 2048, x, y)
+
+unsigned cfg_long_chain_multiple_exit(unsigned x) {
+  unsigned y = 0;
+#define BRANCH(i, x, y) if (((x % 13171) + ++y) < i) { int var = x / 13171 + y; return var; } 
+  EXPAND_4096_BRANCHES(1, x, y);
+#undef BRANCH
+  return 42;
+}

Added: cfe/trunk/INPUTS/cfg-long-chain3.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/INPUTS/cfg-long-chain3.c?rev=134698&view=auto
==============================================================================
--- cfe/trunk/INPUTS/cfg-long-chain3.c (added)
+++ cfe/trunk/INPUTS/cfg-long-chain3.c Fri Jul  8 06:20:51 2011
@@ -0,0 +1,21 @@
+#define EXPAND_2_BRANCHES(i, x, y)    BRANCH(i, x, y);              BRANCH(i + 1, x, y);
+#define EXPAND_4_BRANCHES(i, x, y)    EXPAND_2_BRANCHES(i, x, y)    EXPAND_2_BRANCHES(i + 2, x, y)
+#define EXPAND_8_BRANCHES(i, x, y)    EXPAND_4_BRANCHES(i, x, y)    EXPAND_4_BRANCHES(i + 4, x, y)
+#define EXPAND_16_BRANCHES(i, x, y)   EXPAND_8_BRANCHES(i, x, y)    EXPAND_8_BRANCHES(i + 8, x, y)
+#define EXPAND_32_BRANCHES(i, x, y)   EXPAND_16_BRANCHES(i, x, y)   EXPAND_16_BRANCHES(i + 16, x, y)
+#define EXPAND_64_BRANCHES(i, x, y)   EXPAND_32_BRANCHES(i, x, y)   EXPAND_32_BRANCHES(i + 32, x, y)
+#define EXPAND_128_BRANCHES(i, x, y)  EXPAND_64_BRANCHES(i, x, y)   EXPAND_64_BRANCHES(i + 64, x, y)
+#define EXPAND_256_BRANCHES(i, x, y)  EXPAND_128_BRANCHES(i, x, y)  EXPAND_128_BRANCHES(i + 128, x, y)
+#define EXPAND_512_BRANCHES(i, x, y)  EXPAND_256_BRANCHES(i, x, y)  EXPAND_256_BRANCHES(i + 256, x, y)
+#define EXPAND_1024_BRANCHES(i, x, y) EXPAND_512_BRANCHES(i, x, y)  EXPAND_512_BRANCHES(i + 512, x, y)
+#define EXPAND_2048_BRANCHES(i, x, y) EXPAND_1024_BRANCHES(i, x, y) EXPAND_1024_BRANCHES(i + 1024, x, y)
+#define EXPAND_4096_BRANCHES(i, x, y) EXPAND_2048_BRANCHES(i, x, y) EXPAND_2048_BRANCHES(i + 2048, x, y)
+
+unsigned cfg_long_chain_many_preds(unsigned x) {
+  unsigned y = 0;
+#define BRANCH(i, x, y) if ((x % 13171) < i) { int var = x / 13171; y ^= var; } else
+  EXPAND_4096_BRANCHES(1, x, y);
+#undef BRANCH
+  int var = x / 13171; y^= var;
+  return y;
+}

Added: cfe/trunk/INPUTS/cfg-nested-switches.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/INPUTS/cfg-nested-switches.c?rev=134698&view=auto
==============================================================================
--- cfe/trunk/INPUTS/cfg-nested-switches.c (added)
+++ cfe/trunk/INPUTS/cfg-nested-switches.c Fri Jul  8 06:20:51 2011
@@ -0,0 +1,36 @@
+#define EXPAND_2_INNER_CASES(i, x, y)    INNER_CASE(i, x, y);             INNER_CASE(i + 1, x, y);
+#define EXPAND_4_INNER_CASES(i, x, y)    EXPAND_2_INNER_CASES(i, x, y)    EXPAND_2_INNER_CASES(i + 2, x, y)
+#define EXPAND_8_INNER_CASES(i, x, y)    EXPAND_4_INNER_CASES(i, x, y)    EXPAND_4_INNER_CASES(i + 4, x, y)
+#define EXPAND_16_INNER_CASES(i, x, y)   EXPAND_8_INNER_CASES(i, x, y)    EXPAND_8_INNER_CASES(i + 8, x, y)
+#define EXPAND_32_INNER_CASES(i, x, y)   EXPAND_16_INNER_CASES(i, x, y)   EXPAND_16_INNER_CASES(i + 16, x, y)
+#define EXPAND_64_INNER_CASES(i, x, y)   EXPAND_32_INNER_CASES(i, x, y)   EXPAND_32_INNER_CASES(i + 32, x, y)
+
+#define EXPAND_2_OUTER_CASES(i, x, y)    OUTER_CASE(i, x, y);             OUTER_CASE(i + 1, x, y);
+#define EXPAND_4_OUTER_CASES(i, x, y)    EXPAND_2_OUTER_CASES(i, x, y)    EXPAND_2_OUTER_CASES(i + 2, x, y)
+#define EXPAND_8_OUTER_CASES(i, x, y)    EXPAND_4_OUTER_CASES(i, x, y)    EXPAND_4_OUTER_CASES(i + 4, x, y)
+#define EXPAND_16_OUTER_CASES(i, x, y)   EXPAND_8_OUTER_CASES(i, x, y)    EXPAND_8_OUTER_CASES(i + 8, x, y)
+#define EXPAND_32_OUTER_CASES(i, x, y)   EXPAND_16_OUTER_CASES(i, x, y)   EXPAND_16_OUTER_CASES(i + 16, x, y)
+#define EXPAND_64_OUTER_CASES(i, x, y)   EXPAND_32_OUTER_CASES(i, x, y)   EXPAND_32_OUTER_CASES(i + 32, x, y)
+
+// Rather than a single monstrous fan-out, this fans out in smaller increments,
+// but to a similar size.
+unsigned cfg_nested_switch(int x) {
+  unsigned y = 0;
+  while (x > 0) {
+    switch (x) {
+#define INNER_CASE(i, x, y) \
+          case i: { int case_var = 3*x + i; y += case_var - 1; break; }
+#define OUTER_CASE(i, x, y) \
+      case i: { \
+        int case_var = y >> 8; \
+        switch (case_var) { \
+          EXPAND_64_INNER_CASES(0, x, y); \
+        } \
+        break; \
+      }
+EXPAND_64_OUTER_CASES(0, x, y);
+    }
+    --x;
+  }
+  return y;
+}





More information about the cfe-commits mailing list