From: Reid Kleckner Date: Fri, 1 Jul 2016 02:41:25 +0000 (+0000) Subject: [DebugInfo] Set DISubprogram ThisAdjustment in the MS ABI X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc7857b421d9a39eac38e824911fa63587cb3172;p=clang [DebugInfo] Set DISubprogram ThisAdjustment in the MS ABI git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274326 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGCXXABI.h b/lib/CodeGen/CGCXXABI.h index 8c0f6c2efd..9e10ec068e 100644 --- a/lib/CodeGen/CGCXXABI.h +++ b/lib/CodeGen/CGCXXABI.h @@ -336,6 +336,12 @@ public: virtual void addImplicitStructorParams(CodeGenFunction &CGF, QualType &ResTy, FunctionArgList &Params) = 0; + /// Get the ABI-specific "this" parameter adjustment to apply in the prologue + /// of a virtual function. + virtual CharUnits getVirtualFunctionPrologueThisAdjustment(GlobalDecl GD) { + return CharUnits::Zero(); + } + /// Perform ABI-specific "this" parameter adjustment in a virtual function /// prologue. virtual llvm::Value *adjustThisParameterInVirtualFunctionPrologue( diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index ab0ee6cdbe..13461980a4 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1206,6 +1206,7 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction( unsigned Virtuality = 0; unsigned VIndex = 0; unsigned Flags = 0; + int ThisAdjustment = 0; if (Method->isVirtual()) { if (Method->isPure()) @@ -1235,9 +1236,12 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction( if (Method->begin_overridden_methods() == Method->end_overridden_methods()) Flags |= llvm::DINode::FlagIntroducedVirtual; - // FIXME: Pass down ML.VFPtrOffset and ML.VBTableIndex. The debugger needs - // these to synthesize a call to a virtual method in a complex inheritance - // hierarchy. + // The 'this' adjustment accounts for both the virtual and non-virtual + // portions of the adjustment. Presumably the debugger only uses it when + // it knows the dynamic type of an object. + ThisAdjustment = CGM.getCXXABI() + .getVirtualFunctionPrologueThisAdjustment(GD) + .getQuantity(); } ContainingType = RecordTy; } @@ -1263,9 +1267,9 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction( llvm::DINodeArray TParamsArray = CollectFunctionTemplateParams(Method, Unit); llvm::DISubprogram *SP = DBuilder.createMethod( RecordTy, MethodName, MethodLinkageName, MethodDefUnit, MethodLine, - MethodTy, /*isLocalToUnit=*/false, - /* isDefinition=*/false, Virtuality, VIndex, ContainingType, Flags, - CGM.getLangOpts().Optimize, TParamsArray.get()); + MethodTy, /*isLocalToUnit=*/false, /*isDefinition=*/false, Virtuality, + VIndex, ThisAdjustment, ContainingType, Flags, CGM.getLangOpts().Optimize, + TParamsArray.get()); SPCache[Method->getCanonicalDecl()].reset(SP); diff --git a/lib/CodeGen/MicrosoftCXXABI.cpp b/lib/CodeGen/MicrosoftCXXABI.cpp index 31bfbf0cdf..e86d7eb773 100644 --- a/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/lib/CodeGen/MicrosoftCXXABI.cpp @@ -551,7 +551,7 @@ private: return llvm::Constant::getAllOnesValue(CGM.IntTy); } - CharUnits getVirtualFunctionPrologueThisAdjustment(GlobalDecl GD); + CharUnits getVirtualFunctionPrologueThisAdjustment(GlobalDecl GD) override; void GetNullMemberPointerFields(const MemberPointerType *MPT,