diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-05-02 00:05:16 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-05-02 00:05:16 +0000 |
commit | 34a38d8efbde085814bbbb5d1d7c7fcb15897e42 (patch) | |
tree | d36d637ebb49ba943e12b8551ce90764a3caf648 /clang | |
parent | d9070c5ee77c5429b7f84df965df4206045c3504 (diff) | |
download | bcm5719-llvm-34a38d8efbde085814bbbb5d1d7c7fcb15897e42.tar.gz bcm5719-llvm-34a38d8efbde085814bbbb5d1d7c7fcb15897e42.zip |
MS ABI: Fix logic bug in member pointer null test code
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.
llvm-svn: 207815
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/CodeGen/MicrosoftCXXABI.cpp | 2 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index 528cdf6238e..869734ab4e4 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -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; } diff --git a/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp b/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp index 8d9a848cbcd..c5eeb4ef492 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp @@ -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: } } |