]> granicus.if.org Git - clang/commitdiff
Argument evaluation order is not guaranteed. Split these out to force an order.
authorJohn McCall <rjmccall@apple.com>
Thu, 5 Aug 2010 18:11:10 +0000 (18:11 +0000)
committerJohn McCall <rjmccall@apple.com>
Thu, 5 Aug 2010 18:11:10 +0000 (18:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110354 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprScalar.cpp

index 8d28b2485f2f9ebdb2dfc5f66fb1ad3c9e62882e..08d340ef7b50300fe3d1922c20586fe783fbebdf 100644 (file)
@@ -1576,12 +1576,13 @@ Value *ScalarExprEmitter::EmitOverflowCheckedBinOp(const BinOpInfo &Ops) {
         llvm::PointerType::getUnqual(handlerTy));
   handlerFunction = Builder.CreateLoad(handlerFunction);
 
-  llvm::Value *handlerResult = Builder.CreateCall4(handlerFunction,
-      Builder.CreateSExt(Ops.LHS, CGF.Int64Ty),
-      Builder.CreateSExt(Ops.RHS, CGF.Int64Ty),
-      llvm::ConstantInt::get(llvm::Type::getInt8Ty(VMContext), OpID),
-      llvm::ConstantInt::get(llvm::Type::getInt8Ty(VMContext),
-        cast<llvm::IntegerType>(opTy)->getBitWidth()));
+  llvm::Value *lhs = Builder.CreateSExt(Ops.LHS, CGF.Int64Ty);
+  llvm::Value *rhs = Builder.CreateSExt(Ops.RHS, CGF.Int64Ty);
+
+  llvm::Value *handlerResult =
+    Builder.CreateCall4(handlerFunction, lhs, rhs,
+                        Builder.getInt8(OpID),
+              Builder.getInt8(cast<llvm::IntegerType>(opTy)->getBitWidth()));
 
   handlerResult = Builder.CreateTrunc(handlerResult, opTy);