diff options
author | Anders Carlsson <andersca@mac.com> | 2009-11-27 20:47:55 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-11-27 20:47:55 +0000 |
commit | d6b07fb9ca2c3207773de1d8e305f99076598a2e (patch) | |
tree | 818e885b5fbc77c2b5a07c52e837ff7b56c793fd /lib/CodeGen/CGExprConstant.cpp | |
parent | 83d5a2a7d5f933cfdba756e76b6c5cc2f61ac37e (diff) |
Don't build the entire vtable when all we want is the index of a virtual method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90017 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index d0475dd8df..54e3fa4744 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -413,9 +413,10 @@ public: // Get the function pointer (or index if this is a virtual function). if (MD->isVirtual()) { - int64_t Index = CGM.getVtableInfo().getMethodVtableIndex(MD); + uint64_t Index = CGM.getVtableInfo().getMethodVtableIndex(MD); - Values[0] = llvm::ConstantInt::get(PtrDiffTy, Index + 1); + // The pointer is 1 + the virtual table offset in bytes. + Values[0] = llvm::ConstantInt::get(PtrDiffTy, (Index * 8) + 1); } else { llvm::Constant *FuncPtr = CGM.GetAddrOfFunction(MD); |