Looks good to me, but John's the code owner for IR generation so I'd like his signoff.
On Wed, Jul 15, 2015 at 7:58 AM, Rafael Espíndola < rafael.espind...@gmail.com> wrote: > I would like to port this to 3.7. > > On 15 July 2015 at 07:48, Rafael Espindola <rafael.espind...@gmail.com> > wrote: > > Author: rafael > > Date: Wed Jul 15 09:48:06 2015 > > New Revision: 242293 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=242293&view=rev > > Log: > > Set comdat when an available_externally thunk is converted to > linkonce_odr. > > > > Fixes pr24130. > > > > Modified: > > cfe/trunk/lib/CodeGen/CGVTables.cpp > > cfe/trunk/test/CodeGenCXX/thunks.cpp > > > > Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=242293&r1=242292&r2=242293&view=diff > > > ============================================================================== > > --- cfe/trunk/lib/CodeGen/CGVTables.cpp (original) > > +++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Jul 15 09:48:06 2015 > > @@ -56,6 +56,21 @@ static void setThunkVisibility(CodeGenMo > > CGM.setGlobalVisibility(Fn, MD); > > } > > > > +static void setThunkProperties(CodeGenModule &CGM, const ThunkInfo > &Thunk, > > + llvm::Function *ThunkFn, bool ForVTable, > > + GlobalDecl GD) { > > + CGM.setFunctionLinkage(GD, ThunkFn); > > + CGM.getCXXABI().setThunkLinkage(ThunkFn, ForVTable, GD, > > + !Thunk.Return.isEmpty()); > > + > > + // Set the right visibility. > > + const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl()); > > + setThunkVisibility(CGM, MD, Thunk, ThunkFn); > > + > > + if (CGM.supportsCOMDAT() && ThunkFn->isWeakForLinker()) > > + > ThunkFn->setComdat(CGM.getModule().getOrInsertComdat(ThunkFn->getName())); > > +} > > + > > #ifndef NDEBUG > > static bool similar(const ABIArgInfo &infoL, CanQualType typeL, > > const ABIArgInfo &infoR, CanQualType typeR) { > > @@ -429,8 +444,7 @@ void CodeGenVTables::emitThunk(GlobalDec > > return; > > } > > > > - // Change the linkage. > > - CGM.setFunctionLinkage(GD, ThunkFn); > > + setThunkProperties(CGM, Thunk, ThunkFn, ForVTable, GD); > > return; > > } > > > > @@ -451,16 +465,7 @@ void CodeGenVTables::emitThunk(GlobalDec > > CodeGenFunction(CGM).generateThunk(ThunkFn, FnInfo, GD, Thunk); > > } > > > > - CGM.setFunctionLinkage(GD, ThunkFn); > > - CGM.getCXXABI().setThunkLinkage(ThunkFn, ForVTable, GD, > > - !Thunk.Return.isEmpty()); > > - > > - // Set the right visibility. > > - const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl()); > > - setThunkVisibility(CGM, MD, Thunk, ThunkFn); > > - > > - if (CGM.supportsCOMDAT() && ThunkFn->isWeakForLinker()) > > - > ThunkFn->setComdat(CGM.getModule().getOrInsertComdat(ThunkFn->getName())); > > + setThunkProperties(CGM, Thunk, ThunkFn, ForVTable, GD); > > } > > > > void CodeGenVTables::maybeEmitThunkForVTable(GlobalDecl GD, > > > > Modified: cfe/trunk/test/CodeGenCXX/thunks.cpp > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/thunks.cpp?rev=242293&r1=242292&r2=242293&view=diff > > > ============================================================================== > > --- cfe/trunk/test/CodeGenCXX/thunks.cpp (original) > > +++ cfe/trunk/test/CodeGenCXX/thunks.cpp Wed Jul 15 09:48:06 2015 > > @@ -361,6 +361,23 @@ namespace Test15 { > > // CHECK: declare void @_ZThn8_N6Test151C1fEiz > > } > > > > +namespace Test16 { > > +struct A { > > + virtual ~A(); > > +}; > > +struct B { > > + virtual void foo(); > > +}; > > +struct C : public A, public B { > > + void foo() {} > > +}; > > +struct D : public C { > > + ~D(); > > +}; > > +D::~D() {} > > +// CHECK: define linkonce_odr void @_ZThn8_N6Test161C3fooEv({{.*}}) > {{.*}} comdat > > +} > > + > > /**** The following has to go at the end of the file ****/ > > > > // This is from Test5: > > > > > > _______________________________________________ > > cfe-commits mailing list > > cfe-commits@cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits