[PATCH] D58658: [OpenCL] Fix assertion due to blocks
Yaxun Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 25 17:39:49 PST 2019
yaxunl created this revision.
yaxunl added a reviewer: Anastasia.
Herald added subscribers: kristof.beyls, javed.absar.
A recent change caused assertion in CodeGenFunction::EmitBlockCallExpr when a block is called.
There is code
if (!isa<ParmVarDecl>(E->getCalleeDecl()))
Func = CGM.getOpenCLRuntime().getInvokeFunction(E->getCallee());
getCalleeDecl calls Expr::getReferencedDeclOfCallee, which does not handle
BlockExpr and returns nullptr, which causes isa to assert.
This patch fixes that.
https://reviews.llvm.org/D58658
Files:
lib/AST/Expr.cpp
test/CodeGenOpenCL/blocks.cl
Index: test/CodeGenOpenCL/blocks.cl
===================================================================
--- test/CodeGenOpenCL/blocks.cl
+++ test/CodeGenOpenCL/blocks.cl
@@ -90,6 +90,12 @@
return blockArgFunc(^{return 42;});
}
+// COMMON-LABEL: define {{.*}}@call_block
+// call {{.*}}@__call_block_block_invoke
+int call_block() {
+ return ^int(int num) { return num; } (11);
+}
+
// CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__size"
// CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__align"
Index: lib/AST/Expr.cpp
===================================================================
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -1358,6 +1358,8 @@
return DRE->getDecl();
if (MemberExpr *ME = dyn_cast<MemberExpr>(CEE))
return ME->getMemberDecl();
+ if (auto *BE = dyn_cast<BlockExpr>(CEE))
+ return BE->getBlockDecl();
return nullptr;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58658.188280.patch
Type: text/x-patch
Size: 894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190226/95243d81/attachment.bin>
More information about the cfe-commits
mailing list