[llvm-commits] [llvm-gcc-4.2] r41981 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Chris Lattner
sabre at nondot.org
Fri Sep 14 22:47:38 PDT 2007
Author: lattner
Date: Sat Sep 15 00:47:38 2007
New Revision: 41981
URL: http://llvm.org/viewvc/llvm-project?rev=41981&view=rev
Log:
Fix PR1662 by handling pointer negate_expr.
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=41981&r1=41980&r2=41981&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Sat Sep 15 00:47:38 2007
@@ -2683,8 +2683,17 @@
}
Value *TreeToLLVM::EmitNEGATE_EXPR(tree exp, Value *DestLoc) {
- if (!DestLoc)
- return Builder.CreateNeg(Emit(TREE_OPERAND(exp, 0), 0), "tmp");
+ if (!DestLoc) {
+ Value *V = Emit(TREE_OPERAND(exp, 0), 0);
+ if (!isa<PointerType>(V->getType()))
+ return Builder.CreateNeg(V, "tmp");
+
+ // GCC allows NEGATE_EXPR on pointers as well. Cast to int, negate, cast
+ // back.
+ V = CastToAnyType(V, false, TD.getIntPtrType(), false);
+ V = Builder.CreateNeg(V, "tmp");
+ return CastToType(Instruction::IntToPtr, V, ConvertType(TREE_TYPE(exp)));
+ }
// Emit the operand to a temporary.
const Type *ComplexTy=cast<PointerType>(DestLoc->getType())->getElementType();
More information about the llvm-commits
mailing list