Skip to content
  1. Mar 10, 2014
    • Evan Cheng's avatar
      For functions with ARM target specific calling convention, when simplify-libcall · 0e8f4612
      Evan Cheng authored
      optimize a call to a llvm intrinsic to something that invovles a call to a C
      library call, make sure it sets the right calling convention on the call.
      
      e.g.
      extern double pow(double, double);
      double t(double x) {
        return pow(10, x);
      }
      
      Compiles to something like this for AAPCS-VFP:
      define arm_aapcs_vfpcc double @t(double %x) #0 {
      entry:
        %0 = call double @llvm.pow.f64(double 1.000000e+01, double %x)
        ret double %0
      }
      
      declare double @llvm.pow.f64(double, double) #1
      
      Simplify libcall (part of instcombine) will turn the above into:
      define arm_aapcs_vfpcc double @t(double %x) #0 {
      entry:
        %__exp10 = call double @__exp10(double %x) #1
        ret double %__exp10
      }
      
      declare double @__exp10(double)
      
      The pre-instcombine code works because calls to LLVM builtins are special.
      Instruction selection will chose the right calling convention for the call.
      However, the code after instcombine is wrong. The call to __exp10 will use
      the C calling convention.
      
      I can think of 3 options to fix this.
      
      1. Make "C" calling convention just work since the target should know what CC
         is being used.
      
         This doesn't work because each function can use different CC with the "pcs"
         attribute.
      
      2. Have Clang add the right CC keyword on the calls to LLVM builtin.
      
         This will work but it doesn't match the LLVM IR specification which states
         these are "Standard C Library Intrinsics".
      
      3. Fix simplify libcall so the resulting calls to the C routines will have the
         proper CC keyword. e.g.
         %__exp10 = call arm_aapcs_vfpcc double @__exp10(double %x) #1
      
         This works and is the solution I implemented here.
      
      Both solutions #2 and #3 would work. After carefully considering the pros and
      cons, I decided to implement #3 for the following reasons.
      
      1. It doesn't change the "spec" of the intrinsics.
      2. It's a self-contained fix.
      
      There are a couple of potential downsides.
      1. There could be other places in the optimizer that is broken in the same way
         that's not addressed by this.
      2. There could be other calling conventions that need to be propagated by
         simplify-libcall that's not handled.
      
      But for now, this is the fix that I'm most comfortable with.
      
      llvm-svn: 203488
      0e8f4612
  2. Mar 09, 2014
    • Benjamin Kramer's avatar
      SimplifyCFG: Simplify the weight scaling algorithm. · 79da941f
      Benjamin Kramer authored
      No change in functionality.
      
      llvm-svn: 203413
      79da941f
    • Ahmed Charles's avatar
      Fix build break. · 5d461ede
      Ahmed Charles authored
      llvm-svn: 203366
      5d461ede
    • Chandler Carruth's avatar
      [C++11] Add range based accessors for the Use-Def chain of a Value. · cdf47884
      Chandler Carruth authored
      This requires a number of steps.
      1) Move value_use_iterator into the Value class as an implementation
         detail
      2) Change it to actually be a *Use* iterator rather than a *User*
         iterator.
      3) Add an adaptor which is a User iterator that always looks through the
         Use to the User.
      4) Wrap these in Value::use_iterator and Value::user_iterator typedefs.
      5) Add the range adaptors as Value::uses() and Value::users().
      6) Update *all* of the callers to correctly distinguish between whether
         they wanted a use_iterator (and to explicitly dig out the User when
         needed), or a user_iterator which makes the Use itself totally
         opaque.
      
      Because #6 requires churning essentially everything that walked the
      Use-Def chains, I went ahead and added all of the range adaptors and
      switched them to range-based loops where appropriate. Also because the
      renaming requires at least churning every line of code, it didn't make
      any sense to split these up into multiple commits -- all of which would
      touch all of the same lies of code.
      
      The result is still not quite optimal. The Value::use_iterator is a nice
      regular iterator, but Value::user_iterator is an iterator over User*s
      rather than over the User objects themselves. As a consequence, it fits
      a bit awkwardly into the range-based world and it has the weird
      extra-dereferencing 'operator->' that so many of our iterators have.
      I think this could be fixed by providing something which transforms
      a range of T&s into a range of T*s, but that *can* be separated into
      another patch, and it isn't yet 100% clear whether this is the right
      move.
      
      However, this change gets us most of the benefit and cleans up
      a substantial amount of code around Use and User. =]
      
      llvm-svn: 203364
      cdf47884
  3. Mar 07, 2014
  4. Mar 06, 2014
  5. Mar 05, 2014
  6. Mar 04, 2014
  7. Mar 03, 2014
    • Diego Novillo's avatar
      Pass to emit DWARF path discriminators. · f5041ce5
      Diego Novillo authored
      DWARF discriminators are used to distinguish multiple control flow paths
      on the same source location. When this happens, instructions across
      basic block boundaries will share the same debug location.
      
      This pass detects this situation and creates a new lexical scope to one
      of the two instructions. This lexical scope is a child scope of the
      original and contains a new discriminator value. This discriminator is
      then picked up from MCObjectStreamer::EmitDwarfLocDirective to be
      written on the object file.
      
      This fixes http://llvm.org/bugs/show_bug.cgi?id=18270.
      
      llvm-svn: 202752
      f5041ce5
    • Benjamin Kramer's avatar
      [C++11] Use std::tie to simplify compare operators. · b2f034b8
      Benjamin Kramer authored
      No functionality change.
      
      llvm-svn: 202751
      b2f034b8
    • Benjamin Kramer's avatar
      [C++11] Remove a leftover std::function instance. · 9c794c7a
      Benjamin Kramer authored
      It's not needed anymore.
      
      llvm-svn: 202748
      9c794c7a
    • Chandler Carruth's avatar
      [C++11] Remove the completely unnecessary requirement on SetVector's · d031fe9f
      Chandler Carruth authored
      remove_if that its predicate is adaptable. We don't actually need this,
      we can write a generic adapter for any predicate.
      
      This lets us remove some very wrong std::function usages. We should
      never be using std::function for predicates to algorithms. This incurs
      an *indirect* call overhead for every evaluation of the predicate, and
      makes it very hard to inline through.
      
      llvm-svn: 202742
      d031fe9f
    • Evgeniy Stepanov's avatar
      [msan] Handle X86 SIMD bitshift intrinsics. · 77be532f
      Evgeniy Stepanov authored
      llvm-svn: 202712
      77be532f
    • Tobias Grosser's avatar
      [C++11] Add a basic block range view for RegionInfo · 4abf9d3a
      Tobias Grosser authored
      This also switches the users in LLVM to ensure this functionality is tested.
      
      llvm-svn: 202705
      4abf9d3a
    • Chandler Carruth's avatar
      [C++11] Add two range adaptor views to User: operands and · 1583e99c
      Chandler Carruth authored
      operand_values. The first provides a range view over operand Use
      objects, and the second provides a range view over the Value*s being
      used by those operands.
      
      The naming is "STL-style" rather than "LLVM-style" because we have
      historically named iterator methods STL-style, and range methods seem to
      have far more in common with their iterator counterparts than with
      "normal" APIs. Feel free to bikeshed on this one if you want, I'm happy
      to change these around if people feel strongly.
      
      I've switched code in SROA and LCG to exercise these mostly to ensure
      they work correctly -- we don't really have an easy way to unittest this
      and they're trivial.
      
      llvm-svn: 202687
      1583e99c
  8. Mar 02, 2014
  9. Mar 01, 2014
Loading