[llvm] r273145 - Avoid output indeterminism between GCC and Clang builds.

Patrik Hagglund via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 20 03:19:05 PDT 2016


Author: patha
Date: Mon Jun 20 05:19:04 2016
New Revision: 273145

URL: http://llvm.org/viewvc/llvm-project?rev=273145&view=rev
Log:
Avoid output indeterminism between GCC and Clang builds.

Remove dependency of the evalution order of function arguments, which
is unspecified.

Patch by David Stenberg.

Modified:
    llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp

Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=273145&r1=273144&r2=273145&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Mon Jun 20 05:19:04 2016
@@ -1443,8 +1443,12 @@ Value *SCEVExpander::visitAddRecExpr(con
     }
 
     // Just do a normal add. Pre-expand the operands to suppress folding.
-    return expand(SE.getAddExpr(SE.getUnknown(expand(S->getStart())),
-                                SE.getUnknown(expand(Rest))));
+    //
+    // The LHS and RHS values are factored out of the expand call to make the
+    // output independent of the argument evaluation order.
+    const SCEV *AddExprLHS = SE.getUnknown(expand(S->getStart()));
+    const SCEV *AddExprRHS = SE.getUnknown(expand(Rest));
+    return expand(SE.getAddExpr(AddExprLHS, AddExprRHS));
   }
 
   // If we don't yet have a canonical IV, create one.




More information about the llvm-commits mailing list