[llvm-dev] Memory scope proposal

Pekka Jääskeläinen via llvm-dev llvm-dev at lists.llvm.org
Wed May 18 01:18:53 PDT 2016


Hi all,

On 02.05.2016 17:46, Tom Stellard via llvm-dev wrote:
>> Why not going with a metadata attachment directly and kill the "singlethread" keyword? Something like:
>> >Something like:
>> >
>> >  cmpxchg i32* %addr, i32 42, i32 0 monotonic monotonic, 3, !memory.scope{!42}
>> >  cmpxchg i32* %addr, i32 42, i32 0 monotonic monotonic, 3, !memory.scope{!43}
>> >
>> >...
>> >
>> >!42 = !{"singlethread"}
>> >!43 = !{"L2"}
>> >
>> >
>> >I also avoids manipulating/pruning the global map, and target won't depend on integer to keep bitcode compatibility.
>> >
>> >
> This seems like it will work assuming that promoting something like "L2" to the
> most conservative memory scope is legal (this is what would have to happen
> if the metadata was dropped).  Are there any targets where this type of'
> promotion would be illegal?

+1

Sorry to enter this discussion so late, but in my opinion this
is a very good non-intrusive starting point solution.

Implementing it as a MD with the assumption of there being a safe
conservative memory scope to fall back to (in case the MD gets
stripped off for some reason) converts it to a mere
optimization hint without the need to touch LLVM IR instruction semantics.

Also, as it's only a MD, if we encounter a need to extend it later 
towards a more integrated solution (or a mechanism to support
targets where this scheme is not feasible), we can more easily do so.

BR,
-- 
Pekka


More information about the llvm-dev mailing list