From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/CodeGen/2009-01-05-BlockInlining.c | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 clang/test/CodeGen/2009-01-05-BlockInlining.c (limited to 'clang/test/CodeGen/2009-01-05-BlockInlining.c') diff --git a/clang/test/CodeGen/2009-01-05-BlockInlining.c b/clang/test/CodeGen/2009-01-05-BlockInlining.c new file mode 100644 index 0000000..2ae9b70 --- /dev/null +++ b/clang/test/CodeGen/2009-01-05-BlockInlining.c @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 %s -emit-llvm -fblocks -o - | FileCheck %s +// rdar://5865221 + +// These will be inlined by the optimizers provided the block descriptors +// and block literals are internal constants. +// CHECK: @__block_descriptor_tmp = internal constant +// CHECK: @__block_literal_global = internal constant +// CHECK: @__block_descriptor_tmp1 = internal constant +// CHECK: @__block_literal_global2 = internal constant +static int fun(int x) { + return x+1; +} + +static int block(int x) { + return (^(int x){return x+1;})(x); +} + +static void print(int result) { + printf("%d\n", result); +} + +int main (int argc, const char * argv[]) { + int x = argc-1; + print(fun(x)); + print(block(x)); + int (^block_inline)(int) = ^(int x){return x+1;}; + print(block_inline(x)); + return 0; +} -- cgit v1.2.3