[PATCH] D46804: Fix merging of small weak functions

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 13 07:10:21 PDT 2018


nikic created this revision.
nikic added reviewers: jfb, whitequark.
Herald added a subscriber: llvm-commits.

When two interposable functions are merged, we cannot replace
uses and have to emit calls to a common internal function. However,
writeThunk() will not actually emit a thunk if the function is too
small. This leaves us in a broken state where mergeTwoFunctions
already rewired the functions, but writeThunk doesn't do anything.

This patch changes the implementation so that:

- writeThunk() does just that.
- The direct replacement of calls is moved into mergeTwoFunctions() into the interposable case only.
- isThunkProfitable() is extracted and will be called for the non-iterposable case always, and in the interposable case only if uses are still left after replacement.

This issue has been introduced in https://reviews.llvm.org/D34806,
where the code for checking thunk profitability has been moved.


Repository:
  rL LLVM

https://reviews.llvm.org/D46804

Files:
  lib/Transforms/IPO/MergeFunctions.cpp
  test/Transforms/MergeFunc/weak-small.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46804.146509.patch
Type: text/x-patch
Size: 5243 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180513/34438ed2/attachment.bin>


More information about the llvm-commits mailing list