This repository has been archived by the owner on Apr 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MergeFunctions] Replace all uses of unnamed_addr functions.
This reduces code size for constructs like vtables or interrupt tables that refer to functions in global initializers. Differential Revision: https://reviews.llvm.org/D34805 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315852 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
1 parent
49fe891
commit e53e8bd
Showing
3 changed files
with
57 additions
and
3 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,30 @@ | ||
; RUN: opt -S -mergefunc < %s | FileCheck %s | ||
|
||
%A = type { i32 } | ||
%B = type { i32 } | ||
|
||
; CHECK-NOT: @b | ||
|
||
@x = constant { i32 (i32)*, i32 (i32)* } | ||
{ i32 (i32)* bitcast (i32 (%A)* @a to i32 (i32)*), | ||
i32 (i32)* bitcast (i32 (%B)* @b to i32 (i32)*) } | ||
; CHECK: { i32 (i32)* bitcast (i32 (%A)* @a to i32 (i32)*), i32 (i32)* bitcast (i32 (%A)* @a to i32 (i32)*) } | ||
|
||
define internal i32 @a(%A) unnamed_addr { | ||
extractvalue %A %0, 0 | ||
xor i32 %2, 0 | ||
ret i32 %3 | ||
} | ||
|
||
define internal i32 @b(%B) unnamed_addr { | ||
extractvalue %B %0, 0 | ||
xor i32 %2, 0 | ||
ret i32 %3 | ||
} | ||
|
||
define i32 @c(i32) { | ||
insertvalue %B undef, i32 %0, 0 | ||
call i32 @b(%B %2) | ||
; CHECK: call i32 bitcast (i32 (%A)* @a to i32 (%B)*)(%B %2) | ||
ret i32 %3 | ||
} |
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,18 @@ | ||
; RUN: opt -S -mergefunc < %s | FileCheck %s | ||
|
||
; CHECK-NOT: @b | ||
|
||
@x = constant { i32 (i32)*, i32 (i32)* } { i32 (i32)* @a, i32 (i32)* @b } | ||
; CHECK: { i32 (i32)* @a, i32 (i32)* @a } | ||
|
||
define internal i32 @a(i32 %a) unnamed_addr { | ||
%b = xor i32 %a, 0 | ||
%c = xor i32 %b, 0 | ||
ret i32 %c | ||
} | ||
|
||
define internal i32 @b(i32 %a) unnamed_addr { | ||
%b = xor i32 %a, 0 | ||
%c = xor i32 %b, 0 | ||
ret i32 %c | ||
} |