summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/global-blocks-win32.c
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2018-08-09 12:42:36 +0000
committerHans Wennborg <hans@hanshq.net>2018-08-09 12:42:36 +0000
commit4d989f7996d43d3c4d01e057772bd279a9e81afc (patch)
treee0fdc6e223f90e307dbc4855b02256b7025161fd /clang/test/CodeGen/global-blocks-win32.c
parent850d801d577ba2b37b1e208df402b89606d01d11 (diff)
downloadbcm5719-llvm-4d989f7996d43d3c4d01e057772bd279a9e81afc.tar.gz
bcm5719-llvm-4d989f7996d43d3c4d01e057772bd279a9e81afc.zip
Merging r339317:
------------------------------------------------------------------------ r339317 | theraven | 2018-08-09 10:02:42 +0200 (Thu, 09 Aug 2018) | 15 lines Correctly initialise global blocks on Windows. Summary: Windows does not allow globals to be initialised to point to globals in another DLL. Exported globals may be referenced only from code. Work around this by creating an initialiser that runs in early library initialisation and sets the isa pointer. Reviewers: rjmccall Reviewed By: rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50436 ------------------------------------------------------------------------ llvm-svn: 339339
Diffstat (limited to 'clang/test/CodeGen/global-blocks-win32.c')
-rw-r--r--clang/test/CodeGen/global-blocks-win32.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/test/CodeGen/global-blocks-win32.c b/clang/test/CodeGen/global-blocks-win32.c
new file mode 100644
index 00000000000..7a66c924b42
--- /dev/null
+++ b/clang/test/CodeGen/global-blocks-win32.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fblocks -triple i386-pc-windows-msvc %s -emit-llvm -o - -fblocks | FileCheck %s
+
+
+int (^x)(void) = ^() { return 21; };
+
+
+// Check that the block literal is emitted with a null isa pointer
+// CHECK: @__block_literal_global = internal global { i8**, i32, i32, i8*, %struct.__block_descriptor* } { i8** null,
+
+// Check that _NSConcreteGlobalBlock has the correct dllimport specifier.
+// CHECK: @_NSConcreteGlobalBlock = external dllimport global i8*
+// Check that we create an initialiser pointer in the correct section (early library initialisation).
+// CHECK: @.block_isa_init_ptr = internal constant void ()* @.block_isa_init, section ".CRT$XCLa"
+
+// Check that we emit an initialiser for it.
+// CHECK: define internal void @.block_isa_init() {
+// CHECK: store i8** @_NSConcreteGlobalBlock, i8*** getelementptr inbounds ({ i8**, i32, i32, i8*, %struct.__block_descriptor* }, { i8**, i32, i32, i8*, %struct.__block_descriptor* }* @__block_literal_global, i32 0, i32 0), align 4
+
OpenPOWER on IntegriCloud