[PATCH] Add NoDuplicate attribute to clang (2nd try)

Marcello Maggioni hayarms at gmail.com
Fri Feb 21 12:31:00 PST 2014


Hi everybody,

back in November I made a patch that added the noduplicate attribute to
Clang (original discussion here
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20131118/093647.html).
After passing multiple reviews in the end I went in holiday and the
patch got lost and not committed :P

So here I try again to get this patch committed. The patch is needed by
some OpenCL implementers , because it permits to mark functions as "Not
duplicable" by optimization passes. (in the sense that function calls to
the function cannot be duplicated).
Some functions require that optimization that convert code like this:

nodupfunc();
if (a < n) {
  foo();
} else {
  bar();
}

into this

if (a < n) {
  nodupfunc();
  foo();
} else {
  nodupfunc();
  bar();
}

do not consider the function call to "nodupfunc" for optimization. If the
"nodupfunc" would have been marked as "NoDuplicate" the optimization
wouldn't have performed the sinking and duplication of the function call.
Typical examples of functions that requires this are some implementations
of the OpenCL barrier() function.

That said, the patch is basically the same to the last one I posted back in
november, updated to work with the latest clang code and I also added
documentation for the new attribute as suggested by Richard Smith in one of
the last messages.

The patch is split in two. One contains the code and one the tests for the
new attribute.

If somebody can review it I'd appreciate :) I also don't have commit
access, so I would need someone to commit it for me if it is fine.

Cheers,
Marcello
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140221/613f80be/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang_noduplicate_tests.patch
Type: text/x-patch
Size: 1740 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140221/613f80be/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang_noduplicatev3.patch
Type: text/x-patch
Size: 6906 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140221/613f80be/attachment-0001.bin>


More information about the cfe-commits mailing list