Skip to content

Commit 5566988

Browse files
committed
[PATCH] Fix assertion due to blocks
1 parent 5715ced commit 5566988

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ set(TARGET_NAME ${COMMON_CLANG_LIBRARY_NAME}${BUILD_PLATFORM} )
8181
if(NOT USE_PREBUILT_LLVM)
8282
set(TARGET_BRANCH "ocl-open-80")
8383
set(CLANG_SOURCE_DIR ${LLVM_SOURCE_DIR}/tools/clang)
84-
set(CLANG_BASE_REVISION e7524422bf4ee02f80a528547cde7e45b30c83dc)
84+
set(CLANG_BASE_REVISION a03da8be08a208122e292016cb6cea1f30229677)
8585

8686
set(SPIRV_SOURCE_DIR ${LLVM_SOURCE_DIR}/projects/llvm-spirv)
8787
set(SPIRV_BASE_REVISION 0650ff887b5ef00066e6a0527bab592dafd59c83)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
From 29e2813a2ab7d5569860bb07892dfef7b5374d96 Mon Sep 17 00:00:00 2001
2+
From: Yaxun Liu <[email protected]>
3+
Date: Tue, 26 Feb 2019 16:20:41 +0000
4+
Subject: [PATCH] [OpenCL] Fix assertion due to blocks
5+
6+
A recent change caused assertion in CodeGenFunction::EmitBlockCallExpr when a block is called.
7+
8+
There is code
9+
10+
Func = CGM.getOpenCLRuntime().getInvokeFunction(E->getCallee());
11+
getCalleeDecl calls Expr::getReferencedDeclOfCallee, which does not handle
12+
BlockExpr and returns nullptr, which causes isa to assert.
13+
14+
This patch fixes that.
15+
16+
Differential Revision: https://reviews.llvm.org/D58658
17+
18+
19+
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354893 91177308-0d34-0410-b5e6-96231b3b80d8
20+
---
21+
lib/AST/Expr.cpp | 2 ++
22+
test/CodeGenOpenCL/blocks.cl | 6 ++++++
23+
2 files changed, 8 insertions(+)
24+
25+
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
26+
index aef1eab..85690c7 100644
27+
--- a/lib/AST/Expr.cpp
28+
+++ b/lib/AST/Expr.cpp
29+
@@ -1358,6 +1358,8 @@ Decl *Expr::getReferencedDeclOfCallee() {
30+
return DRE->getDecl();
31+
if (MemberExpr *ME = dyn_cast<MemberExpr>(CEE))
32+
return ME->getMemberDecl();
33+
+ if (auto *BE = dyn_cast<BlockExpr>(CEE))
34+
+ return BE->getBlockDecl();
35+
36+
return nullptr;
37+
}
38+
diff --git a/test/CodeGenOpenCL/blocks.cl b/test/CodeGenOpenCL/blocks.cl
39+
index ab5a2c6..c3e2685 100644
40+
--- a/test/CodeGenOpenCL/blocks.cl
41+
+++ b/test/CodeGenOpenCL/blocks.cl
42+
@@ -90,6 +90,12 @@ int get42() {
43+
return blockArgFunc(^{return 42;});
44+
}
45+
46+
+// COMMON-LABEL: define {{.*}}@call_block
47+
+// call {{.*}}@__call_block_block_invoke
48+
+int call_block() {
49+
+ return ^int(int num) { return num; } (11);
50+
+}
51+
+
52+
// CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__size"
53+
// CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__align"
54+
55+
--
56+
1.8.3.1
57+

0 commit comments

Comments
 (0)