carries_dependency attribute


I was wondering what is the semantic of the carries_dependency attribute.

On it says some suspicious things to me (but I am probably interpreting that wrong, sorry about that):

The carries_dependency attribute specifies dependency propagation into and out of functions.

Where can it be placed? (on function declaration and/or definition?)
What are its parameters? (none?)

When specified on a function or Objective-C method, the carries_dependency attribute means that the return value carries a dependency out of the function, so that the implementation need not constrain ordering upon return from that function.

I was under the impression that a dependency was an ordering constraint we want to enforce… What are we trying to say here?

Implementations of the function and its caller may choose to preserve dependencies instead of emitting memory ordering instructions such as fences.

So, if that attribute is not here, we do not need to preserve dependencies as long as we emit a memory ordering instruction?

Note, this attribute does not change the meaning of the program, but may result in generation of more efficient code.

I am almost certain of missing something here, else it does not make sense…


It was supposed to be part of the "consume" atomic memory ordering, but in practice clang simply ignores it.