This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Change type of block pointer for OpenCL
ClosedPublic

Authored by AlexeySotkin on Feb 15 2019, 3:45 AM.

Details

Summary

For some reason OpenCL blocks in LLVM IR are represented as function pointers.
These pointers do not point to any real function and never get called. Actually
they point to some structure, which in turn contains pointer to the real block
invoke function.
This patch changes represntation of OpenCL blocks in LLVM IR from function
pointers to pointers to %struct.__block_literal_generic.
Such representation allows to avoid unnecessary bitcasts and simplifies
further processing (e.g. translation to SPIR-V ) of the module for targets
which do not support function pointers.

Diff Detail

Repository
rL LLVM

Event Timeline

AlexeySotkin created this revision.Feb 15 2019, 3:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 15 2019, 3:45 AM
Anastasia accepted this revision.Feb 18 2019, 7:35 AM

LGTM! Thanks! This totally makes sense! I think we inherited that from ObjC but never adapted fully. This change has low risk of breaking backwards compatibility but might need some minor update in tools.

This revision is now accepted and ready to land.Feb 18 2019, 7:35 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 19 2019, 7:21 AM