[PATCH] D87620: [TSAN] Handle musttail call properly in EscapeEnumerator (and TSAN)

Xun Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 12:54:34 PDT 2020


lxfind added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/EscapeEnumerator.cpp:111
     CallInst *CI = cast<CallInst>(Calls[--I]);
     changeToInvokeAndSplitBasicBlock(CI, CleanupBB);
   }
----------------
wenlei wrote:
> lxfind wrote:
> > wenlei wrote:
> > > Does TSAN rely on exit cleanup instrumentation for correctness? How does it work for existing Invoke?
> > > 
> > > This patch would be fine if missing some exit instrumentation is ok in general..
> > The change would just make the call to tsan exit function happen earlier, before the tail call. So we are not missing any exit instrumentation after this change.
> > The change would just make the call to tsan exit function happen earlier, before the tail call. So we are not missing any exit instrumentation after this change.
> 
> That's the part from AdjustMustTailCall. 
> 
> IIUC, the other part on line 82 would skip changing throwing tail call to invoke, which would also skip the clean up in landing pad. That's what I was referring to,
Ah I see. So the reason EscapeEnumerator tries to turn calls into invoke with an exception return path is so that when exceptions are thrown, it still has a chance to call the tsan exit function before propagating the exception back.
Now that this changes make the call to tsan exit function before the musttail call, we no longer need to try to catch the exception after the musttail call and call exit function again if it ever throws.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87620/new/

https://reviews.llvm.org/D87620



More information about the llvm-commits mailing list