From: Richard Earnshaw Date: Wed, 1 Aug 2018 08:16:38 +0000 (+0000) Subject: x86 - add speculation_barrier pattern X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=31e962f2dd67eef0f148b60696df9d95cc1dd713;p=gcc.git x86 - add speculation_barrier pattern This patch adds a speculation barrier for x86, based on my understanding of the required mitigation for that CPU, which is to use an lfence instruction. This patch needs some review by an x86 expert and if adjustments are needed, I'd appreciate it if they could be picked up by the port maintainer. This is supposed to serve as an example of how to deploy the new __builtin_speculation_safe_value() intrinsic on this architecture. * config/i386/i386.md (unspecv): Add UNSPECV_SPECULATION_BARRIER. (speculation_barrier): New insn. From-SVN: r263196 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b934f43208f..6b2e93bb48a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-08-01 Richard Earnshaw + + * config/i386/i386.md (unspecv): Add UNSPECV_SPECULATION_BARRIER. + (speculation_barrier): New insn. + 2018-08-01 Richard Biener PR bootstrap/86724 diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 559ad9334a7..73948c12618 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -301,6 +301,9 @@ ;; For CLDEMOTE support UNSPECV_CLDEMOTE + + ;; For Speculation Barrier support + UNSPECV_SPECULATION_BARRIER ]) ;; Constants to represent rounding modes in the ROUND instruction @@ -20979,6 +20982,13 @@ [(set_attr "type" "other") (set_attr "memory" "unknown")]) +(define_insn "speculation_barrier" + [(unspec_volatile [(const_int 0)] UNSPECV_SPECULATION_BARRIER)] + "" + "lfence" + [(set_attr "type" "other") + (set_attr "length" "3")]) + (include "mmx.md") (include "sse.md") (include "sync.md")