diff options
author | Anders Carlsson <andersca@mac.com> | 2010-05-03 16:05:06 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-05-03 16:05:06 +0000 |
commit | 32897fd3bd84e96d4bfa28aca0c7a907776fb855 (patch) | |
tree | 66bd64353837e62f5b094b060c03bc681358333e /lib/CodeGen/CGExprAgg.cpp | |
parent | 7362258bb8c84cc3107993a7249cb3602ceb0bb7 (diff) |
When computing the address of a virtual member function pointer, use the pointer width instead of hardcoding for 64-bit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102921 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprAgg.cpp')
-rw-r--r-- | lib/CodeGen/CGExprAgg.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 96274cb6e7..d2f75bd355 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -335,11 +335,16 @@ void AggExprEmitter::VisitUnaryAddrOf(const UnaryOperator *E) { if (MD->isVirtual()) { int64_t Index = CGF.CGM.getVTables().getMethodVTableIndex(MD); + // FIXME: We shouldn't use / 8 here. + uint64_t PointerWidthInBytes = + CGF.CGM.getContext().Target.getPointerWidth(0) / 8; + // Itanium C++ ABI 2.3: // For a non-virtual function, this field is a simple function pointer. // For a virtual function, it is 1 plus the virtual table offset // (in bytes) of the function, represented as a ptrdiff_t. - FuncPtr = llvm::ConstantInt::get(PtrDiffTy, (Index * 8) + 1); + FuncPtr = llvm::ConstantInt::get(PtrDiffTy, + (Index * PointerWidthInBytes) + 1); } else { const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>(); const llvm::Type *Ty = |