[cfe-commits] r172352 - /cfe/trunk/lib/CodeGen/CGBuiltin.cpp

NAKAMURA Takumi geek4civic at gmail.com
Sun Jan 13 03:26:44 PST 2013


Author: chapuni
Date: Sun Jan 13 05:26:44 2013
New Revision: 172352

URL: http://llvm.org/viewvc/llvm-project?rev=172352&view=rev
Log:
CGBuiltin.cpp: Fix abuse of ArrayRef in EmitOverflowIntrinsic().

In ArrayRef<T>(X), X should not be temporary value. It could be rewritten more redundantly;

  llvm::Type *XTy = X->getType();
  ArrayRef<llvm::Type *> Ty(XTy);
  llvm::Value *Callee = CGF.CGM.getIntrinsic(IntrinsicID, Ty);

Since it is safe if both XTy and Ty are temporary value in one statement, it could be shorten;

  llvm::Value *Callee = CGF.CGM.getIntrinsic(IntrinsicID, ArrayRef<llvm::Type*>(X->getType()));

ArrayRef<T> has an implicit constructor to create uni-entry of T;

  llvm::Value *Callee = CGF.CGM.getIntrinsic(IntrinsicID, X->getType());

MSVC-generated clang.exe crashed.

Modified:
    cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=172352&r1=172351&r2=172352&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sun Jan 13 05:26:44 2013
@@ -187,8 +187,7 @@
          "Arguments must be the same type. (Did you forget to make sure both "
          "arguments have the same integer width?)");
 
-  ArrayRef<llvm::Type *> Type(X->getType());
-  llvm::Value *Callee = CGF.CGM.getIntrinsic(IntrinsicID, Type);
+  llvm::Value *Callee = CGF.CGM.getIntrinsic(IntrinsicID, X->getType());
   llvm::Value *Tmp = CGF.Builder.CreateCall2(Callee, X, Y);
   Carry = CGF.Builder.CreateExtractValue(Tmp, 1);
   return CGF.Builder.CreateExtractValue(Tmp, 0);





More information about the cfe-commits mailing list