summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2008-05-29 15:09:15 +0000
committerEli Friedman <eli.friedman@gmail.com>2008-05-29 15:09:15 +0000
commit3c28524632243c97fe327b4b7656b0b9a44c86f1 (patch)
tree3cff639992249eae1c1f2a53a3f841a16e7df9a7 /clang/lib/CodeGen
parent9e064a21804b7cdb194fb7a19353378b0566d55c (diff)
downloadbcm5719-llvm-3c28524632243c97fe327b4b7656b0b9a44c86f1.tar.gz
bcm5719-llvm-3c28524632243c97fe327b4b7656b0b9a44c86f1.zip
Fix an extremely subtle bug with pointer comparisons: they have to be
unsigned because it's possible (at least in theory) to have have both positive and negative pointers pointing to the same object. llvm-svn: 51681
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGExprScalar.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index 9daa21eb340..fc8639dbf24 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -917,12 +917,12 @@ Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc,
if (LHS->getType()->isFloatingPoint()) {
Result = Builder.CreateFCmp((llvm::FCmpInst::Predicate)FCmpOpc,
LHS, RHS, "cmp");
- } else if (LHSTy->isUnsignedIntegerType()) {
- Result = Builder.CreateICmp((llvm::ICmpInst::Predicate)UICmpOpc,
+ } else if (LHSTy->isSignedIntegerType()) {
+ Result = Builder.CreateICmp((llvm::ICmpInst::Predicate)SICmpOpc,
LHS, RHS, "cmp");
} else {
- // Signed integers and pointers.
- Result = Builder.CreateICmp((llvm::ICmpInst::Predicate)SICmpOpc,
+ // Unsigned integers and pointers.
+ Result = Builder.CreateICmp((llvm::ICmpInst::Predicate)UICmpOpc,
LHS, RHS, "cmp");
}
} else {
OpenPOWER on IntegriCloud