aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-03-06 23:05:56 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-03-06 23:05:56 +0000
commita6e27790acb6d06be6c1113ea94165c4b7e056cd (patch)
tree504fbd79d1d3cecb8a7336e4ca7b0f4d77e11465
parentc837656ca6d2a5b434923d7e2fd11d3a3c3bfa74 (diff)
Fixed a bug where generation of read-barriers caused
crash in ir-gen. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66302 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGExprScalar.cpp3
-rw-r--r--test/CodeGenObjC/objc2-weak-compare.m24
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index 9951d8794b..70373031bb 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -1015,6 +1015,9 @@ Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc,
LHS, RHS, "cmp");
} else {
// Unsigned integers and pointers.
+ // Casting becomes necessary with -fobjc-gc as one or the other my turn
+ // into an 'id' type due to generation of read barriers.
+ RHS = Builder.CreateBitCast(RHS, LHS->getType());
Result = Builder.CreateICmp((llvm::ICmpInst::Predicate)UICmpOpc,
LHS, RHS, "cmp");
}
diff --git a/test/CodeGenObjC/objc2-weak-compare.m b/test/CodeGenObjC/objc2-weak-compare.m
new file mode 100644
index 0000000000..5889b1ff8d
--- /dev/null
+++ b/test/CodeGenObjC/objc2-weak-compare.m
@@ -0,0 +1,24 @@
+// RUN: clang -fnext-runtime -fobjc-gc -emit-llvm -o %t %s
+
+@interface PBXTarget
+{
+
+PBXTarget * __weak _lastKnownTarget;
+PBXTarget * __weak _KnownTarget;
+PBXTarget * result;
+}
+- Meth;
+@end
+
+@implementation PBXTarget
+- Meth {
+ if (_lastKnownTarget != result)
+ foo();
+ if (result != _lastKnownTarget)
+ foo();
+
+ if (_lastKnownTarget != _KnownTarget)
+ foo();
+}
+
+@end