1. Dec 15, 2016
    • Pavel Labath's avatar
      Simplify format member detection in FormatVariadic · 08c2e868
      Pavel Labath authored
      Summary:
      This replaces the format member search, which was quite complicated, with a more
      direct approach to detecting whether a class should be formatted using the
      format-member method. Instead we use a special type llvm::format_adapter, which
      every adapter must inherit from. Then the search can be simply implemented with
      the is_base_of type trait.
      
      Aside from the simplification, I like this way more because it makes it more
      explicit that you are supposed to use this type only for adapter-like
      formattings, and the other approach (format_provider overloads) should be used
      as a default (a mistake I made when first trying to use this library).
      
      The only slight change in behaviour here is that now choose the format-adapter
      branch even if the format member invocation will fail to compile (e.g. because it is a
      non-const member function and we are passing a const adapter), whereas
      previously we would have gone on to search for format_providers for the type.
      However, I think that is actually a good thing, as it probably means the
      programmer did something wrong.
      
      Reviewers: zturner, inglorion
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D27679
      
      llvm-svn: 289795
      08c2e868
    • Sjoerd Meijer's avatar
      [Thumb] Teach ISel how to lower compares of AND bitmasks efficiently · 96e10b5a
      Sjoerd Meijer authored
      This is essentially a recommit of r285893, but with a correctness fix. The
      problem of the original commit was that this:
      
      bic r5, r7, #31
      cbz r5, .LBB2_10
      
      got rewritten into:
      
      lsrs  r5, r7, #5
      beq .LBB2_10
      
      The result in destination register r5 is not the same and this is incorrect
      when r5 is not dead. So this fix includes checking the uses of the AND
      destination register. And also, compared to the original commit, some regression
      tests didn't need changing anymore because of this extra check.
      
      For completeness, this was the original commit message:
      
      For the common pattern (CMPZ (AND x, #bitmask), #0), we can do some more
      efficient instruction selection if the bitmask is one consecutive sequence of
      set bits (32 - clz(bm) - ctz(bm) == popcount(bm)).
      
      1) If the bitmask touches the LSB, then we can remove all the upper bits and
      set the flags by doing one LSLS.
      2) If the bitmask touches the MSB, then we can remove all the lower bits and
      set the flags with one LSRS.
      3) If the bitmask has popcount == 1 (only one set bit), we can shift that bit
      into the sign bit with one LSLS and change the condition query from NE/EQ to
      MI/PL (we could also implement this by shifting into the carry bit and
      branching on BCC/BCS).
      4) Otherwise, we can emit a sequence of LSLS+LSRS to remove the upper and lower
      zero bits of the mask.
      
      1-3 require only one 16-bit instruction and can elide the CMP. 4 requires two
      16-bit instructions but can elide the CMP and doesn't require materializing a
      complex immediate, so is also a win.
      
      Differential Revision: https://reviews.llvm.org/D27761
      
      llvm-svn: 289794
      96e10b5a
    • Dylan McKay's avatar
      [AVR] Add argument indices to the instrumention hook functions · 4b028e2e
      Dylan McKay authored
      This allows the instrumention hook functions to do better
      pretty-printing.
      
      llvm-svn: 289793
      4b028e2e
    • George Rimar's avatar
    • Michael Kruse's avatar
      Remove references to AssumptionCache. NFC. · 7037fde4
      Michael Kruse authored
      The AssumptionCache was removed in r289756 after being replaced by the an
      addtional operand list of affected values in r289755. The absence of that cache
      means that we have now have to manually search for llvm.assume intrinsics as
      now done by other passes (LazyValueInfo, CodeMetrics) do not take into
      account an llvm::Instruction's user lists (ScalarEvolution).
      
      llvm-svn: 289791
      7037fde4
    • George Rimar's avatar
      [ELF] - Partial support of --gdb-index command line option (Part 2). · 8b547393
      George Rimar authored
      Patch continues work started in D24706,
      
      in this patch address area was added to .gdb_index section output.
      
      Differential revision: https://reviews.llvm.org/D25821
      
      llvm-svn: 289790
      8b547393
    • Dean Michael Berris's avatar
      [XRay][compiler-rt][NFC] Deduplicate code in x86-64 trampolines. · 76e56c67
      Dean Michael Berris authored
      Summary:
      The layout of all registers saved on stack shouldn't deviate and will be reused in future trampolines as well.
      
      While there, fix whitespace and clarify comments.
      
      Author: mpel
      
      Reviewers: dberris
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D27799
      
      llvm-svn: 289789
      76e56c67
    • Prakhar Bahuguna's avatar
      Fix for build warning in execute-only support · 13e9921c
      Prakhar Bahuguna authored
      llvm-svn: 289788
      13e9921c
    • Yaxun Liu's avatar
      Re-commit r289252 and r289285, and fix PR31374 · 402804b6
      Yaxun Liu authored
      llvm-svn: 289787
      402804b6
    • Prakhar Bahuguna's avatar
      [ARM] Implement execute-only support in CodeGen · 61ef150d
      Prakhar Bahuguna authored
      Summary:
      This implements execute-only support for ARM code generation, which
      prevents the compiler from generating data accesses to code sections.
      The following changes are involved:
      
      * Add the CodeGen option "-arm-execute-only" to the ARM code generator.
      * Add the clang flag "-mexecute-only" as well as the GCC-compatible
        alias "-mpure-code" to enable this option.
      * When enabled, literal pools are replaced with MOVW/MOVT instructions,
        with VMOV used in addition for floating-point literals. As the MOVT
        instruction is required, execute-only support is only available in
        Thumb mode for targets supporting ARMv8-M baseline or Thumb2.
      * Jump tables are placed in data sections when in execute-only mode.
      * The execute-only text section is assigned section ID 0, and is
        marked as unreadable with the SHF_ARM_PURECODE flag with symbol 'y'.
        This also overrides selection of ELF sections for globals.
      
      Reviewers: t.p.northover, rengolin
      
      Subscribers: llvm-commits, aemerson
      
      Differential Revision: https://reviews.llvm.org/D27450
      
      llvm-svn: 289786
      61ef150d
    • Prakhar Bahuguna's avatar
      Allow ELF section flags to be specified numerically · e640c6f7
      Prakhar Bahuguna authored
      Summary:
      GAS already allows flags for sections to be specified directly as a
      numeric value. This functionality is particularly useful for setting
      processor or application-specific values that may not be directly
      supported or understood by LLVM. This patch allows LLVM to use numeric
      section flag values verbatim if specified by the assembly file.
      
      Reviewers: grosbach, rafael, t.p.northover, rengolin
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D27451
      
      llvm-svn: 289785
      e640c6f7
    • Prakhar Bahuguna's avatar
      [ARM] Implement execute-only support in CodeGen · 52a7dd7d
      Prakhar Bahuguna authored
      This implements execute-only support for ARM code generation, which
      prevents the compiler from generating data accesses to code sections.
      The following changes are involved:
      
      * Add the CodeGen option "-arm-execute-only" to the ARM code generator.
      * Add the clang flag "-mexecute-only" as well as the GCC-compatible
        alias "-mpure-code" to enable this option.
      * When enabled, literal pools are replaced with MOVW/MOVT instructions,
        with VMOV used in addition for floating-point literals. As the MOVT
        instruction is required, execute-only support is only available in
        Thumb mode for targets supporting ARMv8-M baseline or Thumb2.
      * Jump tables are placed in data sections when in execute-only mode.
      * The execute-only text section is assigned section ID 0, and is
        marked as unreadable with the SHF_ARM_PURECODE flag with symbol 'y'.
        This also overrides selection of ELF sections for globals.
      
      llvm-svn: 289784
      52a7dd7d
    • Saleem Abdulrasool's avatar
      CodeGen: force builtins to be local · 342beeb9
      Saleem Abdulrasool authored
      Unfortunately _setjmp3 can be both import or local.  The ASAN tests try to
      emulate the flags which makes this harder to detect.  Rely on the linker
      creating or using thunks here instead.  Should repair the ASAN windows bots.
      
      llvm-svn: 289783
      342beeb9
    • George Rimar's avatar
      [ELF] - Do not crash when move location counter backward. · 14460e02
      George Rimar authored
      PR31335 shows that we do that in next case:
      SECTIONS { .text 0x2000 : {. = 0x100 ; *(.text) } }
      
      though documentations says that "If . is used inside a section 
      description however, it refers to the byte offset from the start
      of that section, not an absolute address. " looks does not work 
      as documented in bfd (as mentioned in comments for PR31335).
      
      Until we find out the expected behavior was suggested at least not
      to 'crash', what we do after trying to generate huge file.
      
      Differential revision: https://reviews.llvm.org/D27712
      
      llvm-svn: 289782
      14460e02
    • Eric Fiselier's avatar
      Fix typo · 7dfa6268
      Eric Fiselier authored
      llvm-svn: 289781
      7dfa6268
    • Eric Fiselier's avatar
      Add tests for LWG 2796 · f4d7c186
      Eric Fiselier authored
      llvm-svn: 289780
      f4d7c186
    • Sanjoy Das's avatar
      Add missing -mtriple to MIR test case · 93b1de0f
      Sanjoy Das authored
      llvm-svn: 289779
      93b1de0f
    • Eric Fiselier's avatar
      Add more test cases for PR31384 · 3fede1c9
      Eric Fiselier authored
      llvm-svn: 289778
      3fede1c9
    • Yaxun Liu's avatar
      Attempt to fix llvm-readobj crash on ppc64 due to r289674 · 6f8d9099
      Yaxun Liu authored
      llvm-svn: 289777
      6f8d9099
    • Saleem Abdulrasool's avatar
      CodeGen: fix runtime function dll storage · 6cb07449
      Saleem Abdulrasool authored
      Properly attribute DLL storage to runtime functions.  When generating the
      runtime function, scan for an existing declaration which may provide an explicit
      declaration (local storage) or a DLL import or export storage from the user.
      Honour that if available.  Otherwise, if building with a local visibility of the
      public or standard namespaces (-flto-visibility-public-std), give the symbols
      local storage (it indicates a /MT[d] link, so static runtime).  Otherwise,
      assume that the link is dynamic, and give the runtime function dllimport
      storage.
      
      This allows for implementations to get the correct storage as long as they are
      properly declared, the user to override the import storage, and in case no
      explicit storage is given, use of the import storage.
      
      llvm-svn: 289776
      6cb07449
    • Daniel Jasper's avatar
      Fix go bindings after r289702 (hopefully, don't really know how to build · befe7a3f
      Daniel Jasper authored
      them, build.sh seems to be broken).
      
      llvm-svn: 289775
      befe7a3f
    • Eric Fiselier's avatar
      Add test case for PR31384 · 9ce17454
      Eric Fiselier authored
      llvm-svn: 289774
      9ce17454
    • Eric Fiselier's avatar
      Revert r289727 due to PR31384 · 347a1cc2
      Eric Fiselier authored
      This patch reverts the changes to tuple which fixed construction from
      types derived from tuple. It breaks the code mentioned in llvm.org/PR31384.
      I'll follow this commit up with a test case.
      
      llvm-svn: 289773
      347a1cc2
    • Kostya Serebryany's avatar
    • Dylan McKay's avatar
      [AVR] Whitelist the avrlit config environment variables · dc58eb54
      Dylan McKay authored
      This allows us to use `lit` to run on-target execution tests.
      
      llvm-svn: 289769
      dc58eb54
    • Hal Finkel's avatar
      Revert part of r289765 that is not necessary · f19e1142
      Hal Finkel authored
      CS.doesNotAccessMemory(ArgNo) and CS.onlyReadsMemory(ArgNo) calls
      dataOperandHasImpliedAttr, so revert this part of r289765 because
      it should not be necessary.
      
      llvm-svn: 289768
      f19e1142
    • Eric Fiselier's avatar
      XFAIL test for more apple-clang versions · a0620a1c
      Eric Fiselier authored
      llvm-svn: 289767
      a0620a1c
    • Hal Finkel's avatar
      Trying to fix NDEBUG build after r289764 · 34f9d6ac
      Hal Finkel authored
      llvm-svn: 289766
      34f9d6ac
    • Hal Finkel's avatar
      Fix argument attribute queries with bundle operands · 39fed399
      Hal Finkel authored
      When iterating over data operands in AA, don't make argument-attribute-specific
      queries on bundle operands. Trying to fix self hosting...
      
      llvm-svn: 289765
      39fed399
    • Sanjoy Das's avatar
      [MachineBlockPlacement] Don't make blocks "uneditable" · d7389d62
      Sanjoy Das authored
      Summary:
      This fixes an issue with MachineBlockPlacement due to a badly timed call
      to `analyzeBranch` with `AllowModify` set to true.  The timeline is as
      follows:
      
       1. `MachineBlockPlacement::maybeTailDuplicateBlock` calls
          `TailDup.shouldTailDuplicate` on its argument, which in turn calls
          `analyzeBranch` with `AllowModify` set to true.
      
       2. This `analyzeBranch` call edits the terminator sequence of the block
          based on the physical layout of the machine function, turning an
          unanalyzable non-fallthrough block to a unanalyzable fallthrough
          block.  Normally MBP bails out of rearranging such blocks, but this
          block was unanalyzable non-fallthrough (and thus rearrangeable) the
          first time MBP looked at it, and so it goes ahead and decides where
          it should be placed in the function.
      
       3. When placing this block MBP fails to analyze and thus update the
          block in keeping with the new physical layout.
      
      Concretely, before (1) we have something like:
      
      ```
      LBL0:
        < unknown terminator op that may branch to LBL1 >
        jmp LBL1
      
      LBL1:
        ... A
      
      LBL2:
        ... B
      ```
      
      In (2), analyze branch simplifies this to
      
      ```
      LBL0:
        < unknown terminator op that may branch to LBL2 >
        ;; jmp LBL1 <- redundant jump removed
      
      LBL1:
        ... A
      
      LBL2:
        ... B
      ```
      
      In (3), MachineBlockPlacement goes ahead with its plan of putting LBL2
      after the first block since that is profitable.
      
      ```
      LBL0:
        < unknown terminator op that may branch to LBL2 >
        ;; jmp LBL1 <- redundant jump
      
      LBL2:
        ... B
      
      LBL1:
        ... A
      ```
      
      and the program now has incorrect behavior (we no longer fall-through
      from `LBL0` to `LBL1`) because MBP can no longer edit LBL0.
      
      There are several possible solutions, but I went with removing the teeth
      off of the `analyzeBranch` calls in TailDuplicator.  That makes thinking
      about the result of these calls easier, and breaks nothing in the lit
      test suite.
      
      I've also added some bookkeeping to the MachineBlockPlacement pass and
      used that to write an assert that would have caught this.
      
      Reviewers: chandlerc, gberry, MatzeB, iteratee
      
      Subscribers: mcrosier, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D27783
      
      llvm-svn: 289764
      d7389d62
    • Mehdi Amini's avatar
      Revert "Fix printf specifier handling: invalid specifier should not be marked... · ba80a837
      Mehdi Amini authored
      Revert "Fix printf specifier handling: invalid specifier should not be marked as "consuming data arguments""
      
      This reverts commit r289762, wasn't ready to be pushed, it broke the printf tests.
      
      llvm-svn: 289763
      ba80a837
    • Mehdi Amini's avatar
    • Mehdi Amini's avatar
      Fix os_log formating with arbitrary precision and field width · ab11d830
      Mehdi Amini authored
      llvm-svn: 289761
      ab11d830
    • Peter Collingbourne's avatar
      COFF: Open and map input files asynchronously on Windows. · 6ee0b4e9
      Peter Collingbourne authored
      Profiling revealed that the majority of lld's execution time on Windows was
      spent opening and mapping input files. We can reduce this cost significantly
      by performing these operations asynchronously.
      
      This change introduces a queue for all operations on input file data. When
      we discover that we need to load a file (for example, when we find a lazy
      archive for an undefined symbol, or when we read a linker directive to
      load a file from disk), the file operation is launched using a future and
      the symbol resolution operation is enqueued.  This implies another change
      to symbol resolution semantics, but it seems to be harmless ("ninja All"
      in Chromium still succeeds).
      
      To measure the perf impact of this change I linked Chromium's chrome_child.dll
      with both thin and fat archives.
      
      Thin archives:
      
      Before (median of 5 runs): 19.50s
      After: 10.93s
      
      Fat archives:
      
      Before: 12.00s
      After: 9.90s
      
      On Linux I found that doing this asynchronously had a negative effect on
      performance, probably because the cost of mapping a file is small enough that
      it becomes outweighed by the cost of managing the futures. So on non-Windows
      platforms I use the deferred execution strategy.
      
      Differential Revision: https://reviews.llvm.org/D27768
      
      llvm-svn: 289760
      6ee0b4e9
    • Craig Topper's avatar
    • Rui Ueyama's avatar
      Rename functions as per post commit review for r289072. · fd7ed23e
      Rui Ueyama authored
      llvm-svn: 289758
      fd7ed23e
    • Hal Finkel's avatar
      Fix iterator-invalidation issue · 321053a7
      Hal Finkel authored
      Inserting a new key into a DenseMap potentially invalidates iterators into that
      map. Trying to fix an issue from r289755 triggering this assertion:
      
        Assertion `isHandleInSync() && "invalid iterator access!"' failed.
      
      llvm-svn: 289757
      321053a7
    • Hal Finkel's avatar
      Remove the AssumptionCache · 3ca4a6bc
      Hal Finkel authored
      After r289755, the AssumptionCache is no longer needed. Variables affected by
      assumptions are now found by using the new operand-bundle-based scheme. This
      new scheme is more computationally efficient, and also we need much less
      code...
      
      llvm-svn: 289756
      3ca4a6bc
    • Hal Finkel's avatar
      Make processing @llvm.assume more efficient by using operand bundles · cb9f78e1
      Hal Finkel authored
      There was an efficiency problem with how we processed @llvm.assume in
      ValueTracking (and other places). The AssumptionCache tracked all of the
      assumptions in a given function. In order to find assumptions relevant to
      computing known bits, etc. we searched every assumption in the function. For
      ValueTracking, that means that we did O(#assumes * #values) work in InstCombine
      and other passes (with a constant factor that can be quite large because we'd
      repeat this search at every level of recursion of the analysis).
      
      Several of us discussed this situation at the last developers' meeting, and
      this implements the discussed solution: Make the values that an assume might
      affect operands of the assume itself. To avoid exposing this detail to
      frontends and passes that need not worry about it, I've used the new
      operand-bundle feature to add these extra call "operands" in a way that does
      not affect the intrinsic's signature. I think this solution is relatively
      clean. InstCombine adds these extra operands based on what ValueTracking, LVI,
      etc. will need and then those passes need only search the users of the values
      under consideration. This should fix the computational-complexity problem.
      
      At this point, no passes depend on the AssumptionCache, and so I'll remove
      that as a follow-up change.
      
      Differential Revision: https://reviews.llvm.org/D27259
      
      llvm-svn: 289755
      cb9f78e1
    • Richard Smith's avatar
      [c++1z] Permit constant evaluation of a call through a function pointer whose · dfe85e2d
      Richard Smith authored
      type differs from the type of the actual function due to having a different
      exception specification.
      
      llvm-svn: 289754
      dfe85e2d