@@ -130,10 +130,11 @@ void CGOpenCLRuntime::recordBlockInfo(const BlockExpr *E,
130130 assert (!EnqueuedBlockMap.contains (E) && " Block expression emitted twice" );
131131 assert (isa<llvm::Function>(InvokeF) && " Invalid invoke function" );
132132 assert (Block->getType ()->isPointerTy () && " Invalid block literal type" );
133- EnqueuedBlockMap[E].InvokeFunc = InvokeF;
134- EnqueuedBlockMap[E].BlockArg = Block;
135- EnqueuedBlockMap[E].BlockTy = BlockTy;
136- EnqueuedBlockMap[E].KernelHandle = nullptr ;
133+ EnqueuedBlockInfo &BlockInfo = EnqueuedBlockMap[E];
134+ BlockInfo.InvokeFunc = InvokeF;
135+ BlockInfo.BlockArg = Block;
136+ BlockInfo.BlockTy = BlockTy;
137+ BlockInfo.KernelHandle = nullptr ;
137138}
138139
139140llvm::Function *CGOpenCLRuntime::getInvokeFunction (const Expr *E) {
@@ -148,17 +149,19 @@ CGOpenCLRuntime::emitOpenCLEnqueuedBlock(CodeGenFunction &CGF, const Expr *E) {
148149 // to get the block literal.
149150 const BlockExpr *Block = getBlockExpr (E);
150151
151- assert (EnqueuedBlockMap.contains (Block) && " Block expression not emitted" );
152+ auto It = EnqueuedBlockMap.find (Block);
153+ assert (It != EnqueuedBlockMap.end () && " Block expression not emitted" );
154+ EnqueuedBlockInfo &BlockInfo = It->second ;
152155
153156 // Do not emit the block wrapper again if it has been emitted.
154- if (EnqueuedBlockMap[Block] .KernelHandle ) {
155- return EnqueuedBlockMap[Block] ;
157+ if (BlockInfo .KernelHandle ) {
158+ return BlockInfo ;
156159 }
157160
158161 auto *F = CGF.getTargetHooks ().createEnqueuedBlockKernel (
159- CGF, EnqueuedBlockMap[Block] .InvokeFunc , EnqueuedBlockMap[Block] .BlockTy );
162+ CGF, BlockInfo .InvokeFunc , BlockInfo .BlockTy );
160163
161164 // The common part of the post-processing of the kernel goes here.
162- EnqueuedBlockMap[Block] .KernelHandle = F;
163- return EnqueuedBlockMap[Block] ;
165+ BlockInfo .KernelHandle = F;
166+ return BlockInfo ;
164167}
0 commit comments