[cfe-commits] r129830 - /cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
Daniel Dunbar
daniel at zuster.org
Tue Apr 19 16:10:47 PDT 2011
Author: ddunbar
Date: Tue Apr 19 18:10:47 2011
New Revision: 129830
URL: http://llvm.org/viewvc/llvm-project?rev=129830&view=rev
Log:
IRgen/ARM: Fix a think-o in conversion-to-null for member function pointers, we
were computing the conversion as (ptr != 0 && non-virtual), when it should be
(ptr != 0 || is-virtual).
- Test to follow in LLVM test-suite.
Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=129830&r1=129829&r2=129830&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Tue Apr 19 18:10:47 2011
@@ -652,20 +652,21 @@
return Builder.CreateICmpNE(MemPtr, NegativeOne, "memptr.tobool");
}
- // In Itanium, a member function pointer is null if 'ptr' is null.
+ // In Itanium, a member function pointer is not null if 'ptr' is not null.
llvm::Value *Ptr = Builder.CreateExtractValue(MemPtr, 0, "memptr.ptr");
llvm::Constant *Zero = llvm::ConstantInt::get(Ptr->getType(), 0);
llvm::Value *Result = Builder.CreateICmpNE(Ptr, Zero, "memptr.tobool");
- // In ARM, it's that, plus the low bit of 'adj' must be zero.
+ // On ARM, a member function pointer is also non-null if the low bit of 'adj'
+ // (the virtual bit) is set.
if (IsARM) {
llvm::Constant *One = llvm::ConstantInt::get(Ptr->getType(), 1);
llvm::Value *Adj = Builder.CreateExtractValue(MemPtr, 1, "memptr.adj");
llvm::Value *VirtualBit = Builder.CreateAnd(Adj, One, "memptr.virtualbit");
- llvm::Value *IsNotVirtual = Builder.CreateICmpEQ(VirtualBit, Zero,
- "memptr.notvirtual");
- Result = Builder.CreateAnd(Result, IsNotVirtual);
+ llvm::Value *IsVirtual = Builder.CreateICmpNE(VirtualBit, Zero,
+ "memptr.isvirtual");
+ Result = Builder.CreateOr(Result, IsVirtual);
}
return Result;
More information about the cfe-commits
mailing list