This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Prevent generation of globals in non-constant address space for OpenCL
ClosedPublic

Authored by Anastasia on Nov 24 2016, 10:05 AM.

Details

Reviewers
yaxunl
Summary

Clang performs some optimizations/shortcuts for const qualified aggregate variables while generating them on the stack. It bypasses the generation of alloca instructions and their uses are replaced by accesses to the initializer global variable directly instead.

In OpenCL we can only do this if a variable is qualified with a constant address space.

Diff Detail

Event Timeline

Anastasia updated this revision to Diff 79244.Nov 24 2016, 10:05 AM
Anastasia retitled this revision from to [OpenCL] Prevent generation of globals in non-constant address space for OpenCL.
Anastasia updated this object.
Anastasia added a reviewer: yaxunl.
Anastasia added a subscriber: cfe-commits.
yaxunl added inline comments.Nov 28 2016, 6:58 AM
lib/CodeGen/CGDecl.cpp
954

can we merge this if with the above if?

Anastasia updated this revision to Diff 79403.Nov 28 2016, 7:41 AM

Merged if statements into one!

Anastasia marked an inline comment as done.Nov 28 2016, 7:42 AM
yaxunl accepted this revision.Nov 28 2016, 8:37 AM
yaxunl edited edge metadata.

LGTM. Thanks!

This revision is now accepted and ready to land.Nov 28 2016, 8:37 AM
Anastasia closed this revision.Nov 30 2016, 7:47 AM

Committed in r288163.