summaryrefslogtreecommitdiff
path: root/clang/INPUTS/cfg-big-switch.c
diff options
context:
space:
mode:
authorZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-09-24 09:58:17 +1000
committerZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-09-24 09:58:17 +1000
commit222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch)
tree7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/INPUTS/cfg-big-switch.c
parent3d206f03985b50beacae843d880bccdc91a9f424 (diff)
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/INPUTS/cfg-big-switch.c')
-rw-r--r--clang/INPUTS/cfg-big-switch.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/INPUTS/cfg-big-switch.c b/clang/INPUTS/cfg-big-switch.c
new file mode 100644
index 0000000..a48b51a
--- /dev/null
+++ b/clang/INPUTS/cfg-big-switch.c
@@ -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;
+}