This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Simplify LLVM IR generated for OpenCL blocks
ClosedPublic

Authored by AlexeySotkin on Feb 19 2019, 8:35 AM.

Details

Summary

Emit direct call of block invoke functions when possible, i.e. in case the
block is not passed as a function argument.
Also doing some refactoring of CodeGenFunction::EmitBlockCallExpr()

Diff Detail

Repository
rC Clang

Event Timeline

AlexeySotkin created this revision.Feb 19 2019, 8:35 AM

Fix ObjC lit tests failure

Anastasia added inline comments.Feb 20 2019, 2:39 AM
lib/CodeGen/CGBlocks.cpp
1274

I think it's reasonable enough... if we restrict blocks as parameters in the spec later it should be easy enough to modify this code.

lib/CodeGen/CGOpenCLRuntime.cpp
131

Btw, does this handle the case when we assign a variable multiple time? I was just wondering if we need a loop somewhere?

I.e. does something like this work now:

typedef void (^bl_t)(local void *);

bl_t a = ...;
bl_t b = a;
bl_t c = b;

c();
enqueue_kernel(... c, ...);

Fix resolving of block invoke function in case of sequence of assignments.

AlexeySotkin marked an inline comment as done.Feb 20 2019, 6:58 AM
AlexeySotkin added inline comments.
lib/CodeGen/CGOpenCLRuntime.cpp
131

You are right, we need a loop. Now it works.

Anastasia accepted this revision.Feb 20 2019, 7:46 AM

LGTM! Great! Thanks!

This revision is now accepted and ready to land.Feb 20 2019, 7:46 AM
This revision was automatically updated to reflect the committed changes.