Re: r332639 - Fix a mangling failure on clang-cl C++17
Thanks! Added in 332646 On Thu, May 17, 2018 at 11:30 AM Nico Weber wrote: > You might've forgotten to svn add the test :-) > > On Thu, May 17, 2018, 2:16 PM Reid Kleckner via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: rnk >> Date: Thu May 17 11:12:18 2018 >> New Revision: 332639 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=332639&view=rev >> Log: >> Fix a mangling failure on clang-cl C++17 >> >> MethodVFTableLocations in MigrosoftVTableContext contains canonicalized >> decl. But, it's sometimes asked to lookup for non-canonicalized decl, >> and that causes assertion failure, and compilation failure. >> >> Fixes PR37481. >> >> Patch by Taiju Tsuiki! >> >> Differential Revision: https://reviews.llvm.org/D46929 >> >> Modified: >> cfe/trunk/lib/AST/VTableBuilder.cpp >> cfe/trunk/lib/CodeGen/CGCXX.cpp >> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp >> cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp >> >> Modified: cfe/trunk/lib/AST/VTableBuilder.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=332639&r1=332638&r2=332639&view=diff >> >> == >> --- cfe/trunk/lib/AST/VTableBuilder.cpp (original) >> +++ cfe/trunk/lib/AST/VTableBuilder.cpp Thu May 17 11:12:18 2018 >> @@ -2223,6 +2223,7 @@ ItaniumVTableContext::ItaniumVTableConte >> ItaniumVTableContext::~ItaniumVTableContext() {} >> >> uint64_t ItaniumVTableContext::getMethodVTableIndex(GlobalDecl GD) { >> + GD = GD.getCanonicalDecl(); >>MethodVTableIndicesTy::iterator I = MethodVTableIndices.find(GD); >>if (I != MethodVTableIndices.end()) >> return I->second; >> @@ -2503,6 +2504,8 @@ private: >> for (const auto &I : MethodInfoMap) { >>const CXXMethodDecl *MD = I.first; >>const MethodInfo &MI = I.second; >> + assert(MD == MD->getCanonicalDecl()); >> + >>// Skip the methods that the MostDerivedClass didn't override >>// and the entries shadowed by return adjusting thunks. >>if (MD->getParent() != MostDerivedClass || MI.Shadowed) >> @@ -3737,6 +3740,8 @@ MicrosoftVTableContext::getMethodVFTable >>if (isa(GD.getDecl())) >> assert(GD.getDtorType() == Dtor_Deleting); >> >> + GD = GD.getCanonicalDecl(); >> + >>MethodVFTableLocationsTy::iterator I = MethodVFTableLocations.find(GD); >>if (I != MethodVFTableLocations.end()) >> return I->second; >> >> Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=332639&r1=332638&r2=332639&view=diff >> >> == >> --- cfe/trunk/lib/CodeGen/CGCXX.cpp (original) >> +++ cfe/trunk/lib/CodeGen/CGCXX.cpp Thu May 17 11:12:18 2018 >> @@ -267,7 +267,6 @@ static CGCallee BuildAppleKextVirtualCal >>const CXXRecordDecl *RD) { >>assert(!CGF.CGM.getTarget().getCXXABI().isMicrosoft() && >> "No kext in Microsoft ABI"); >> - GD = GD.getCanonicalDecl(); >>CodeGenModule &CGM = CGF.CGM; >>llvm::Value *VTable = CGM.getCXXABI().getAddrOfVTable(RD, CharUnits()); >>Ty = Ty->getPointerTo()->getPointerTo(); >> @@ -283,7 +282,7 @@ static CGCallee BuildAppleKextVirtualCal >> CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, >> "vfnkxt"); >>llvm::Value *VFunc = >> CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.PointerAlignInBytes); >> - CGCallee Callee(GD.getDecl(), VFunc); >> + CGCallee Callee(GD.getDecl()->getCanonicalDecl(), VFunc); >>return Callee; >> } >> >> >> Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=332639&r1=332638&r2=332639&view=diff >> >> == >> --- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original) >> +++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu May 17 11:12:18 2018 >> @@ -825,7 +825,6 @@ ItaniumCXXABI::EmitMemberFunctionPointer >> llvm::Constant *ItaniumCXXABI::BuildMemberPointer(const CXXMethodDecl >> *MD, >>CharUnits >> ThisAdjustment) { >>assert(MD->isInstance() && "Member function must not be static!"); >> - MD = MD->getCanonicalDecl(); >> >>CodeGenTypes &Types = CGM.getTypes(); >> >> @@ -1640,7 +1639,6 @@ CGCallee ItaniumCXXABI::getVirtualFuncti >>Address This, >>llvm::Type *Ty, >>SourceLocation Loc) { >> - GD = GD.getCanonicalDecl(); >>Ty = Ty->getPointerTo()->getPointerTo(); >>auto *MethodDecl = cast(GD.getDecl()); >>llvm::Value *VTable = CGF.GetVTablePtr(This, Ty, >> MethodDecl->getParent()); >> @@ -1674,7 +1672,7 @@ CGCallee ItaniumCXXABI::getVirtualFuncti >> V
Re: r332639 - Fix a mangling failure on clang-cl C++17
You might've forgotten to svn add the test :-) On Thu, May 17, 2018, 2:16 PM Reid Kleckner via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: rnk > Date: Thu May 17 11:12:18 2018 > New Revision: 332639 > > URL: http://llvm.org/viewvc/llvm-project?rev=332639&view=rev > Log: > Fix a mangling failure on clang-cl C++17 > > MethodVFTableLocations in MigrosoftVTableContext contains canonicalized > decl. But, it's sometimes asked to lookup for non-canonicalized decl, > and that causes assertion failure, and compilation failure. > > Fixes PR37481. > > Patch by Taiju Tsuiki! > > Differential Revision: https://reviews.llvm.org/D46929 > > Modified: > cfe/trunk/lib/AST/VTableBuilder.cpp > cfe/trunk/lib/CodeGen/CGCXX.cpp > cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp > cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp > > Modified: cfe/trunk/lib/AST/VTableBuilder.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=332639&r1=332638&r2=332639&view=diff > > == > --- cfe/trunk/lib/AST/VTableBuilder.cpp (original) > +++ cfe/trunk/lib/AST/VTableBuilder.cpp Thu May 17 11:12:18 2018 > @@ -2223,6 +2223,7 @@ ItaniumVTableContext::ItaniumVTableConte > ItaniumVTableContext::~ItaniumVTableContext() {} > > uint64_t ItaniumVTableContext::getMethodVTableIndex(GlobalDecl GD) { > + GD = GD.getCanonicalDecl(); >MethodVTableIndicesTy::iterator I = MethodVTableIndices.find(GD); >if (I != MethodVTableIndices.end()) > return I->second; > @@ -2503,6 +2504,8 @@ private: > for (const auto &I : MethodInfoMap) { >const CXXMethodDecl *MD = I.first; >const MethodInfo &MI = I.second; > + assert(MD == MD->getCanonicalDecl()); > + >// Skip the methods that the MostDerivedClass didn't override >// and the entries shadowed by return adjusting thunks. >if (MD->getParent() != MostDerivedClass || MI.Shadowed) > @@ -3737,6 +3740,8 @@ MicrosoftVTableContext::getMethodVFTable >if (isa(GD.getDecl())) > assert(GD.getDtorType() == Dtor_Deleting); > > + GD = GD.getCanonicalDecl(); > + >MethodVFTableLocationsTy::iterator I = MethodVFTableLocations.find(GD); >if (I != MethodVFTableLocations.end()) > return I->second; > > Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=332639&r1=332638&r2=332639&view=diff > > == > --- cfe/trunk/lib/CodeGen/CGCXX.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGCXX.cpp Thu May 17 11:12:18 2018 > @@ -267,7 +267,6 @@ static CGCallee BuildAppleKextVirtualCal >const CXXRecordDecl *RD) { >assert(!CGF.CGM.getTarget().getCXXABI().isMicrosoft() && > "No kext in Microsoft ABI"); > - GD = GD.getCanonicalDecl(); >CodeGenModule &CGM = CGF.CGM; >llvm::Value *VTable = CGM.getCXXABI().getAddrOfVTable(RD, CharUnits()); >Ty = Ty->getPointerTo()->getPointerTo(); > @@ -283,7 +282,7 @@ static CGCallee BuildAppleKextVirtualCal > CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfnkxt"); >llvm::Value *VFunc = > CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.PointerAlignInBytes); > - CGCallee Callee(GD.getDecl(), VFunc); > + CGCallee Callee(GD.getDecl()->getCanonicalDecl(), VFunc); >return Callee; > } > > > Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=332639&r1=332638&r2=332639&view=diff > > == > --- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original) > +++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu May 17 11:12:18 2018 > @@ -825,7 +825,6 @@ ItaniumCXXABI::EmitMemberFunctionPointer > llvm::Constant *ItaniumCXXABI::BuildMemberPointer(const CXXMethodDecl *MD, >CharUnits > ThisAdjustment) { >assert(MD->isInstance() && "Member function must not be static!"); > - MD = MD->getCanonicalDecl(); > >CodeGenTypes &Types = CGM.getTypes(); > > @@ -1640,7 +1639,6 @@ CGCallee ItaniumCXXABI::getVirtualFuncti >Address This, >llvm::Type *Ty, >SourceLocation Loc) { > - GD = GD.getCanonicalDecl(); >Ty = Ty->getPointerTo()->getPointerTo(); >auto *MethodDecl = cast(GD.getDecl()); >llvm::Value *VTable = CGF.GetVTablePtr(This, Ty, > MethodDecl->getParent()); > @@ -1674,7 +1672,7 @@ CGCallee ItaniumCXXABI::getVirtualFuncti > VFunc = VFuncLoad; >} > > - CGCallee Callee(MethodDecl, VFunc); > + CGCallee Callee(MethodDecl->getCanonicalDecl(), VFunc); >return Callee; > } > > > Modified: cfe/trunk/lib/CodeGen/MicrosoftC