]> granicus.if.org Git - clang/commitdiff
MS ABI: Fix logic bug in member pointer null test code
authorReid Kleckner <reid@kleckner.net>
Fri, 2 May 2014 00:05:16 +0000 (00:05 +0000)
committerReid Kleckner <reid@kleckner.net>
Fri, 2 May 2014 00:05:16 +0000 (00:05 +0000)
This code is trying to test if the pointer is *not* null.  Therefore we
should use 'or' instead of 'and' to combine the results of 'icmp ne'.
This logic is consistent with the general member pointer comparison code
in EmitMemberPointerComparison.

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

lib/CodeGen/MicrosoftCXXABI.cpp
test/CodeGenCXX/microsoft-abi-member-pointers.cpp

index 528cdf6238ea2a33b89aa0c23baba223cff9dd6b..869734ab4e49dece4babc6f244210a4e39441210 100644 (file)
@@ -1628,7 +1628,7 @@ MicrosoftCXXABI::EmitMemberPointerIsNotNull(CodeGenFunction &CGF,
   for (int I = 1, E = fields.size(); I < E; ++I) {
     llvm::Value *Field = Builder.CreateExtractValue(MemPtr, I);
     llvm::Value *Next = Builder.CreateICmpNE(Field, fields[I], "memptr.cmp");
-    Res = Builder.CreateAnd(Res, Next, "memptr.tobool");
+    Res = Builder.CreateOr(Res, Next, "memptr.tobool");
   }
   return Res;
 }
index 8d9a848cbcd5cb8a869a7d08c6a0e2b8d59b4131..c5eeb4ef492e7d729adaef0c49f860eb16710c12 100644 (file)
@@ -229,10 +229,10 @@ bool nullTestDataUnspecified(int Unspecified::*mp) {
 // CHECK:   %[[cmp0:.*]] = icmp ne i32 %[[mp0]], 0
 // CHECK:   %[[mp1:.*]] = extractvalue { i32, i32, i32 } %[[mp]], 1
 // CHECK:   %[[cmp1:.*]] = icmp ne i32 %[[mp1]], 0
-// CHECK:   %[[and0:.*]] = and i1 %[[cmp0]], %[[cmp1]]
+// CHECK:   %[[and0:.*]] = or i1 %[[cmp0]], %[[cmp1]]
 // CHECK:   %[[mp2:.*]] = extractvalue { i32, i32, i32 } %[[mp]], 2
 // CHECK:   %[[cmp2:.*]] = icmp ne i32 %[[mp2]], -1
-// CHECK:   %[[and1:.*]] = and i1 %[[and0]], %[[cmp2]]
+// CHECK:   %[[and1:.*]] = or i1 %[[and0]], %[[cmp2]]
 // CHECK:   ret i1 %[[and1]]
 // CHECK: }
 }