[llvm-commits] [llvm] r97288 - in /llvm/trunk: lib/Transforms/Scalar/SCCP.cpp test/Transforms/SCCP/retvalue-undef.ll

Daniel Dunbar daniel at zuster.org
Fri Feb 26 23:22:22 PST 2010


On Fri, Feb 26, 2010 at 4:07 PM, Chris Lattner <sabre at nondot.org> wrote:
> Author: lattner
> Date: Fri Feb 26 18:07:42 2010
> New Revision: 97288
>
> URL: http://llvm.org/viewvc/llvm-project?rev=97288&view=rev
> Log:
> fix PR6414, a nondeterminism issue in IPSCCP which was because
> of a subtle interation in a loop operating in densemap order.
>
> Added:
>    llvm/trunk/test/Transforms/SCCP/retvalue-undef.ll
> Modified:
>    llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
>
> Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=97288&r1=97287&r2=97288&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Fri Feb 26 18:07:42 2010
> @@ -1918,6 +1918,14 @@
>   // all call uses with the inferred value.  This means we don't need to bother
>   // actually returning anything from the function.  Replace all return
>   // instructions with return undef.
> +  //
> +  // Do this in two stages: first identify the functions we should process, then
> +  // actually zap their returns.  This is important because we can only do this
> +  // the address of the function isn't taken.  In cases where a return is the
> +  // last use of a function, the order of processing functions would affect
> +  // whether we other functions are optimizable.

Grammaros: "this the address" and "whether we other"

 - Daniel

> +  SmallVector<ReturnInst*, 8> ReturnsToZap;
> +
>   // TODO: Process multiple value ret instructions also.
>   const DenseMap<Function*, LatticeVal> &RV = Solver.getTrackedRetVals();
>   for (DenseMap<Function*, LatticeVal>::const_iterator I = RV.begin(),
> @@ -1933,7 +1941,13 @@
>     for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
>       if (ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator()))
>         if (!isa<UndefValue>(RI->getOperand(0)))
> -          RI->setOperand(0, UndefValue::get(F->getReturnType()));
> +          ReturnsToZap.push_back(RI);
> +  }
> +
> +  // Zap all returns which we've identified as zap to change.
> +  for (unsigned i = 0, e = ReturnsToZap.size(); i != e; ++i) {
> +    Function *F = ReturnsToZap[i]->getParent()->getParent();
> +    ReturnsToZap[i]->setOperand(0, UndefValue::get(F->getReturnType()));
>   }
>
>   // If we infered constant or undef values for globals variables, we can delete
>
> Added: llvm/trunk/test/Transforms/SCCP/retvalue-undef.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/retvalue-undef.ll?rev=97288&view=auto
> ==============================================================================
> --- llvm/trunk/test/Transforms/SCCP/retvalue-undef.ll (added)
> +++ llvm/trunk/test/Transforms/SCCP/retvalue-undef.ll Fri Feb 26 18:07:42 2010
> @@ -0,0 +1,32 @@
> +; RUN: opt -ipsccp -S %s | FileCheck %s
> +; PR6414
> +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
> +target triple = "x86_64-unknown-linux-gnu"
> +
> +define internal i32 ()* @f() {
> +  ret i32 ()* @g
> +}
> +
> +define internal i32 @g() {
> +  ret i32 8
> +}
> +
> +; CHECK: internal i32 @g()
> +; CHECK-NEXT: ret i32 8
> +
> +define internal void @outer_mod() {
> +  %1 = call i32 ()* ()* @f()                      ; <i32 ()*> [#uses=1]
> +  %2 = call i32 %1()                              ; <i32> [#uses=0]
> +  ret void
> +}
> +
> +define internal void @module_init() {
> +  call void @register_outer_mod(void ()* @outer_mod)
> +  ret void
> +}
> +
> +declare void @register_outer_mod(void ()*)
> +
> +define i32 @main() {
> +  ret i32 0
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list