[PATCH] [-cxx-abi microsoft] Emit thunks for pointers to virtual member functions
Hans Wennborg
hans at chromium.org
Fri Nov 15 09:28:46 PST 2013
Thanks for all the comments! Committing.
================
Comment at: lib/CodeGen/CodeGenFunction.h:1159
@@ +1158,3 @@
+ void EmitCallAndReturnForThunk(GlobalDecl GD, llvm::Value *Callee,
+ llvm::Value *ThisPtr,
+ const ThunkInfo *Thunk);
----------------
Timur Iskhodzhanov wrote:
> Do you need ThisPtr as a parameter yet?
> You pass `CGF.LoadCXXThis()` as an argument in both places.
Done.
================
Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:993
@@ +992,3 @@
+ LinkageInfo LV = MD->getLinkageAndVisibility();
+ ThunkFn->setLinkage(LV.getLinkage() != ExternalLinkage
+ ? llvm::GlobalValue::InternalLinkage
----------------
Reid Kleckner wrote:
> I think you really want MD->isExternallyVisible() to handle the VisibleNoLinkage case, which would be triggered by something evil like:
>
> inline __forceinline bool foo(bool set_mp) {
> struct B {
> virtual void f() {}
> static bool compare_mps(void (B::*mp1)(), void (B::*mp2)()) {
> return mp1 == mp2;
> }
> };
> if (set_mp)
> mp = reinterpret_cast<void (A::*)()>(&B::f);
> return B::compare_mps(&B::f, reinterpret_cast<void (B::*)()>(mp));
> }
>
> If you use internal linkage here, you'll get two distinct thunks, and the comparison will be false when it shouldn't be.
Done.
http://llvm-reviews.chandlerc.com/D2104
More information about the cfe-commits
mailing list