1. Jun 13, 2016
  2. Jun 12, 2016
    • Benjamin Kramer's avatar
      Pass DebugLoc and SDLoc by const ref. · bdc4956b
      Benjamin Kramer authored
      This used to be free, copying and moving DebugLocs became expensive
      after the metadata rewrite. Passing by reference eliminates a ton of
      track/untrack operations. No functionality change intended.
      
      llvm-svn: 272512
      bdc4956b
    • Sanjay Patel's avatar
      [x86, SSE] change patterns for CMPP to float types to allow matching with SSE1 (PR28044) · 977530a8
      Sanjay Patel authored
      This patch is intended to solve:
      https://llvm.org/bugs/show_bug.cgi?id=28044
      
      By changing the definition of X86ISD::CMPP to use float types, we allow it to be created 
      and pass legalization for an SSE1-only target where v4i32 is not legal.
      
      The motivational trail for this change includes:
      https://llvm.org/bugs/show_bug.cgi?id=28001
      
      and eventually makes this trigger:
      http://reviews.llvm.org/D21190
      
      Ie, after this step, we should be free to have Clang generate FP compare IR instead of x86
      intrinsics for SSE C packed compare intrinsics. (We can auto-upgrade and remove the LLVM 
      sse.cmp intrinsics as a follow-up step.) Once we're generating vector IR instead of x86
      intrinsics, a big pile of generic optimizations can trigger.
      
      Differential Revision: http://reviews.llvm.org/D21235
      
      llvm-svn: 272511
      977530a8
    • Craig Topper's avatar
    • Benjamin Kramer's avatar
      [RegUsageInfoCollector] Drop unneccesary const_cast. NFC. · bc2f4fb6
      Benjamin Kramer authored
      llvm-svn: 272509
      bc2f4fb6
    • Simon Pilgrim's avatar
      [X86][BMI] Added fast-isel tests for BMI1 intrinsics · 9d8bed17
      Simon Pilgrim authored
      A lot of the codegen is pretty awful for these as they are mostly implemented as generic bit twiddling ops 
      
      llvm-svn: 272508
      9d8bed17
    • Sean Silva's avatar
      [PM] Port DeadArgumentElimination to the new PM · e3bb4574
      Sean Silva authored
      The approach taken here follows r267631.
      
      deadarghaX0r should be easy to port when the time comes to add new-PM
      support to bugpoint.
      
      llvm-svn: 272507
      e3bb4574
    • Amaury Sechet's avatar
      Change () to (void) in the C API. · 48b0665b
      Amaury Sechet authored
      llvm-svn: 272506
      48b0665b
    • Sean Silva's avatar
      [PM] Port ReversePostOrderFunctionAttrs to the new PM · f5080194
      Sean Silva authored
      Below are my super rough notes when porting. They can probably serve as
      a basic guide for porting other passes to the new PM. As I port more
      passes I'll expand and generalize this and make a proper
      docs/HowToPortToNewPassManager.rst document. There is also missing
      documentation for general concepts and API's in the new PM which will
      require some documentation.
      Once there is proper documentation in place we can put up a list of
      passes that have to be ported and game-ify/crowdsource the rest of the
      porting (at least of the middle end; the backend is still unclear).
      
      I will however be taking personal responsibility for ensuring that the
      LLD/ELF LTO pipeline is ported in a timely fashion. The remaining passes
      to be ported are (do something like
      `git grep "<the string in the bullet point below>"` to find the pass):
      
      General Scalar:
      [ ] Simplify the CFG
      [ ] Jump Threading
      [ ] MemCpy Optimization
      [ ] Promote Memory to Register
      [ ] MergedLoadStoreMotion
      [ ] Lazy Value Information Analysis
      
      General IPO:
      [ ] Dead Argument Elimination
      [ ] Deduce function attributes in RPO
      
      Loop stuff / vectorization stuff:
      [ ] Alignment from assumptions
      [ ] Canonicalize natural loops
      [ ] Delete dead loops
      [ ] Loop Access Analysis
      [ ] Loop Invariant Code Motion
      [ ] Loop Vectorization
      [ ] SLP Vectorizer
      [ ] Unroll loops
      
      Devirtualization / CFI:
      [ ] Cross-DSO CFI
      [ ] Whole program devirtualization
      [ ] Lower bitset metadata
      
      CGSCC passes:
      [ ] Function Integration/Inlining
      [ ] Remove unused exception handling info
      [ ] Promote 'by reference' arguments to scalars
      
      Please let me know if you are interested in working on any of the passes
      in the above list (e.g. reply to the post-commit thread for this patch).
      I'll probably be tackling "General Scalar" and "General IPO" first FWIW.
      
      Steps as I port "Deduce function attributes in RPO"
      ---------------------------------------------------
      
      (note: if you are doing any work based on these notes, please leave a
      note in the post-commit review thread for this commit with any
      improvements / suggestions / incompleteness you ran into!)
      
      Note: "Deduce function attributes in RPO" is a module pass.
      
      1. Do preparatory refactoring.
      
      Do preparatory factoring. In this case all I had to do was to pull out a static helper (r272503).
      (TODO: give more advice here e.g. if pass holds state or something)
      
      2. Rename the old pass class.
      
      llvm/lib/Transforms/IPO/FunctionAttrs.cpp
      Rename class ReversePostOrderFunctionAttrs -> ReversePostOrderFunctionAttrsLegacyPass
      in preparation for adding a class ReversePostOrderFunctionAttrs as the pass in the new PM.
      (edit: actually wait what? The new class name will be
      ReversePostOrderFunctionAttrsPass, so it doesn't conflict. So this step is
      sort of useless churn).
      
      llvm/include/llvm/InitializePasses.h
      llvm/lib/LTO/LTOCodeGenerator.cpp
      llvm/lib/Transforms/IPO/IPO.cpp
      llvm/lib/Transforms/IPO/FunctionAttrs.cpp
      Rename initializeReversePostOrderFunctionAttrsPass -> initializeReversePostOrderFunctionAttrsLegacyPassPass
      (note that the "PassPass" thing falls out of `s/ReversePostOrderFunctionAttrs/ReversePostOrderFunctionAttrsLegacyPass/`)
      Note that the INITIALIZE_PASS macro is what creates this identifier name, so renaming the class requires this renaming too.
      
      Note that createReversePostOrderFunctionAttrsPass does not need to be
      renamed since its name is not generated from the class name.
      
      3. Add the new PM pass class.
      
      In the new PM all passes need to have their
      declaration in a header somewhere, so you will often need to add a header.
      In this case
      llvm/include/llvm/Transforms/IPO/FunctionAttrs.h is already there because
      PostOrderFunctionAttrsPass was already ported.
      The file-level comment from the .cpp file can be used as the file-level
      comment for the new header. You may want to tweak the wording slightly
      from "this file implements" to "this file provides" or similar.
      
      Add declaration for the new PM pass in this header:
      
          class ReversePostOrderFunctionAttrsPass
              : public PassInfoMixin<ReversePostOrderFunctionAttrsPass> {
          public:
            PreservedAnalyses run(Module &M, AnalysisManager<Module> &AM);
          };
      
      Its name should end with `Pass` for consistency (note that this doesn't
      collide with the names of most old PM passes). E.g. call it
      `<name of the old PM pass>Pass`.
      
      Also, move the doxygen comment from the old PM pass to the declaration of
      this class in the header.
      Also, include the declaration for the new PM class
      `llvm/Transforms/IPO/FunctionAttrs.h` at the top of the file (in this case,
      it was already done when the other pass in this file was ported).
      
      Now define the `run` method for the new class.
      The main things here are:
      a) Use AM.getResult<...>(M) to get results instead of `getAnalysis<...>()`
      
      b) If the old PM pass would have returned "false" (i.e. `Changed ==
      false`), then you should return PreservedAnalyses::all();
      
      c) In the old PM getAnalysisUsage method, observe the calls
         `AU.addPreserved<...>();`.
      
         In the case `Changed == true`, for each preserved analysis you should do
         call `PA.preserve<...>()` on a PreservedAnalyses object and return it.
         E.g.:
      
             PreservedAnalyses PA;
             PA.preserve<CallGraphAnalysis>();
             return PA;
      
      Note that calls to skipModule/skipFunction are not supported in the new PM
      currently, so optnone and optimization bisect support do not work. You can
      just drop those calls for now.
      
      4. Add the pass to the new PM pass registry to make it available in opt.
      
      In llvm/lib/Passes/PassBuilder.cpp add a #include for your header.
      `#include "llvm/Transforms/IPO/FunctionAttrs.h"`
      In this case there is already an include (from when
      PostOrderFunctionAttrsPass was ported).
      
      Add your pass to llvm/lib/Passes/PassRegistry.def
      In this case, I added
      `MODULE_PASS("rpo-functionattrs", ReversePostOrderFunctionAttrsPass())`
      The string is from the `INITIALIZE_PASS*` macros used in the old pass
      manager.
      
      Then choose a test that uses the pass and use the new PM `-passes=...` to
      run it.
      E.g. in this case there is a test that does:
      ; RUN: opt < %s -basicaa -functionattrs -rpo-functionattrs -S | FileCheck %s
      I have added the line:
      ; RUN: opt < %s -aa-pipeline=basic-aa -passes='require<targetlibinfo>,cgscc(function-attrs),rpo-functionattrs' -S | FileCheck %s
      The `-aa-pipeline=basic-aa` and
      `require<targetlibinfo>,cgscc(function-attrs)` are what is needed to run
      functionattrs in the new PM (note that in the new PM "functionattrs"
      becomes "function-attrs" for some reason). This is just pulled from
      `readattrs.ll` which contains the change from when functionattrs was ported
      to the new PM.
      Adding rpo-functionattrs causes the pass that was just ported to run.
      
      llvm-svn: 272505
      f5080194
    • Amaury Sechet's avatar
      Make sure we have a Add/Remove/Has function for various thing that can have attribute. · 5db224e1
      Amaury Sechet authored
      Summary: This also deprecated the get attribute function familly.
      
      Reviewers: Wallbraker, whitequark, joker.eph, echristo, rafael, jyknight
      
      Subscribers: axw, joker.eph, llvm-commits
      
      Differential Revision: http://reviews.llvm.org/D19181
      
      llvm-svn: 272504
      5db224e1
    • Sean Silva's avatar
      Factor out a helper. NFC · adc79395
      Sean Silva authored
      Prep for porting to new PM.
      
      llvm-svn: 272503
      adc79395
    • Tobias Grosser's avatar
      Recommit: "Simplify min/max expression generation" · 43de1787
      Tobias Grosser authored
      As part of this simplification we pull complex logic out of the loop body and
      skip the previously redundantly executed first loop iteration.
      
      This is a partial recommit of r271514 and r271535 which where in conflict with
      the revert in r272483 and consequently also had to be reverted temporarily.  The
      original patch was contributed by Johannes Doerfert.
      
      This patch is mostly a NFC, but dropping the first loop iteration can sometimes
      result in slightly simpler code.
      
      llvm-svn: 272502
      43de1787
    • Craig Topper's avatar
      [X86] Pre-allocate some of the shuffle mask SmallVectors in the auto upgrade... · c0a5fa0a
      Craig Topper authored
      [X86] Pre-allocate some of the shuffle mask SmallVectors in the auto upgrade code instead of calling push_back in a loop. This removes the need to check if the vector needs to grow on each iteration.
      
      llvm-svn: 272501
      c0a5fa0a
    • Tobias Grosser's avatar
      Update isl to isl-0.17.1-57-g1879898 · 07b20952
      Tobias Grosser authored
      With this update the isl AST generation extracts disjunctive constraints early
      on. As a result, code that previously resulted in two branches with (close-to)
      identical code within them:
      
        if (P <= -1) {
          for (int c0 = 0; c0 < N; c0 += 1)
            Stmt_store(c0);
        } else if (P >= 1)
          for (int c0 = 0; c0 < N; c0 += 1)
             Stmt_store(c0);
      
      results now in only a single branch body:
      
        if (P <= -1 || P >= 1)
          for (int c0 = 0; c0 < N; c0 += 1)
             Stmt_store(c0);
      
      This resolves http://llvm.org/PR27559
      
      Besides the above change, this isl update brings better simplification of
      sets/maps containing existentially quantified dimensions and fixes a bug in
      isl's coalescing.
      
      llvm-svn: 272500
      07b20952
    • Tobias Grosser's avatar
      Expand test cases affected by next commit · 8620679e
      Tobias Grosser authored
      As these test cases will be changed in a subsequent commit, we expand and
      tighten them to make the subsequent changes to them more obvious. As part of
      this we add more context to some test cases and add CHECK-NEXT lines to ensure
      no intermediate lines are missed by accident.
      
      llvm-svn: 272499
      8620679e
    • Sean Silva's avatar
      [libprofile] Define an expansion `%clang_profgen=` · 537b1467
      Sean Silva authored
      llvm-svn: 272498
      537b1467
    • Craig Topper's avatar
      [AVX512] Remove the masked palignr intrinsics that I forgot to remove when I... · 251030ba
      Craig Topper authored
      [AVX512] Remove the masked palignr intrinsics that I forgot to remove when I added auto-upgrade code to turn them into shufflevectors and selects.
      
      llvm-svn: 272497
      251030ba
    • Craig Topper's avatar
      [X86] Greatly simplify the llvm.x86.avx.vpermil.* auto-upgrade code. We can... · 8a10505f
      Craig Topper authored
      [X86] Greatly simplify the llvm.x86.avx.vpermil.* auto-upgrade code. We can fully derive everything using types of the intrinsic arguments rather than writing separate loops for each intrinsic. NFC
      
      llvm-svn: 272496
      8a10505f
    • Eli Friedman's avatar
      [MergedLoadStoreMotion] Use correct helper for load hoist safety. · 9f8031c2
      Eli Friedman authored
      It isn't legal to hoist a load past a call which might not return;
      even if it doesn't throw, it could, for example, call exit().
      
      Fixes http://llvm.org/PR27953.
      
      llvm-svn: 272495
      9f8031c2
    • Craig Topper's avatar
      [X86] Move tests for llvm.x86.avx.vpermil.* intrinsics to a -upgrade test... · b7713e41
      Craig Topper authored
      [X86] Move tests for llvm.x86.avx.vpermil.* intrinsics to a -upgrade test since they are autoupgraded to shufflevector.
      
      llvm-svn: 272494
      b7713e41
    • Craig Topper's avatar
      [X86,IR] Make use of the CreateShuffleVector form that takes an... · 2f561827
      Craig Topper authored
      [X86,IR] Make use of the CreateShuffleVector form that takes an ArrayRef<uint32_t> to avoid the need to manually create a bunch of Constants and a ConstantVector. NFC
      
      llvm-svn: 272493
      2f561827
    • Craig Topper's avatar
      [CodeGen] Update to use an ArrayRef of uint32_t instead of int in calls to... · d1cb4cea
      Craig Topper authored
      [CodeGen] Update to use an ArrayRef of uint32_t instead of int in calls to CreateShuffleVector to match llvm interface change.
      
      llvm-svn: 272492
      d1cb4cea