This repository has been archived by the owner on Feb 5, 2019. It is now read-only.
forked from luqmana/llvm
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MergeFunctions] Fix merging of small weak functions
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 non-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. Differential Revision: https://reviews.llvm.org/D46804 Reviewed By: whitequark git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332342 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
1 parent
da0cb60
commit efbf5cc
Showing
2 changed files
with
65 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
; RUN: opt -mergefunc -S < %s | FileCheck %s | ||
|
||
; Weak functions too small for merging to be profitable | ||
|
||
; CHECK: define weak i32 @foo(i8*, i32) | ||
; CHECK-NEXT: ret i32 %1 | ||
; CHECK: define weak i32 @bar(i8*, i32) | ||
; CHECK-NEXT: ret i32 %1 | ||
|
||
define weak i32 @foo(i8*, i32) #0 { | ||
ret i32 %1 | ||
} | ||
|
||
define weak i32 @bar(i8*, i32) #0 { | ||
ret i32 %1 | ||
} |