1. 23 7月, 2014 3 次提交
    • B
      auto merge of #15869 : alexcrichton/rust/issue-15828, r=kballard · bc6bbc3d
      bors 提交于
      Closes #15828
      bc6bbc3d
    • B
      auto merge of #15863 : dotdash/rust/lifetimes3, r=alexcrichton · 31c908b7
      bors 提交于
      Lifetime intrinsics help to reduce stack usage, because LLVM can apply
      stack coloring to reuse the stack slots of dead allocas for new ones.
      
      For example these functions now both use the same amount of stack, while
      previous `bar()` used five times as much as `foo()`:
      
      ````rust
      fn foo() {
        println("{}", 5);
      }
      
      fn bar() {
        println("{}", 5);
        println("{}", 5);
        println("{}", 5);
        println("{}", 5);
        println("{}", 5);
      }
      ````
      
      On top of that, LLVM can also optimize out certain operations when it
      knows that memory is dead after a certain point. For example, it can
      sometimes remove the zeroing used to cancel the drop glue. This is
      possible when the glue drop itself was already removed because the
      zeroing dominated the drop glue call. For example in:
      
      ````rust
      pub fn bar(x: (Box<int>, int)) -> (Box<int>, int) {
          x
      }
      ````
      
      With optimizations, this currently results in:
      
      ````llvm
      define void @_ZN3bar20h330fa42547df8179niaE({ i64*, i64 }* noalias nocapture nonnull sret, { i64*, i64 }* noalias nocapture nonnull) unnamed_addr #0 {
      "_ZN29_$LP$Box$LT$int$GT$$C$int$RP$39glue_drop.$x22glue_drop$x22$LP$1347$RP$17h88cf42702e5a322aE.exit":
        %2 = bitcast { i64*, i64 }* %1 to i8*
        %3 = bitcast { i64*, i64 }* %0 to i8*
        tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %3, i8* %2, i64 16, i32 8, i1 false)
        tail call void @llvm.memset.p0i8.i64(i8* %2, i8 0, i64 16, i32 8, i1 false)
        ret void
      }
      ````
      
      But with lifetime intrinsics we get:
      
      ````llvm
      define void @_ZN3bar20h330fa42547df8179niaE({ i64*, i64 }* noalias nocapture nonnull sret, { i64*, i64 }* noalias nocapture nonnull) unnamed_addr #0 {
      "_ZN29_$LP$Box$LT$int$GT$$C$int$RP$39glue_drop.$x22glue_drop$x22$LP$1347$RP$17h88cf42702e5a322aE.exit":
        %2 = bitcast { i64*, i64 }* %1 to i8*
        %3 = bitcast { i64*, i64 }* %0 to i8*
        tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %3, i8* %2, i64 16, i32 8, i1 false)
        tail call void @llvm.lifetime.end(i64 16, i8* %2)
        ret void
      }
      ````
      
      Fixes #15665
      31c908b7
    • B
      auto merge of #15857 : treeman/rust/doc-dijkstra-example, r=alexcrichton · 2ffccb76
      bors 提交于
      I wanted to have a slightly larger example compared to the method examples, but I'm unsure how it worked out.
      
      Feedback would nice.
      2ffccb76
  2. 22 7月, 2014 37 次提交