diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2014-02-22 16:59:24 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2014-02-22 16:59:24 +0000 |
commit | 7c19ab17c722288f47dfc887dec0405814bf304d (patch) | |
tree | a90abcc93e28e1d24c4025be0d2ba931b264d6c5 /clang/docs | |
parent | 9d2c15eff7edd220a3246ebedd2e502051e49844 (diff) | |
download | bcm5719-llvm-7c19ab17c722288f47dfc887dec0405814bf304d.tar.gz bcm5719-llvm-7c19ab17c722288f47dfc887dec0405814bf304d.zip |
Exposing the noduplicate attribute within Clang, which marks functions so that the optimizer does not duplicate code.
Patch thanks to Marcello Maggioni!
llvm-svn: 201941
Diffstat (limited to 'clang/docs')
-rw-r--r-- | clang/docs/AttributeReference.rst | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/clang/docs/AttributeReference.rst b/clang/docs/AttributeReference.rst index 1d41cb32cf6..84b5440ac30 100644 --- a/clang/docs/AttributeReference.rst +++ b/clang/docs/AttributeReference.rst @@ -558,6 +558,50 @@ caveats to this use of name mangling: Query for this feature with ``__has_extension(attribute_overloadable)``.
+noduplicate
+-----------
+.. csv-table:: Supported Syntaxes
+ :header: "GNU", "C++11", "__declspec", "Keyword"
+
+ "X","X","",""
+
+The ``noduplicate`` attribute can be placed on function declarations to control
+whether function calls to this function can be duplicated
+or not as a result of optimizations. This is required for the implementation
+of functions with certain special requirements, like the OpenCL "barrier",
+function that, depending on the hardware, might require to be run concurrently
+by all the threads that are currently executing in lockstep on the hardware.
+For example this attribute applied on the function "nodupfunc"
+avoids that this code:
+
+.. code-block:: c
+
+ void nodupfunc() __attribute__((noduplicate));
+ // Setting it as a C++11 attribute is also valid
+ // void nodupfunc() [[clang::noduplicate]];
+ void foo();
+ void bar();
+
+ nodupfunc();
+ if (a > n) {
+ foo();
+ } else {
+ bar();
+ }
+
+gets possibly modified by some optimization into code similar to this:
+
+.. code-block:: c
+
+ if (a > n) {
+ nodupfunc();
+ foo();
+ } else {
+ nodupfunc();
+ bar();
+ }
+
+where the barrier call is duplicated and sunk into the two branches of the condition.
Variable Attributes
===================
|