diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2008-08-04 16:51:22 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2008-08-04 16:51:22 +0000 |
| commit | 88402ce8d064b53cf3d12e782a7b102a285e587e (patch) | |
| tree | 0cd99bc29bf98e54c68780860614b57c0c580e89 /clang/test/CodeGen/indirect-goto.c | |
| parent | 7adf07608847865d47fa50640c3b18007953c4aa (diff) | |
| download | bcm5719-llvm-88402ce8d064b53cf3d12e782a7b102a285e587e.tar.gz bcm5719-llvm-88402ce8d064b53cf3d12e782a7b102a285e587e.zip | |
Add CodeGen support for indirect goto.
- Follows emission scheme used by llvm-gcc, i.e. invent an id for
each label whose address is taken and replace each indirect goto by
a switch to each possible target.
- Currently we emit a switch for each indirect goto instead of
merging them as llvm-gcc does.
llvm-svn: 54318
Diffstat (limited to 'clang/test/CodeGen/indirect-goto.c')
| -rw-r--r-- | clang/test/CodeGen/indirect-goto.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/test/CodeGen/indirect-goto.c b/clang/test/CodeGen/indirect-goto.c new file mode 100644 index 00000000000..c0dc8a8298d --- /dev/null +++ b/clang/test/CodeGen/indirect-goto.c @@ -0,0 +1,20 @@ +// RUN: clang -emit-llvm-bc -o - %s | opt -std-compile-opts | llvm-dis > %t && +// RUN: grep "ret i32" %t | count 1 && +// RUN: grep "ret i32 210" %t | count 1 + +static int foo(unsigned i) { + const void *addrs[] = { &&L1, &&L2, &&L3, &&L4, &&L5 }; + int res = 1; + + goto *addrs[i]; + L5: res *= 11; + L4: res *= 7; + L3: res *= 5; + L2: res *= 3; + L1: res *= 2; + return res; +} + +int bar() { + return foo(3); +} |

