[llvm-dev] [RFC] Coroutine and pthread_self

Joerg Sonnenberger via llvm-dev llvm-dev at lists.llvm.org
Tue Nov 24 15:06:10 PST 2020


On Tue, Nov 24, 2020 at 04:52:32PM -0500, James Y Knight wrote:
> The contract for 'attribute((const))' as specified in GCC's docs may be
> open to your interpretation -- and in fact there has been a discussion on
> the GCC lists in the past about this topic: <
> https://gcc.gnu.org/legacy-ml/gcc/2015-09/msg00354.html>. But I think it's
> far too late to change to the semantics you propose. The actual semantics
> -- both as implemented and as depended upon in practice -- are that calls
> to an `__attribute__((const))` function can be arbitrarily moved, added, or
> removed within one thread of computation, but *not* globally across the
> entire program.
> 
> In any case, what it lowers to in Clang is the LLVM IR function-attribute
> readnone, which I'd argue is even more clearly correct to use on an LLVM
> function returning the address of a TLS global variable. Note that llvm
> infers that property via the FunctionAttrs pass, e.g. for this function:
> @t = thread_local global i32 0, align 4
> define i32* @foo() {
> ret i32* @t
> }

I don't see how that is a valid transformation under the definition in
the language reference either. I also don't believe that this is the
only situation it can happen, I would expect OpenMP to expose similar
issues.

Joerg


More information about the llvm-dev mailing list