[PATCH] D41761: Introduce llvm.nospeculateload intrinsic

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 5 11:45:42 PST 2018

reames added a comment.

A design variation on this which may be worth considering is to phrase this as a speculative use barrier.  That is, don't include the load at all, simply provide an intrinsic which guarantees that the result of the load (or any other instruction) will not be consumed by a speculative use with potential side-channel visible side effects.

i.e. restructure the intrinsic with the following form:
declare T @llvm.nospeculate(T %value)
declare T @llvm.nospeculate(T %value, i1 %spec_condition)

(The later variant is for when the problematic condition to speculate is known, but this has unresolved design challenges around CSE of conditions.  TBD)

An example using the former would be:
%val = load i32, i32* %potentially_out_bounds
%val.forced = call T @llvm.nospeculate(T %val)
use %val.forced

I'm still thinking through what this would lower to on x86, but I think we can find cheapish instruction sequences which force the first load to retire before the use or treat this as scheduling constraint.


More information about the llvm-commits mailing list