[PATCH] D111660: [FuncSpec] Make sure function is actually the callee before trying to specialize.

duk via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 12 11:36:33 PDT 2021


duck-37 added inline comments.


================
Comment at: llvm/lib/Transforms/IPO/FunctionSpecialization.cpp:665
       auto &CS = *cast<CallBase>(U);
+      if (CS.getCalledFunction() != F) {
+        continue;
----------------
SjoerdMeijer wrote:
> Hmmm, interesting. Can this lead to a miscompute, or other problems?  I think we need to add a test to trigger that (which this patch fixes)?
Yes, this can lead to miscompiles and crashes if not handled properly. The problem is that I *believe* this issue only arises in very specific scenarios and only when we start allowing specialization of functions that can get their address taken. Otherwise this is never triggered on problematic functions. 

Since allowing that is outside of the scope of this PR, I thought it would be best to add the test for that in a separate patch I'm planning on submitting later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111660



More information about the llvm-commits mailing list