Skip to content
Snippets Groups Projects
  1. May 31, 2018
    • Tom Stellard's avatar
      Merging r322030: · 2f27999d
      Tom Stellard authored
      ------------------------------------------------------------------------
      r322030 | rsmith | 2018-01-08 13:46:42 -0800 (Mon, 08 Jan 2018) | 3 lines
      
      PR35862: Suppress -Wmissing-variable-declarations warning on inline variables,
      variable templates, and instantiations thereof.
      
      ------------------------------------------------------------------------
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@333623 91177308-0d34-0410-b5e6-96231b3b80d8
      2f27999d
  2. May 30, 2018
    • Tom Stellard's avatar
      Merging r333497: · e8264bb9
      Tom Stellard authored
      ------------------------------------------------------------------------
      r333497 | ctopper | 2018-05-29 20:38:15 -0700 (Tue, 29 May 2018) | 5 lines
      
      [X86] Fix the names of a bunch of icelake intrinsics.
      
      Mostly this fixes the names of all the 128-bit intrinsics to start with _mm_ instead of _mm128_ as is the convention and what the Intel docs say.
      
      This also fixes the name of the bitshuffle intrinsics to say epi64 for 128 and 256 bit versions.
      ------------------------------------------------------------------------
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@333575 91177308-0d34-0410-b5e6-96231b3b80d8
      e8264bb9
    • Tom Stellard's avatar
      Merging r326476: · 8b2f6d55
      Tom Stellard authored
      ------------------------------------------------------------------------
      r326476 | mstorsjo | 2018-03-01 12:22:57 -0800 (Thu, 01 Mar 2018) | 7 lines
      
      [RecordLayout] Only assert that fundamental type sizes are power of two on MSVC
      
      Make types with sizes that aren't a power of two an error (that can
      be disabled) in structs with ms_struct layout, except on mingw where
      the situation is quite likely to occur and GCC handles it silently.
      
      Differential Revision: https://reviews.llvm.org/D43908
      ------------------------------------------------------------------------
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@333571 91177308-0d34-0410-b5e6-96231b3b80d8
      8b2f6d55
    • Tom Stellard's avatar
      Merging r326173: · 060f2b89
      Tom Stellard authored
      ------------------------------------------------------------------------
      r326173 | mstorsjo | 2018-02-26 22:27:06 -0800 (Mon, 26 Feb 2018) | 17 lines
      
      [RecordLayout] Don't align to non-power-of-2 sizes when using -mms-bitfields
      
      When targeting GNU/MinGW for i386, the size of the "long double" data
      type is 12 bytes (while it is 8 bytes in MSVC). When building
      with -mms-bitfields to have struct layouts match MSVC, data types
      are laid out in a struct with alignment according to their size.
      However, this doesn't make sense for the long double type, since
      it doesn't match MSVC at all, and aligning to a non-power-of-2
      size triggers other asserts later.
      
      This matches what GCC does, aligning a long double to 4 bytes
      in structs on i386 even when -mms-bitfields is specified.
      
      This fixes asserts when using the max_align_t data type when
      building for MinGW/i386 with the -mms-bitfields flag.
      
      Differential Revision: https://reviews.llvm.org/D43734
      ------------------------------------------------------------------------
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@333569 91177308-0d34-0410-b5e6-96231b3b80d8
      060f2b89
    • Tom Stellard's avatar
      Merging r326235: · fb5042e8
      Tom Stellard authored
      ------------------------------------------------------------------------
      r326235 | mstorsjo | 2018-02-27 11:42:19 -0800 (Tue, 27 Feb 2018) | 6 lines
      
      [MinGW, CrossWindows] Allow passing -static together with -shared
      
      In these combinations, link a DLL as usual, but pass -Bstatic instead
      of -Bdynamic to indicate prefering static libraries.
      
      Differential Revision: https://reviews.llvm.org/D43811
      ------------------------------------------------------------------------
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@333566 91177308-0d34-0410-b5e6-96231b3b80d8
      fb5042e8
    • Tom Stellard's avatar
      Merging r329300: · 453b5b51
      Tom Stellard authored
      ------------------------------------------------------------------------
      r329300 | manojgupta | 2018-04-05 08:29:52 -0700 (Thu, 05 Apr 2018) | 16 lines
      
      Disable -fmerge-all-constants as default.
      
      Summary:
      "-fmerge-all-constants" is a non-conforming optimization and should not
      be the default. It is also causing miscompiles when building Linux
      Kernel (https://lkml.org/lkml/2018/3/20/872).
      
      Fixes PR18538.
      
      Reviewers: rjmccall, rsmith, chandlerc
      
      Reviewed By: rsmith, chandlerc
      
      Subscribers: srhines, cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D45289
      ------------------------------------------------------------------------
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@333564 91177308-0d34-0410-b5e6-96231b3b80d8
      453b5b51
    • Tom Stellard's avatar
      Merging r330331: · ac8256fc
      Tom Stellard authored
      ------------------------------------------------------------------------
      r330331 | erichkeane | 2018-04-19 07:27:05 -0700 (Thu, 19 Apr 2018) | 14 lines
      
      Fix __attribute__((force_align_arg_pointer)) misalignment bug
      
      The force_align_arg_pointer attribute was using a hardcoded 16-byte
      alignment value which in combination with -mstack-alignment=32 (or
      larger) would produce a misaligned stack which could result in crashes
      when accessing stack buffers using aligned AVX load/store instructions.
      
      Fix the issue by using the "stackrealign" function attribute instead
      of using a hardcoded 16-byte alignment.
      
      Patch By: Gramner
      
      Differential Revision: https://reviews.llvm.org/D45812
      
      ------------------------------------------------------------------------
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@333511 91177308-0d34-0410-b5e6-96231b3b80d8
      ac8256fc
  3. May 17, 2018
    • Tom Stellard's avatar
      Merging r330927: · fd417ccd
      Tom Stellard authored
      ------------------------------------------------------------------------
      r330927 | sepavloff | 2018-04-26 01:08:25 -0700 (Thu, 26 Apr 2018) | 2 lines
      
      Make test more platform neutral
      
      ------------------------------------------------------------------------
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@332650 91177308-0d34-0410-b5e6-96231b3b80d8
      fd417ccd
    • Tom Stellard's avatar
      Merging r330926: · fb18c2f2
      Tom Stellard authored
      ------------------------------------------------------------------------
      r330926 | sepavloff | 2018-04-25 23:28:47 -0700 (Wed, 25 Apr 2018) | 9 lines
      
      [ConfigFiles] Update argument strings when merging argrument lists
      
      Implementation of `InputArgList` assumes its field `ArgStrings` contains
      strings for each argument exactly in the same order. This condition was
      broken when arguments from config file and from invocation were merged.
      
      This change fixes https://bugs.llvm.org/show_bug.cgi?id=37196 (Clang
      config files can crash argument handling).
      
      ------------------------------------------------------------------------
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@332649 91177308-0d34-0410-b5e6-96231b3b80d8
      fb18c2f2
    • Tom Stellard's avatar
      Merging r327354: · f0ac6bbc
      Tom Stellard authored
      ------------------------------------------------------------------------
      r327354 | dyung | 2018-03-12 17:41:44 -0700 (Mon, 12 Mar 2018) | 2 lines
      
      Add missing "env" so that test added in r327322 passes on Windows bots.
      
      ------------------------------------------------------------------------
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@332566 91177308-0d34-0410-b5e6-96231b3b80d8
      f0ac6bbc
    • Tom Stellard's avatar
      Merging r325446: · 0a3364fe
      Tom Stellard authored
      ------------------------------------------------------------------------
      r325446 | dim | 2018-02-17 13:04:35 -0800 (Sat, 17 Feb 2018) | 28 lines
      
      [X86] Add 'sahf' CPU feature to frontend
      
      Summary:
      Make clang accept `-msahf` (and `-mno-sahf`) flags to activate the
      `+sahf` feature for the backend, for bug 36028 (Incorrect use of
      pushf/popf enables/disables interrupts on amd64 kernels).  This was
      originally submitted in bug 36037 by Jonathan Looney
      <jonlooney@gmail.com>.
      
      As described there, GCC also uses `-msahf` for this feature, and the
      backend already recognizes the `+sahf` feature. All that is needed is to
      teach clang to pass this on to the backend.
      
      The mapping of feature support onto CPUs may not be complete; rather, it
      was chosen to match LLVM's idea of which CPUs support this feature (see
      lib/Target/X86/X86.td).
      
      I also updated the affected test case (CodeGen/attr-target-x86.c) to
      match the emitted output.
      
      Reviewers: craig.topper, coby, efriedma, rsmith
      
      Reviewed By: craig.topper
      
      Subscribers: emaste, cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D43394
      
      ------------------------------------------------------------------------
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@332560 91177308-0d34-0410-b5e6-96231b3b80d8
      0a3364fe
  4. May 11, 2018
    • Tom Stellard's avatar
      Merging r327322: · 6289e4b7
      Tom Stellard authored
      ------------------------------------------------------------------------
      r327322 | arphaman | 2018-03-12 12:36:29 -0700 (Mon, 12 Mar 2018) | 7 lines
      
      [Tooling] Clear the PreambleSrcLocCache when preamble is discarded during reparsing
      
      This ensures that diagnostics are not remapped to incorrect preamble locations after
      the second reparse with a remapped header file occurs.
      
      rdar://37502480
      
      ------------------------------------------------------------------------
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@332113 91177308-0d34-0410-b5e6-96231b3b80d8
      6289e4b7
  5. Apr 11, 2018
    • Simon Dardis's avatar
      Merging r325651: · 0e746072
      Simon Dardis authored
      ------------------------------------------------------------------------
      r325651 | sdardis | 2018-02-21 00:05:05 +0000 (Wed, 21 Feb 2018) | 34 lines
      
      [mips] Spectre variant two mitigation for MIPSR2
      
      This patch provides mitigation for CVE-2017-5715, Spectre variant two,
      which affects the P5600 and P6600. It provides the option
      -mindirect-jump=hazard, which instructs the LLVM backend to replace
      indirect branches with their hazard barrier variants.
      
      This option is accepted when targeting MIPS revision two or later.
      
      The migitation strategy suggested by MIPS for these processors is to
      use two hazard barrier instructions. 'jalr.hb' and 'jr.hb' are hazard
      barrier variants of the 'jalr' and 'jr' instructions respectively.
      
      These instructions impede the execution of instruction stream until
      architecturally defined hazards (changes to the instruction stream,
      privileged registers which may affect execution) are cleared. These
      instructions in MIPS' designs are not speculated past.
      
      These instructions are used with the option -mindirect-jump=hazard
      when branching indirectly and for indirect function calls.
      
      These instructions are defined by the MIPS32R2 ISA, so this mitigation
      method is not compatible with processors which implement an earlier
      revision of the MIPS ISA.
      
      Implementation note: I've opted to provide this as an
      -mindirect-jump={hazard,...} style option in case alternative
      mitigation methods are required for other implementations of the MIPS
      ISA in future, e.g. retpoline style solutions.
      
      Reviewers: atanasyan
      
      Differential Revision: https://reviews.llvm.org/D43487
      
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@329799 91177308-0d34-0410-b5e6-96231b3b80d8
      0e746072
  6. Apr 10, 2018
    • Tom Stellard's avatar
      Merging r328829: · 31f349d8
      Tom Stellard authored
      ------------------------------------------------------------------------
      r328829 | manojgupta | 2018-03-29 14:11:15 -0700 (Thu, 29 Mar 2018) | 23 lines
      
      [AArch64]: Add support for parsing rN registers.
      
      Summary:
      Allow rN registers to be simply parsed as correspoing xN registers.
      The "register ... asm("rN")" is an command to the
      compiler's register allocator, not an operand to any individual assembly
      instruction. GCC documents this syntax as "...the name of the register
      that should be used."
      
      This is needed to support the changes in Linux kernel (see
      https://lkml.org/lkml/2018/3/1/268 )
      
      Note: This will add support only for the limited use case of
      register ... asm("rN"). Any other uses that make rN leak into assembly
      are not supported.
      
      Reviewers: kristof.beyls, rengolin, peter.smith, t.p.northover
      
      Reviewed By: peter.smith
      
      Subscribers: javed.absar, eraman, cfe-commits, srhines
      
      Differential Revision: https://reviews.llvm.org/D44815
      ------------------------------------------------------------------------
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@329669 91177308-0d34-0410-b5e6-96231b3b80d8
      31f349d8
  7. Apr 07, 2018
    • Tom Stellard's avatar
      Merging r327099: · d5f48a21
      Tom Stellard authored
      ------------------------------------------------------------------------
      r327099 | rsmith | 2018-03-08 18:00:01 -0800 (Thu, 08 Mar 2018) | 3 lines
      
      PR36645: Go looking for an appropriate array bound when constant-evaluating a
      name of an array object.
      
      ------------------------------------------------------------------------
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@329478 91177308-0d34-0410-b5e6-96231b3b80d8
      d5f48a21
  8. Feb 22, 2018
    • Hans Wennborg's avatar
      Merging r324308: · a0152d82
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r324308 | rtrieu | 2018-02-06 03:58:21 +0100 (Tue, 06 Feb 2018) | 4 lines
      
      Fix crash on invalid.
      
      Don't call a method when the pointer is null.
      
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@325766 91177308-0d34-0410-b5e6-96231b3b80d8
      a0152d82
  9. Feb 21, 2018
  10. Feb 20, 2018
    • Hans Wennborg's avatar
      Merging r325576: · ae798ac3
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r325576 | hans | 2018-02-20 13:43:02 +0100 (Tue, 20 Feb 2018) | 13 lines
      
      Revert r325375 "[MS] Make constexpr static data members implicitly inline"
      
      This broke Clang bootstrap on Windows, PR36453.
      
      > This handles them exactly the same way that we handle const integral
      > static data members with inline definitions, which is what MSVC does.
      >
      > As a follow-up, now that we have a way to mark variables inline in the
      > AST, we should consider marking them implicitly inline there instead of
      > only treating them as inline in CodeGen. Unfortunately, this breaks a
      > lot of dllimport test cases, so that is future work for now.
      >
      > Fixes PR36125.
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@325577 91177308-0d34-0410-b5e6-96231b3b80d8
      ae798ac3
  11. Feb 19, 2018
    • Hans Wennborg's avatar
      Merging r325375: · d535c749
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r325375 | rnk | 2018-02-16 20:44:47 +0100 (Fri, 16 Feb 2018) | 11 lines
      
      [MS] Make constexpr static data members implicitly inline
      
      This handles them exactly the same way that we handle const integral
      static data members with inline definitions, which is what MSVC does.
      
      As a follow-up, now that we have a way to mark variables inline in the
      AST, we should consider marking them implicitly inline there instead of
      only treating them as inline in CodeGen. Unfortunately, this breaks a
      lot of dllimport test cases, so that is future work for now.
      
      Fixes PR36125.
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@325500 91177308-0d34-0410-b5e6-96231b3b80d8
      d535c749
  12. Feb 14, 2018
  13. Feb 09, 2018
    • Hans Wennborg's avatar
      Merging r324537: · 4a005620
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r324537 | rsmith | 2018-02-07 23:25:16 +0100 (Wed, 07 Feb 2018) | 14 lines
      
      PR36055: fix computation of *-dependence in nested initializer lists.
      
      When we synthesize an implicit inner initializer list when analyzing an outer
      initializer list, we add it to the outer list immediately, and then fill in the
      inner list. This gives the outer list no chance to update its *-dependence bits
      with those of the completed inner list. To fix this, re-add the inner list to
      the outer list once it's completed.
      
      Note that we do not recompute the *-dependence bits from scratch when we
      complete an outer list; this would give the wrong result for the case where a
      designated initializer overwrites a dependent initializer with a non-dependent
      one. The resulting list in that case should still be dependent, even though all
      traces of the dependence were removed from the semantic form.
      
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324719 91177308-0d34-0410-b5e6-96231b3b80d8
      4a005620
    • Hans Wennborg's avatar
      Merging r324594: · 1d5b6bd0
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r324594 | aivchenk | 2018-02-08 12:15:21 +0100 (Thu, 08 Feb 2018) | 17 lines
      
      Fix for #31362 - ms_abi is implemented incorrectly for values >=16 bytes.
      
      Summary:
      This patch is a fix for following issue:
      https://bugs.llvm.org/show_bug.cgi?id=31362 The problem was caused by front end
      lowering C calling conventions without taking into account calling conventions
      enforced by attribute. In this case win64cc was no correctly lowered on targets
      other than Windows.
      
      Reviewed By: rnk (Reid Kleckner)
      
      Differential Revision: https://reviews.llvm.org/D43016
      
      Author: belickim <mateusz.belicki@intel.com>
      
      
      
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324718 91177308-0d34-0410-b5e6-96231b3b80d8
      1d5b6bd0
  14. Feb 08, 2018
    • Hans Wennborg's avatar
      Merging r324514: · 9524f2cc
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r324514 | arphaman | 2018-02-07 21:45:39 +0100 (Wed, 07 Feb 2018) | 10 lines
      
      [PR36008] Avoid -Wsign-compare warning for enum constants in
      typeof expressions
      
      This commit looks through typeof type at the original expression when diagnosing
      -Wsign-compare to avoid an unfriendly diagnostic.
      
      rdar://36588828
      
      Differential Revision: https://reviews.llvm.org/D42561
      
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324602 91177308-0d34-0410-b5e6-96231b3b80d8
      9524f2cc
    • Hans Wennborg's avatar
      Merging r324419: · 39e7ed25
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r324419 | vsapsai | 2018-02-06 23:39:25 +0100 (Tue, 06 Feb 2018) | 23 lines
      
      [Lex] Fix handling numerical literals ending with ' and signed exponent.
      
      For input `0'e+1` lexer tokenized as numeric constant only `0'e`. Later
      NumericLiteralParser skipped 0 and ' as digits and parsed `e+1` as valid
      exponent going past the end of the token. Because it didn't mark numeric
      literal as having an error, it continued parsing and tried to expandUCNs
      with StringRef of length -2.
      
      The fix is not to parse exponent when we reached the end of token.
      
      Discovered by OSS-Fuzz:
      https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=4588
      
      rdar://problem/36076719
      
      Reviewers: rsmith, t.p.northover
      
      Reviewed By: rsmith
      
      Subscribers: cfe-commits, jkorous-apple
      
      Differential Revision: https://reviews.llvm.org/D41834
      
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324579 91177308-0d34-0410-b5e6-96231b3b80d8
      39e7ed25
  15. Feb 07, 2018
    • Hans Wennborg's avatar
      Merging r324439: · b010081f
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r324439 | compnerd | 2018-02-07 02:55:08 +0100 (Wed, 07 Feb 2018) | 5 lines
      
      AST: support SwiftCC on MS ABI
      
      Microsoft has reserved the identifier 'S' as the swift calling
      convention.  Decorate the symbols appropriately.  This enables swift on
      Windows.
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324460 91177308-0d34-0410-b5e6-96231b3b80d8
      b010081f
  16. Feb 05, 2018
    • Hans Wennborg's avatar
      Merging r324059: · 1bfd05a5
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r324059 | mstorsjo | 2018-02-02 07:22:35 +0100 (Fri, 02 Feb 2018) | 21 lines
      
      [MinGW] Emit typeinfo locally for dllimported classes without key functions
      
      This fixes building Qt as shared libraries with clang in MinGW
      mode; previously subclasses of the QObjectData class (in other
      DLLs than the base DLL) failed to find the typeinfo symbols
      (that neither were emitted in the base DLL nor in the DLL
      containing the subclass).
      
      If the virtual destructor in the newly added testcase wouldn't
      be pure (or if there'd be another non-pure virtual method),
      it'd be a key function and things would work out even before this
      change. Make sure to locally emit the typeinfo for these classes
      as well.
      
      This matches what GCC does in this specific testcase.
      
      This fixes the root issue that spawned PR35146. (The difference
      to GCC that is initially described in that bug still is present
      though.)
      
      Differential Revision: https://reviews.llvm.org/D42641
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324219 91177308-0d34-0410-b5e6-96231b3b80d8
      1bfd05a5
    • Hans Wennborg's avatar
      Merging r323935: · eb51f1dc
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r323935 | rsmith | 2018-02-01 01:28:36 +0100 (Thu, 01 Feb 2018) | 5 lines
      
      PR36181: Teach CodeGen to properly ignore requests to emit dependent entities.
      
      Previously, friend function definitions within class templates slipped through
      the gaps and caused the MS mangler to assert.
      
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324215 91177308-0d34-0410-b5e6-96231b3b80d8
      eb51f1dc
    • Hans Wennborg's avatar
      Merging r324134: · 2f7bb0ce
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r324134 | ericwf | 2018-02-02 21:30:39 +0100 (Fri, 02 Feb 2018) | 14 lines
      
      Make __has_unique_object_representations reject empty union types.
      
      Summary:
      Clang incorrectly reports empty unions as having a unique object representation. However, this is not correct since `sizeof(EmptyUnion) == 1` AKA it has 8 bits of padding. Therefore it should be treated the same as an empty struct and report `false`.
      
      @erichkeane also suggested this fix should be merged into the 6.0 release branch, so the initial release of `__has_unique_object_representations` is as bug-free as possible. 
      
      Reviewers: erichkeane, rsmith, aaron.ballman, majnemer
      
      Reviewed By: erichkeane
      
      Subscribers: cfe-commits, erichkeane
      
      Differential Revision: https://reviews.llvm.org/D42863
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324213 91177308-0d34-0410-b5e6-96231b3b80d8
      2f7bb0ce
  17. Feb 02, 2018
    • Hans Wennborg's avatar
      Merging r323155: · 9c57ee8b
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r323155 | chandlerc | 2018-01-22 23:05:25 +0100 (Mon, 22 Jan 2018) | 133 lines
      
      Introduce the "retpoline" x86 mitigation technique for variant #2 of the speculative execution vulnerabilities disclosed today, specifically identified by CVE-2017-5715, "Branch Target Injection", and is one of the two halves to Spectre..
      
      Summary:
      First, we need to explain the core of the vulnerability. Note that this
      is a very incomplete description, please see the Project Zero blog post
      for details:
      https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html
      
      The basis for branch target injection is to direct speculative execution
      of the processor to some "gadget" of executable code by poisoning the
      prediction of indirect branches with the address of that gadget. The
      gadget in turn contains an operation that provides a side channel for
      reading data. Most commonly, this will look like a load of secret data
      followed by a branch on the loaded value and then a load of some
      predictable cache line. The attacker then uses timing of the processors
      cache to determine which direction the branch took *in the speculative
      execution*, and in turn what one bit of the loaded value was. Due to the
      nature of these timing side channels and the branch predictor on Intel
      processors, this allows an attacker to leak data only accessible to
      a privileged domain (like the kernel) back into an unprivileged domain.
      
      The goal is simple: avoid generating code which contains an indirect
      branch that could have its prediction poisoned by an attacker. In many
      cases, the compiler can simply use directed conditional branches and
      a small search tree. LLVM already has support for lowering switches in
      this way and the first step of this patch is to disable jump-table
      lowering of switches and introduce a pass to rewrite explicit indirectbr
      sequences into a switch over integers.
      
      However, there is no fully general alternative to indirect calls. We
      introduce a new construct we call a "retpoline" to implement indirect
      calls in a non-speculatable way. It can be thought of loosely as
      a trampoline for indirect calls which uses the RET instruction on x86.
      Further, we arrange for a specific call->ret sequence which ensures the
      processor predicts the return to go to a controlled, known location. The
      retpoline then "smashes" the return address pushed onto the stack by the
      call with the desired target of the original indirect call. The result
      is a predicted return to the next instruction after a call (which can be
      used to trap speculative execution within an infinite loop) and an
      actual indirect branch to an arbitrary address.
      
      On 64-bit x86 ABIs, this is especially easily done in the compiler by
      using a guaranteed scratch register to pass the target into this device.
      For 32-bit ABIs there isn't a guaranteed scratch register and so several
      different retpoline variants are introduced to use a scratch register if
      one is available in the calling convention and to otherwise use direct
      stack push/pop sequences to pass the target address.
      
      This "retpoline" mitigation is fully described in the following blog
      post: https://support.google.com/faqs/answer/7625886
      
      We also support a target feature that disables emission of the retpoline
      thunk by the compiler to allow for custom thunks if users want them.
      These are particularly useful in environments like kernels that
      routinely do hot-patching on boot and want to hot-patch their thunk to
      different code sequences. They can write this custom thunk and use
      `-mretpoline-external-thunk` *in addition* to `-mretpoline`. In this
      case, on x86-64 thu thunk names must be:
      ```
        __llvm_external_retpoline_r11
      ```
      or on 32-bit:
      ```
        __llvm_external_retpoline_eax
        __llvm_external_retpoline_ecx
        __llvm_external_retpoline_edx
        __llvm_external_retpoline_push
      ```
      And the target of the retpoline is passed in the named register, or in
      the case of the `push` suffix on the top of the stack via a `pushl`
      instruction.
      
      There is one other important source of indirect branches in x86 ELF
      binaries: the PLT. These patches also include support for LLD to
      generate PLT entries that perform a retpoline-style indirection.
      
      The only other indirect branches remaining that we are aware of are from
      precompiled runtimes (such as crt0.o and similar). The ones we have
      found are not really attackable, and so we have not focused on them
      here, but eventually these runtimes should also be replicated for
      retpoline-ed configurations for completeness.
      
      For kernels or other freestanding or fully static executables, the
      compiler switch `-mretpoline` is sufficient to fully mitigate this
      particular attack. For dynamic executables, you must compile *all*
      libraries with `-mretpoline` and additionally link the dynamic
      executable and all shared libraries with LLD and pass `-z retpolineplt`
      (or use similar functionality from some other linker). We strongly
      recommend also using `-z now` as non-lazy binding allows the
      retpoline-mitigated PLT to be substantially smaller.
      
      When manually apply similar transformations to `-mretpoline` to the
      Linux kernel we observed very small performance hits to applications
      running typical workloads, and relatively minor hits (approximately 2%)
      even for extremely syscall-heavy applications. This is largely due to
      the small number of indirect branches that occur in performance
      sensitive paths of the kernel.
      
      When using these patches on statically linked applications, especially
      C++ applications, you should expect to see a much more dramatic
      performance hit. For microbenchmarks that are switch, indirect-, or
      virtual-call heavy we have seen overheads ranging from 10% to 50%.
      
      However, real-world workloads exhibit substantially lower performance
      impact. Notably, techniques such as PGO and ThinLTO dramatically reduce
      the impact of hot indirect calls (by speculatively promoting them to
      direct calls) and allow optimized search trees to be used to lower
      switches. If you need to deploy these techniques in C++ applications, we
      *strongly* recommend that you ensure all hot call targets are statically
      linked (avoiding PLT indirection) and use both PGO and ThinLTO. Well
      tuned servers using all of these techniques saw 5% - 10% overhead from
      the use of retpoline.
      
      We will add detailed documentation covering these components in
      subsequent patches, but wanted to make the core functionality available
      as soon as possible. Happy for more code review, but we'd really like to
      get these patches landed and backported ASAP for obvious reasons. We're
      planning to backport this to both 6.0 and 5.0 release streams and get
      a 5.0 release with just this cherry picked ASAP for distros and vendors.
      
      This patch is the work of a number of people over the past month: Eric, Reid,
      Rui, and myself. I'm mailing it out as a single commit due to the time
      sensitive nature of landing this and the need to backport it. Huge thanks to
      everyone who helped out here, and everyone at Intel who helped out in
      discussions about how to craft this. Also, credit goes to Paul Turner (at
      Google, but not an LLVM contributor) for much of the underlying retpoline
      design.
      
      Reviewers: echristo, rnk, ruiu, craig.topper, DavidKreitzer
      
      Subscribers: sanjoy, emaste, mcrosier, mgorny, mehdi_amini, hiraditya, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D41723
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324068 91177308-0d34-0410-b5e6-96231b3b80d8
      9c57ee8b
  18. Jan 30, 2018
  19. Jan 24, 2018
    • Hans Wennborg's avatar
      Merging r323008: · abf562a4
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r323008 | vsapsai | 2018-01-20 00:41:47 +0100 (Sat, 20 Jan 2018) | 32 lines
      
      [Lex] Fix crash on code completion in comment in included file.
      
      This fixes PR32732 by updating CurLexerKind to reflect available lexers.
      We were hitting null pointer in Preprocessor::Lex because CurLexerKind
      was CLK_Lexer but CurLexer was null. And we set it to null in
      Preprocessor::HandleEndOfFile when exiting a file with code completion
      point.
      
      To reproduce the crash it is important for a comment to be inside a
      class specifier. In this case in Parser::ParseClassSpecifier we improve
      error recovery by pushing a semicolon token back into the preprocessor
      and later on try to lex a token because we haven't reached the end of
      file.
      
      Also clang crashes only on code completion in included file, i.e. when
      IncludeMacroStack is not empty. Though we reset CurLexer even if include
      stack is empty. The difference is that during pushing back a semicolon
      token, preprocessor calls EnterCachingLexMode which decides it is
      already in caching mode because various lexers are null and
      IncludeMacroStack is not empty. As the result, CurLexerKind remains
      CLK_Lexer instead of updating to CLK_CachingLexer.
      
      rdar://problem/34787685
      
      Reviewers: akyrtzi, doug.gregor, arphaman
      
      Reviewed By: arphaman
      
      Subscribers: cfe-commits, kfunk, arphaman, nemanjai, kbarton
      
      Differential Revision: https://reviews.llvm.org/D41688
      
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@323333 91177308-0d34-0410-b5e6-96231b3b80d8
      abf562a4
  20. Jan 22, 2018
    • Hans Wennborg's avatar
      Merging r322984: · 8231d605
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r322984 | rtrieu | 2018-01-19 21:46:19 +0100 (Fri, 19 Jan 2018) | 7 lines
      
      Allow BlockDecl in CXXRecord scope to have no access specifier.
      
      Using a BlockDecl in a default member initializer causes it to be attached to
      CXXMethodDecl without its access specifier being set.  This prevents a crash
      where getAccess is called on this BlockDecl, since that method expects any
      Decl in CXXRecord scope to have an access specifier.
      
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@323108 91177308-0d34-0410-b5e6-96231b3b80d8
      8231d605
  21. Jan 19, 2018
    • Hans Wennborg's avatar
      Merging r322901: · 9b9bcde7
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r322901 | nico | 2018-01-18 13:40:27 -0800 (Thu, 18 Jan 2018) | 19 lines
      
      Remove TautologicalInRangeCompare from Extra and TautologicalCompare.
      
      This removes the following (already default-off) warnings from -Wextra:
        -Wtautological-type-limit-compare,
        -Wtautological-unsigned-zero-compare
        -Wtautological-unsigned-enum-zero-compare
      
      On the thread "[cfe-dev] -Wtautological-constant-compare issues", clang
      code owners Richard Smith, John McCall, and Reid Kleckner as well as
      libc++ code owner Marshall Clow stated that these new warnings are not
      yet ready for prime time and shouldn't be part of -Wextra.
      
      Furthermore, Vedant Kumar (Apple), Peter Hosek (Fuchsia), and me (Chromium)
      expressed the same concerns (Vedant on that thread, Peter on
      https://reviews.llvm.org/D39462, me on https://reviews.llvm.org/D41512).
      
      So remove them from -Wextra, and remove TautologicalInRangeCompare from
      TautologicalCompare too until they're usable with real-world code.
      
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@322931 91177308-0d34-0410-b5e6-96231b3b80d8
      9b9bcde7
  22. Jan 17, 2018
    • Hans Wennborg's avatar
      Merging r321779: · ca189f00
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r321779 | rsmith | 2018-01-03 17:24:17 -0800 (Wed, 03 Jan 2018) | 7 lines
      
      PR35045: Convert injected-class-name to its corresponding simple-template-id
      during template argument deduction.
      
      We already did this when the injected-class-name was in P, but missed the case
      where it was in A. This (probably) can't happen except in implicit deduction
      guides.
      
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@322677 91177308-0d34-0410-b5e6-96231b3b80d8
      ca189f00
    • Hans Wennborg's avatar
      Merging r321777: · 2dfe2bdb
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r321777 | rsmith | 2018-01-03 17:02:18 -0800 (Wed, 03 Jan 2018) | 2 lines
      
      PR35028: Retain duplicate alignas attributes in template instantiation.
      
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@322676 91177308-0d34-0410-b5e6-96231b3b80d8
      2dfe2bdb
    • Hans Wennborg's avatar
      Merging r322390: · 27eb4d05
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r322390 | vsapsai | 2018-01-12 10:54:35 -0800 (Fri, 12 Jan 2018) | 20 lines
      
      [Lex] Avoid out-of-bounds dereference in LexAngledStringLiteral.
      
      Fix makes the loop in LexAngledStringLiteral more like the loops in
      LexStringLiteral, LexCharConstant. When we skip a character after
      backslash, we need to check if we reached the end of the file instead of
      reading the next character unconditionally.
      
      Discovered by OSS-Fuzz:
      https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3832
      
      rdar://problem/35572754
      
      Reviewers: arphaman, kcc, rsmith, dexonsmith
      
      Reviewed By: rsmith, dexonsmith
      
      Subscribers: cfe-commits, rsmith, dexonsmith
      
      Differential Revision: https://reviews.llvm.org/D41423
      
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@322649 91177308-0d34-0410-b5e6-96231b3b80d8
      27eb4d05
    • Hans Wennborg's avatar
      Merging r322236: · acedccff
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r322236 | rsmith | 2018-01-10 15:08:26 -0800 (Wed, 10 Jan 2018) | 3 lines
      
      In C++17, when instantiating an out-of-line definition of an inline static data
      member, don't forget to instantiate the initializer too.
      
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@322641 91177308-0d34-0410-b5e6-96231b3b80d8
      acedccff
    • Hans Wennborg's avatar
      Merging r322350, r322405, r322420, r322593: · 06686ae9
      Hans Wennborg authored
      ------------------------------------------------------------------------
      r322350 | rtrieu | 2018-01-11 20:42:27 -0800 (Thu, 11 Jan 2018) | 6 lines
      
      [ODRHash] Don't hash friend functions.
      
      In certain combinations of templated classes and friend functions, the body
      of friend functions does not get propagated along with function signature.
      Exclude friend functions for hashing to avoid this case.
      
      ------------------------------------------------------------------------
      
      ------------------------------------------------------------------------
      r322405 | rtrieu | 2018-01-12 13:49:20 -0800 (Fri, 12 Jan 2018) | 2 lines
      
      Disable test for Windows to fix Windows buildbots.
      
      ------------------------------------------------------------------------
      
      ------------------------------------------------------------------------
      r322420 | rtrieu | 2018-01-12 15:13:33 -0800 (Fri, 12 Jan 2018) | 2 lines
      
      Try to suppress Windows testing again.
      
      ------------------------------------------------------------------------
      
      ------------------------------------------------------------------------
      r322593 | rtrieu | 2018-01-16 11:53:06 -0800 (Tue, 16 Jan 2018) | 6 lines
      
      Add context to why test was disabled on Windows
      
      test/Modules/odr_hash-Friend.cpp triggers an assertion in MicrosoftMangle.cpp
      This has been reported in PR35939
      
      
      ------------------------------------------------------------------------
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@322632 91177308-0d34-0410-b5e6-96231b3b80d8
      06686ae9
Loading