Skip to content
  1. Mar 02, 2014
  2. Feb 25, 2014
    • Rafael Espindola's avatar
      Fix resetting the DataLayout in a Module. · 248ac139
      Rafael Espindola authored
      No tool does this currently, but as everything else in a module we should be
      able to change its DataLayout.
      
      Most of the fix is in DataLayout to make sure it can be reset properly.
      
      The test uses Module::setDataLayout since the fact that we mutate a DataLayout
      is an implementation detail. The module could hold a OwningPtr<DataLayout> and
      the DataLayout itself could be immutable.
      
      Thanks to Philip Reames for pushing me in the right direction.
      
      llvm-svn: 202198
      248ac139
    • Rafael Espindola's avatar
      Make DataLayout a plain object, not a pass. · 93512512
      Rafael Espindola authored
      Instead, have a DataLayoutPass that holds one. This will allow parts of LLVM
      don't don't handle passes to also use DataLayout.
      
      llvm-svn: 202168
      93512512
  3. Feb 05, 2014
    • Chandler Carruth's avatar
      [PM] Don't require analysis results to be const in the new pass manager. · eedf9fca
      Chandler Carruth authored
      I think this was just over-eagerness on my part. The analysis results
      need to often be non-const because they need to (in some cases at least)
      be updated by the transformation pass in order to remain correct. It
      also makes lazy analyses (a common case) needlessly annoying to write in
      order to make their entire state mutable.
      
      llvm-svn: 200881
      eedf9fca
  4. Jan 22, 2014
    • Matt Arsenault's avatar
      Bug 18228 - Fix accepting bitcasts between vectors of pointers with a · fc3c91d0
      Matt Arsenault authored
      different number of elements.
      
      Bitcasts were passing with vectors of pointers with different number of
      elements since the number of elements was checking
      SrcTy->getVectorNumElements() == SrcTy->getVectorNumElements() which
      isn't helpful. The addrspacecast was also wrong, but that case at least
      is caught by the verifier. Refactor bitcast and addrspacecast handling
      in castIsValid to be more readable and fix this problem.
      
      llvm-svn: 199821
      fc3c91d0
  5. Jan 19, 2014
    • Chandler Carruth's avatar
      [PM] Make the verifier work independently of any pass manager. · 043949d4
      Chandler Carruth authored
      This makes the 'verifyFunction' and 'verifyModule' functions totally
      independent operations on the LLVM IR. It also cleans up their API a bit
      by lifting the abort behavior into their clients and just using an
      optional raw_ostream parameter to control printing.
      
      The implementation of the verifier is now just an InstVisitor with no
      multiple inheritance. It also is significantly more const-correct, and
      hides the const violations internally. The two layers that force us to
      break const correctness are building a DomTree and dispatching through
      the InstVisitor.
      
      A new VerifierPass is used to implement the legacy pass manager
      interface in terms of the other pieces.
      
      The error messages produced may be slightly different now, and we may
      have slightly different short circuiting behavior with different usage
      models of the verifier, but generally everything works equivalently and
      this unblocks wiring the verifier up to the new pass manager.
      
      llvm-svn: 199569
      043949d4
  6. Jan 13, 2014
    • Chandler Carruth's avatar
      [PM] Split DominatorTree into a concrete analysis result object which · 73523021
      Chandler Carruth authored
      can be used by both the new pass manager and the old.
      
      This removes it from any of the virtual mess of the pass interfaces and
      lets it derive cleanly from the DominatorTreeBase<> template. In turn,
      tons of boilerplate interface can be nuked and it turns into a very
      straightforward extension of the base DominatorTree interface.
      
      The old analysis pass is now a simple wrapper. The names and style of
      this split should match the split between CallGraph and
      CallGraphWrapperPass. All of the users of DominatorTree have been
      updated to match using many of the same tricks as with CallGraph. The
      goal is that the common type remains the resulting DominatorTree rather
      than the pass. This will make subsequent work toward the new pass
      manager significantly easier.
      
      Also in numerous places things became cleaner because I switched from
      re-running the pass (!!! mid way through some other passes run!!!) to
      directly recomputing the domtree.
      
      llvm-svn: 199104
      73523021
    • Chandler Carruth's avatar
      [cleanup] Move the Dominators.h and Verifier.h headers into the IR · 5ad5f15c
      Chandler Carruth authored
      directory. These passes are already defined in the IR library, and it
      doesn't make any sense to have the headers in Analysis.
      
      Long term, I think there is going to be a much better way to divide
      these matters. The dominators code should be fully separated into the
      abstract graph algorithm and have that put in Support where it becomes
      obvious that evn Clang's CFGBlock's can use it. Then the verifier can
      manually construct dominance information from the Support-driven
      interface while the Analysis library can provide a pass which both
      caches, reconstructs, and supports a nice update API.
      
      But those are very long term, and so I don't want to leave the really
      confusing structure until that day arrives.
      
      llvm-svn: 199082
      5ad5f15c
  7. Jan 12, 2014
  8. Jan 11, 2014
  9. Jan 07, 2014
    • Chandler Carruth's avatar
      Move the LLVM IR asm writer header files into the IR directory, as they · 9aca918d
      Chandler Carruth authored
      are part of the core IR library in order to support dumping and other
      basic functionality.
      
      Rename the 'Assembly' include directory to 'AsmParser' to match the
      library name and the only functionality left their -- printing has been
      in the core IR library for quite some time.
      
      Update all of the #includes to match.
      
      All of this started because I wanted to have the layering in good shape
      before I started adding support for printing LLVM IR using the new pass
      infrastructure, and commandline support for the new pass infrastructure.
      
      llvm-svn: 198688
      9aca918d
  10. Jan 05, 2014
  11. Jan 02, 2014
  12. Jan 01, 2014
  13. Dec 13, 2013
  14. Dec 10, 2013
  15. Dec 05, 2013
  16. Dec 02, 2013
    • Diego Novillo's avatar
      Fix dominator descendants for unreachable blocks. · ee592429
      Diego Novillo authored
      When a block is unreachable, asking its dom tree descendants should
      return the empty set. However, the computation of the descendants
      was causing a segmentation fault because the dom tree node we get
      from the basic block is initially NULL.
      
      Fixed by adding a test for a valid dom tree node before we iterate.
      
      The patch also adds some unit tests to the existing dom tree tests.
      
      llvm-svn: 196099
      ee592429
  17. Nov 26, 2013
    • Chandler Carruth's avatar
      [PM] Split the CallGraph out from the ModulePass which creates the · 6378cf53
      Chandler Carruth authored
      CallGraph.
      
      This makes the CallGraph a totally generic analysis object that is the
      container for the graph data structure and the primary interface for
      querying and manipulating it. The pass logic is separated into its own
      class. For compatibility reasons, the pass provides wrapper methods for
      most of the methods on CallGraph -- they all just forward.
      
      This will allow the new pass manager infrastructure to provide its own
      analysis pass that constructs the same CallGraph object and makes it
      available. The idea is that in the new pass manager, the analysis pass's
      'run' method returns a concrete analysis 'result'. Here, that result is
      a 'CallGraph'. The 'run' method will typically do only minimal work,
      deferring much of the work into the implementation of the result object
      in order to be lazy about computing things, but when (like DomTree)
      there is *some* up-front computation, the analysis does it prior to
      handing the result back to the querying pass.
      
      I know some of this is fairly ugly. I'm happy to change it around if
      folks can suggest a cleaner interim state, but there is going to be some
      amount of unavoidable ugliness during the transition period. The good
      thing is that this is very limited and will naturally go away when the
      old pass infrastructure goes away. It won't hang around to bother us
      later.
      
      Next up is the initial new-PM-style call graph analysis. =]
      
      llvm-svn: 195722
      6378cf53
  18. Nov 23, 2013
    • Chandler Carruth's avatar
      [PM] Complete the cross-layer interfaces with a Module-to-Function · c1ff9ed6
      Chandler Carruth authored
      proxy. This lets a function pass query a module analysis manager.
      However, the interface is const to indicate that only cached results can
      be safely queried.
      
      With this, I think the new pass manager is largely functionally complete
      for modules and analyses. Still lots to test, and need to generalize to
      SCCs and Loops, and need to build an adaptor layer to support the use of
      existing Pass objects in the new managers.
      
      llvm-svn: 195538
      c1ff9ed6
    • Chandler Carruth's avatar
      [PM] Rename TestAnalysisPass to TestFunctionAnalysis to clear the way · 2ad18583
      Chandler Carruth authored
      for a TestModuleAnalysis.
      
      llvm-svn: 195537
      2ad18583
    • Chandler Carruth's avatar
      [PM] Add support to the analysis managers to query explicitly for cached · de9afd84
      Chandler Carruth authored
      results.
      
      This is the last piece of infrastructure needed to effectively support
      querying *up* the analysis layers. The next step will be to introduce
      a proxy which provides access to those layers with appropriate use of
      const to direct queries to the safe interface.
      
      llvm-svn: 195525
      de9afd84
    • Chandler Carruth's avatar
      [PM] Switch the downward invalidation to be incremental where only the · bceeb229
      Chandler Carruth authored
      one function's analyses are invalidated at a time. Also switch the
      preservation of the proxy to *fully* preserve the lower (function)
      analyses.
      
      Combined, this gets both upward and downward analysis invalidation to
      a point I'm happy with:
      
      - A function pass invalidates its function analyses, and its parent's
        module analyses.
      - A module pass invalidates all of its functions' analyses including the
        set of which functions are in the module.
      - A function pass can preserve a module analysis pass.
      - If all function passes preserve a module analysis pass, that
        preservation persists. If any doesn't the module analysis is
        invalidated.
      - A module pass can opt into managing *all* function analysis
        invalidation itself or *none*.
      - The conservative default is none, and the proxy takes the maximally
        conservative approach that works even if the set of functions has
        changed.
      - If a module pass opts into managing function analysis invalidation it
        has to propagate the invalidation itself, the proxy just does nothing.
      
      The only thing really missing is a way to query for a cached analysis or
      nothing at all. With this, function passes can more safely request
      a cached module analysis pass without fear of it accidentally running
      part way through.
      
      llvm-svn: 195519
      bceeb229
  19. Nov 22, 2013
    • Chandler Carruth's avatar
      [PM] Teach the analysis managers to pass themselves as arguments to the · f2edc075
      Chandler Carruth authored
      run methods of the analysis passes.
      
      Also generalizes and re-uses the SFINAE for transformation passes so
      that users can write an analysis pass and only accept an analysis
      manager if that is useful to their pass.
      
      This completes the plumbing to make an analysis manager available
      through every pass's run method if desired so that passes no longer need
      to be constructed around them.
      
      llvm-svn: 195451
      f2edc075
    • Chandler Carruth's avatar
      [PM] Remove the IRUnitT typedef requirement for analysis passes. · bf950c0f
      Chandler Carruth authored
      Since the analysis managers were split into explicit function and module
      analysis managers, it is now completely trivial to specify this when
      building up the concept and model types explicitly, and it is impossible
      to end up with a type error at run time. We instantiate a template when
      registering a pass that will enforce the requirement at a type-system
      level, and we produce a dynamic error on all the other query paths to
      the analysis manager if the pass in question isn't registered.
      
      llvm-svn: 195447
      bf950c0f
    • Chandler Carruth's avatar
      [PM] Fix the analysis templates' usage of IRUnitT. · 5bf5e31c
      Chandler Carruth authored
      This is supposed to be the whole type of the IR unit, and so we
      shouldn't pass a pointer to it but rather the value itself. In turn, we
      need to provide a 'Module *' as that type argument (for example). This
      will become more relevant with SCCs or other units which may not be
      passed as a pointer type, but also brings consistency with the
      transformation pass templates.
      
      llvm-svn: 195445
      5bf5e31c
    • Chandler Carruth's avatar
      [PM] Switch analysis managers to be threaded through the run methods · b3e72199
      Chandler Carruth authored
      rather than the constructors of passes.
      
      This simplifies the APIs of passes significantly and removes an error
      prone pattern where the *same* manager had to be given to every
      different layer. With the new API the analysis managers themselves will
      have to be cross connected with proxy analyses that allow a pass at one
      layer to query for the analysis manager of another layer. The proxy will
      both expose a handle to the other layer's manager and it will provide
      the invalidation hooks to ensure things remain consistent across layers.
      Finally, the outer-most analysis manager has to be passed to the run
      method of the outer-most pass manager. The rest of the propagation is
      automatic.
      
      I've used SFINAE again to allow passes to completely disregard the
      analysis manager if they don't need or want to care. This helps keep
      simple things simple for users of the new pass manager.
      
      Also, the system specifically supports passing a null pointer into the
      outer-most run method if your pass pipeline neither needs nor wants to
      deal with analyses. I find this of dubious utility as while some
      *passes* don't care about analysis, I'm not sure there are any
      real-world users of the pass manager itself that need to avoid even
      creating an analysis manager. But it is easy to support, so there we go.
      
      Finally I renamed the module proxy for the function analysis manager to
      the more verbose but less confusing name of
      FunctionAnalysisManagerModuleProxy. I hate this name, but I have no idea
      what else to name these things. I'm expecting in the fullness of time to
      potentially have the complete cross product of types at the proxy layer:
      
      {Module,SCC,Function,Loop,Region}AnalysisManager{Module,SCC,Function,Loop,Region}Proxy
      
      (except for XAnalysisManagerXProxy which doesn't make any sense)
      
      This should make it somewhat easier to do the next phases which is to
      build the upward proxy and get its invalidation correct, as well as to
      make the invalidation within the Module -> Function mapping pass be more
      fine grained so as to invalidate fewer fuction analyses.
      
      After all of the proxy analyses are done and the invalidation working,
      I'll finally be able to start working on the next two fun fronts: how to
      adapt an existing pass to work in both the legacy pass world and the new
      one, and building the SCC, Loop, and Region counterparts. Fun times!
      
      llvm-svn: 195400
      b3e72199
  20. Nov 21, 2013
    • Chandler Carruth's avatar
      [PM] Widen the interface for invalidate on an analysis result now that · 2846e9ef
      Chandler Carruth authored
      it is completely optional, and sink the logic for handling the preserved
      analysis set into it.
      
      This allows us to implement the delegation logic desired in the proxy
      module analysis for the function analysis manager where if the proxy
      itself is preserved we assume the set of functions hasn't changed and we
      do a fine grained invalidation by walking the functions in the module
      and running the invalidate for them all at the manager level and letting
      it try to invalidate any passes.
      
      This in turn makes it blindingly obvious why we should hoist the
      invalidate trait and have two collections of results. That allows
      handling invalidation for almost all analyses without indirect calls and
      it allows short circuiting when the preserved set is all.
      
      llvm-svn: 195338
      2846e9ef
    • Chandler Carruth's avatar
      [PM] Add support for using SFINAE to reflect on an analysis's result · f6e9986a
      Chandler Carruth authored
      type and detect whether or not it provides an 'invalidate' member the
      analysis manager should use.
      
      This lets the overwhelming common case of *not* caring about custom
      behavior when an analysis is invalidated be the the obvious default
      behavior with no code written by the author of an analysis. Only when
      they write code specifically to handle invalidation does it get used.
      
      Both cases are actually covered by tests here. The test analysis uses
      the default behavior, and the proxy module analysis actually has custom
      behavior on invalidation that is firing correctly. (In fact, this is the
      analysis which was the primary motivation for having custom invalidation
      behavior in the first place.)
      
      llvm-svn: 195332
      f6e9986a
    • Chandler Carruth's avatar
      [PM] Add a module analysis pass proxy for the function analysis manager. · 851a2aa0
      Chandler Carruth authored
      This proxy will fill the role of proxying invalidation events down IR
      unit layers so that when a module changes we correctly invalidate
      function analyses. Currently this is a very coarse solution -- any
      change blows away the entire thing -- but the next step is to make
      invalidation handling more nuanced so that we can propagate specific
      amounts of invalidation from one layer to the next.
      
      The test is extended to place a module pass between two function pass
      managers each of which have preserved function analyses which get
      correctly invalidated by the module pass that might have changed what
      functions are even in the module.
      
      llvm-svn: 195304
      851a2aa0
  21. Nov 20, 2013
    • Chandler Carruth's avatar
      [PM] Add the preservation system to the new pass manager. · c0bfa8c2
      Chandler Carruth authored
      This adds a new set-like type which represents a set of preserved
      analysis passes. The set is managed via the opaque PassT::ID() void*s.
      The expected convenience templates for interacting with specific passes
      are provided. It also supports a symbolic "all" state which is
      represented by an invalid pointer in the set. This state is nicely
      saturating as it comes up often. Finally, it supports intersection which
      is used when finding the set of preserved passes after N different
      transforms.
      
      The pass API is then changed to return the preserved set rather than
      a bool. This is much more self-documenting than the previous system.
      Returning "none" is a conservatively correct solution just like
      returning "true" from todays passes and not marking any passes as
      preserved. Passes can also be dynamically preserved or not throughout
      the run of the pass, and whatever gets returned is the binding state.
      Finally, preserving "all" the passes is allowed for no-op transforms
      that simply can't harm such things.
      
      Finally, the analysis managers are changed to instead of blindly
      invalidating all of the analyses, invalidate those which were not
      preserved. This should rig up all of the basic preservation
      functionality. This also correctly combines the preservation moving up
      from one IR-layer to the another and the preservation aggregation across
      N pass runs. Still to go is incrementally correct invalidation and
      preservation across IR layers incrementally during N pass runs. That
      will wait until we have a device for even exposing analyses across IR
      layers.
      
      While the core of this change is obvious, I'm not happy with the current
      testing, so will improve it to cover at least some of the invalidation
      that I can test easily in a subsequent commit.
      
      llvm-svn: 195241
      c0bfa8c2
    • Chandler Carruth's avatar
      [PM] Make the function pass manager more regular. · d895e29e
      Chandler Carruth authored
      The FunctionPassManager is now itself a function pass. When run over
      a function, it runs all N of its passes over that function. This is the
      1:N mapping in the pass dimension only. This allows it to be used in
      either a ModulePassManager or potentially some other manager that
      works on IR units which are supersets of Functions.
      
      This commit also adds the obvious adaptor to map from a module pass to
      a function pass, running the function pass across every function in the
      module.
      
      The test has been updated to use this new pattern.
      
      llvm-svn: 195192
      d895e29e
    • Chandler Carruth's avatar
      [PM] Split the analysis manager into a function-specific interface and · ed1ffe01
      Chandler Carruth authored
      a module-specific interface. This is the first of many steps necessary
      to generalize the infrastructure such that we can support both
      a Module-to-Function and Module-to-SCC-to-Function pass manager
      nestings.
      
      After a *lot* of attempts that never worked and didn't even make it to
      a committable state, it became clear that I had gotten the layering
      design of analyses flat out wrong. Four days later, I think I have most
      of the plan for how to correct this, and I'm starting to reshape the
      code into it. This is just a baby step I'm afraid, but starts separating
      the fundamentally distinct concepts of function analysis passes and
      module analysis passes so that in subsequent steps we can effectively
      layer them, and have a consistent design for the eventual SCC layer.
      
      As part of this, I've started some interface changes to make passes more
      regular. The module pass accepts the module in the run method, and some
      of the constructor parameters are gone. I'm still working out exactly
      where constructor parameters vs. method parameters will be used, so
      I expect this to fluctuate a bit.
      
      This actually makes the invalidation less "correct" at this phase,
      because now function passes don't invalidate module analysis passes, but
      that was actually somewhat of a misfeature. It will return in a better
      factored form which can scale to other units of IR. The documentation
      has gotten less verbose and helpful.
      
      llvm-svn: 195189
      ed1ffe01
  22. Nov 17, 2013
  23. Nov 15, 2013
Loading