r326937 ("[OpenCL] Remove block invoke function from emitted block
literal struct", 2018-03-07) broke block argument handling. In
particular the commit was causing a crash during code generation, see
the discussion in https://reviews.llvm.org/D43783 .
The offending commit has just been reverted; add a test to avoid
breaking this again in the future.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343583
91177308-0d34-0410-b5e6-
96231b3b80d8
// COMMON-NOT: define{{.*}}@__foo_block_invoke_kernel
+// Test that we support block arguments.
+// COMMON-LABEL: define {{.*}} @blockArgFunc
+int blockArgFunc(int (^ bl)(void)) {
+ return bl();
+}
+
+// COMMON-LABEL: define {{.*}} @get21
+// COMMON: define {{.*}} @__get21_block_invoke
+// COMMON: ret i32 21
+int get21() {
+ return blockArgFunc(^{return 21;});
+}
+
+// COMMON-LABEL: define {{.*}} @get42
+// COMMON: define {{.*}} @__get42_block_invoke
+// COMMON: ret i32 42
+int get42() {
+ return blockArgFunc(^{return 42;});
+}
+
// CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__size"
// CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__align"