aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/backend/loop2.c
diff options
authorXi Wang <xi.wang@gmail.com>2013-05-16 02:33:46 -0400
committerPekka Enberg <penberg@kernel.org>2013-05-18 10:33:55 +0300
commit0448f78f5fae84b8a9c1358129a03ea24e593b34 (patch)
tree68ff78614b2a9bc516edd388574f0f3a3954a6f1 /validation/backend/loop2.c
parent5449cfbfe55eea2a602a40122c122b5040d67243 (diff)
downloadsparse-dev-0448f78f5fae84b8a9c1358129a03ea24e593b34.tar.gz
sparse, llvm: fix phi generation
PHI in LLVM is different from that in sparse. LLVM requires PHI "for each predecessor basic block of the current block" even if the current block doesn't use it. It's tricky to correctly place PHI. This patch implements a simpler and safer strategy: 1) allocate an alloca for each phi, and 2) translate phi/phisrc to load/store alloca. LLVM optimizations will promote load/store to registers. Cc: Christopher Li <sparse@chrisli.org> Cc: Jeff Garzik <jgarzik@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Signed-off-by: Xi Wang <xi.wang@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'validation/backend/loop2.c')
-rw-r--r--validation/backend/loop2.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/validation/backend/loop2.c b/validation/backend/loop2.c
new file mode 100644
index 00000000..279af214
--- /dev/null
+++ b/validation/backend/loop2.c
@@ -0,0 +1,14 @@
+extern int op(void);
+
+static void test(void)
+{
+ int i;
+ for (i = 0; ; i++) {
+ op();
+ }
+}
+
+/*
+ * check-name: Loops with unused counter
+ * check-command: ./sparsec -c $file -o tmp.o
+ */