Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See https://bugs.llvm.org/show_bug.cgi?id=35533, and D40844 Things covered: * Removing duplicate data segments (as determined by COMDATs emitted by the frontend) * Removing duplicate globals and functions in COMDATs * Checking that each time a COMDAT is seen it has the same symbols as at other times (ie it's a stronger check than simply giving all the symbols in the COMDAT weak linkage) Patch by Nicholas Wilson! Differential Revision: https://reviews.llvm.org/D40845 llvm-svn: 322415
- Loading branch information
Showing
10 changed files
with
251 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
$inlineFn = comdat any | ||
@constantData = weak_odr constant [3 x i8] c"abc", comdat($inlineFn) | ||
define linkonce_odr i32 @inlineFn() comdat { | ||
entry: | ||
ret i32 ptrtoint ([3 x i8]* @constantData to i32) | ||
} | ||
|
||
define i32 @callInline1() { | ||
entry: | ||
ret i32 ptrtoint (i32 ()* @inlineFn to i32) | ||
} |
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,11 @@ | ||
$inlineFn = comdat any | ||
@constantData = weak_odr constant [3 x i8] c"abc", comdat($inlineFn) | ||
define linkonce_odr i32 @inlineFn() comdat { | ||
entry: | ||
ret i32 ptrtoint ([3 x i8]* @constantData to i32) | ||
} | ||
|
||
define i32 @callInline2() { | ||
entry: | ||
ret i32 ptrtoint (i32 ()* @inlineFn to i32) | ||
} |
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,70 @@ | ||
; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %p/Inputs/comdat1.ll -o %t1.o | ||
; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %p/Inputs/comdat2.ll -o %t2.o | ||
; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %s -o %t.o | ||
; RUN: lld -flavor wasm -o %t.wasm %t.o %t1.o %t2.o | ||
; RUN: obj2yaml %t.wasm | FileCheck %s | ||
|
||
declare i32 @inlineFn() | ||
|
||
define void @_start() local_unnamed_addr { | ||
entry: | ||
%call = call i32 @inlineFn() | ||
ret void | ||
} | ||
|
||
; CHECK: - Type: GLOBAL | ||
; CHECK-NEXT: Globals: | ||
; CHECK-NEXT: - Index: 0 | ||
; CHECK-NEXT: Type: I32 | ||
; CHECK-NEXT: Mutable: true | ||
; CHECK-NEXT: InitExpr: | ||
; CHECK-NEXT: Opcode: I32_CONST | ||
; CHECK-NEXT: Value: 66576 | ||
; CHECK-NEXT: - Type: EXPORT | ||
; CHECK-NEXT: Exports: | ||
; CHECK-NEXT: - Name: memory | ||
; CHECK-NEXT: Kind: MEMORY | ||
; CHECK-NEXT: Index: 0 | ||
; CHECK-NEXT: - Name: _start | ||
; CHECK-NEXT: Kind: FUNCTION | ||
; CHECK-NEXT: Index: 0 | ||
; CHECK-NEXT: - Name: inlineFn | ||
; CHECK-NEXT: Kind: FUNCTION | ||
; CHECK-NEXT: Index: 1 | ||
; CHECK-NEXT: - Name: callInline1 | ||
; CHECK-NEXT: Kind: FUNCTION | ||
; CHECK-NEXT: Index: 2 | ||
; CHECK-NEXT: - Name: callInline2 | ||
; CHECK-NEXT: Kind: FUNCTION | ||
; CHECK-NEXT: Index: 3 | ||
; CHECK-NEXT: - Type: ELEM | ||
; CHECK-NEXT: Segments: | ||
; CHECK-NEXT: - Offset: | ||
; CHECK-NEXT: Opcode: I32_CONST | ||
; CHECK-NEXT: Value: 1 | ||
; CHECK-NEXT: Functions: [ 1 ] | ||
; CHECK-NEXT: - Type: CODE | ||
; CHECK-NEXT: Functions: | ||
; CHECK-NEXT: - Index: 0 | ||
; CHECK-NEXT: Locals: | ||
; CHECK-NEXT: Body: 1081808080001A0B | ||
; CHECK-NEXT: - Index: 1 | ||
; CHECK-NEXT: Locals: | ||
; CHECK-NEXT: Body: 4180888080000B | ||
; CHECK-NEXT: - Index: 2 | ||
; CHECK-NEXT: Locals: | ||
; CHECK-NEXT: Body: 4181808080000B | ||
; CHECK-NEXT: - Index: 3 | ||
; CHECK-NEXT: Locals: | ||
; CHECK-NEXT: Body: 4181808080000B | ||
; CHECK-NEXT: - Index: 4 | ||
; CHECK-NEXT: Locals: | ||
; CHECK-NEXT: Body: 0B | ||
; CHECK-NEXT: - Type: DATA | ||
; CHECK-NEXT: Segments: | ||
; CHECK-NEXT: - SectionOffset: 7 | ||
; CHECK-NEXT: MemoryIndex: 0 | ||
; CHECK-NEXT: Offset: | ||
; CHECK-NEXT: Opcode: I32_CONST | ||
; CHECK-NEXT: Value: 1024 | ||
; CHECK-NEXT: Content: '616263' |
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
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
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
Oops, something went wrong.