<div dir="auto">You might've forgotten to svn add the test :-)</div><br><div class="gmail_quote"><div dir="ltr">On Thu, May 17, 2018, 2:16 PM Reid Kleckner via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rnk<br>
Date: Thu May 17 11:12:18 2018<br>
New Revision: 332639<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=332639&view=rev" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=332639&view=rev</a><br>
Log:<br>
Fix a mangling failure on clang-cl C++17<br>
<br>
MethodVFTableLocations in MigrosoftVTableContext contains canonicalized<br>
decl. But, it's sometimes asked to lookup for non-canonicalized decl,<br>
and that causes assertion failure, and compilation failure.<br>
<br>
Fixes PR37481.<br>
<br>
Patch by Taiju Tsuiki!<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D46929" rel="noreferrer noreferrer" target="_blank">https://reviews.llvm.org/D46929</a><br>
<br>
Modified:<br>
cfe/trunk/lib/AST/VTableBuilder.cpp<br>
cfe/trunk/lib/CodeGen/CGCXX.cpp<br>
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp<br>
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp<br>
<br>
Modified: cfe/trunk/lib/AST/VTableBuilder.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=332639&r1=332638&r2=332639&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=332639&r1=332638&r2=332639&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/VTableBuilder.cpp (original)<br>
+++ cfe/trunk/lib/AST/VTableBuilder.cpp Thu May 17 11:12:18 2018<br>
@@ -2223,6 +2223,7 @@ ItaniumVTableContext::ItaniumVTableConte<br>
ItaniumVTableContext::~ItaniumVTableContext() {}<br>
<br>
uint64_t ItaniumVTableContext::getMethodVTableIndex(GlobalDecl GD) {<br>
+ GD = GD.getCanonicalDecl();<br>
MethodVTableIndicesTy::iterator I = MethodVTableIndices.find(GD);<br>
if (I != MethodVTableIndices.end())<br>
return I->second;<br>
@@ -2503,6 +2504,8 @@ private:<br>
for (const auto &I : MethodInfoMap) {<br>
const CXXMethodDecl *MD = I.first;<br>
const MethodInfo &MI = I.second;<br>
+ assert(MD == MD->getCanonicalDecl());<br>
+<br>
// Skip the methods that the MostDerivedClass didn't override<br>
// and the entries shadowed by return adjusting thunks.<br>
if (MD->getParent() != MostDerivedClass || MI.Shadowed)<br>
@@ -3737,6 +3740,8 @@ MicrosoftVTableContext::getMethodVFTable<br>
if (isa<CXXDestructorDecl>(GD.getDecl()))<br>
assert(GD.getDtorType() == Dtor_Deleting);<br>
<br>
+ GD = GD.getCanonicalDecl();<br>
+<br>
MethodVFTableLocationsTy::iterator I = MethodVFTableLocations.find(GD);<br>
if (I != MethodVFTableLocations.end())<br>
return I->second;<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=332639&r1=332638&r2=332639&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=332639&r1=332638&r2=332639&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Thu May 17 11:12:18 2018<br>
@@ -267,7 +267,6 @@ static CGCallee BuildAppleKextVirtualCal<br>
const CXXRecordDecl *RD) {<br>
assert(!CGF.CGM.getTarget().getCXXABI().isMicrosoft() &&<br>
"No kext in Microsoft ABI");<br>
- GD = GD.getCanonicalDecl();<br>
CodeGenModule &CGM = CGF.CGM;<br>
llvm::Value *VTable = CGM.getCXXABI().getAddrOfVTable(RD, CharUnits());<br>
Ty = Ty->getPointerTo()->getPointerTo();<br>
@@ -283,7 +282,7 @@ static CGCallee BuildAppleKextVirtualCal<br>
CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfnkxt");<br>
llvm::Value *VFunc =<br>
CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.PointerAlignInBytes);<br>
- CGCallee Callee(GD.getDecl(), VFunc);<br>
+ CGCallee Callee(GD.getDecl()->getCanonicalDecl(), VFunc);<br>
return Callee;<br>
}<br>
<br>
<br>
Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=332639&r1=332638&r2=332639&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=332639&r1=332638&r2=332639&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu May 17 11:12:18 2018<br>
@@ -825,7 +825,6 @@ ItaniumCXXABI::EmitMemberFunctionPointer<br>
llvm::Constant *ItaniumCXXABI::BuildMemberPointer(const CXXMethodDecl *MD,<br>
CharUnits ThisAdjustment) {<br>
assert(MD->isInstance() && "Member function must not be static!");<br>
- MD = MD->getCanonicalDecl();<br>
<br>
CodeGenTypes &Types = CGM.getTypes();<br>
<br>
@@ -1640,7 +1639,6 @@ CGCallee ItaniumCXXABI::getVirtualFuncti<br>
Address This,<br>
llvm::Type *Ty,<br>
SourceLocation Loc) {<br>
- GD = GD.getCanonicalDecl();<br>
Ty = Ty->getPointerTo()->getPointerTo();<br>
auto *MethodDecl = cast<CXXMethodDecl>(GD.getDecl());<br>
llvm::Value *VTable = CGF.GetVTablePtr(This, Ty, MethodDecl->getParent());<br>
@@ -1674,7 +1672,7 @@ CGCallee ItaniumCXXABI::getVirtualFuncti<br>
VFunc = VFuncLoad;<br>
}<br>
<br>
- CGCallee Callee(MethodDecl, VFunc);<br>
+ CGCallee Callee(MethodDecl->getCanonicalDecl(), VFunc);<br>
return Callee;<br>
}<br>
<br>
<br>
Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=332639&r1=332638&r2=332639&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=332639&r1=332638&r2=332639&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Thu May 17 11:12:18 2018<br>
@@ -228,7 +228,6 @@ public:<br>
<br>
const CXXRecordDecl *<br>
getThisArgumentTypeForMethod(const CXXMethodDecl *MD) override {<br>
- MD = MD->getCanonicalDecl();<br>
if (MD->isVirtual() && !isa<CXXDestructorDecl>(MD)) {<br>
MethodVFTableLocation ML =<br>
CGM.getMicrosoftVTableContext().getMethodVFTableLocation(MD);<br>
@@ -1320,10 +1319,8 @@ void MicrosoftCXXABI::EmitCXXDestructors<br>
<br>
CharUnits<br>
MicrosoftCXXABI::getVirtualFunctionPrologueThisAdjustment(GlobalDecl GD) {<br>
- GD = GD.getCanonicalDecl();<br>
const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());<br>
<br>
- GlobalDecl LookupGD = GD;<br>
if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(MD)) {<br>
// Complete destructors take a pointer to the complete object as a<br>
// parameter, thus don't need this adjustment.<br>
@@ -1332,11 +1329,11 @@ MicrosoftCXXABI::getVirtualFunctionProlo<br>
<br>
// There's no Dtor_Base in vftable but it shares the this adjustment with<br>
// the deleting one, so look it up instead.<br>
- LookupGD = GlobalDecl(DD, Dtor_Deleting);<br>
+ GD = GlobalDecl(DD, Dtor_Deleting);<br>
}<br>
<br>
MethodVFTableLocation ML =<br>
- CGM.getMicrosoftVTableContext().getMethodVFTableLocation(LookupGD);<br>
+ CGM.getMicrosoftVTableContext().getMethodVFTableLocation(GD);<br>
CharUnits Adjustment = ML.VFPtrOffset;<br>
<br>
// Normal virtual instance methods need to adjust from the vfptr that first<br>
@@ -1370,7 +1367,6 @@ Address MicrosoftCXXABI::adjustThisArgum<br>
return CGF.Builder.CreateConstByteGEP(This, Adjustment);<br>
}<br>
<br>
- GD = GD.getCanonicalDecl();<br>
const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());<br>
<br>
GlobalDecl LookupGD = GD;<br>
@@ -1839,7 +1835,6 @@ CGCallee MicrosoftCXXABI::getVirtualFunc<br>
Address This,<br>
llvm::Type *Ty,<br>
SourceLocation Loc) {<br>
- GD = GD.getCanonicalDecl();<br>
CGBuilderTy &Builder = CGF.Builder;<br>
<br>
Ty = Ty->getPointerTo()->getPointerTo();<br>
@@ -1878,7 +1873,7 @@ CGCallee MicrosoftCXXABI::getVirtualFunc<br>
VFunc = Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());<br>
}<br>
<br>
- CGCallee Callee(MethodDecl, VFunc);<br>
+ CGCallee Callee(MethodDecl->getCanonicalDecl(), VFunc);<br>
return Callee;<br>
}<br>
<br>
@@ -2737,7 +2732,6 @@ llvm::Constant *<br>
MicrosoftCXXABI::EmitMemberFunctionPointer(const CXXMethodDecl *MD) {<br>
assert(MD->isInstance() && "Member function must not be static!");<br>
<br>
- MD = MD->getCanonicalDecl();<br>
CharUnits NonVirtualBaseAdjustment = CharUnits::Zero();<br>
const CXXRecordDecl *RD = MD->getParent()->getMostRecentDecl();<br>
CodeGenTypes &Types = CGM.getTypes();<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" rel="noreferrer">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>