]> granicus.if.org Git - clang/commitdiff
Fixed a bug where generation of read-barriers caused
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 6 Mar 2009 23:05:56 +0000 (23:05 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 6 Mar 2009 23:05:56 +0000 (23:05 +0000)
crash in ir-gen.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66302 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprScalar.cpp
test/CodeGenObjC/objc2-weak-compare.m [new file with mode: 0644]

index 9951d8794b8992b93138bdcc10998f847db6511e..70373031bb26192aab2805849c3fe5e1473ee909 100644 (file)
@@ -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 (file)
index 0000000..5889b1f
--- /dev/null
@@ -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