1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00
llvm-mirror/test/Linker/comdat-rm-dst.ll
Rafael Espindola 981c18bd80 Drop comdats from the dst module if they are not selected.
A really unfortunate design of llvm-link and related libraries is that
they operate one module at a time.

This means they can copy a GV to the destination module that should not
be there in the final result because a later bitcode file takes
precedence.

We already handled cases like a strong GV replacing a weak for example.

One case that is not currently handled is a comdat replacing another.
This doesn't happen in ELF, but with COFF largest selection kind it is
possible.

In "llvm-link a.ll b.ll" if the selected comdat was from a.ll,
everything will work and we will not copy the comdat from b.ll.

But if we run "llvm-link b.ll a.ll", we fail to delete the already
copied comdat from b.ll. This patch fixes that.

llvm-svn: 264103
2016-03-22 21:35:47 +00:00

34 lines
950 B
LLVM

; RUN: llvm-link -S -o %t %s %p/Inputs/comdat-rm-dst.ll
; RUN: FileCheck %s < %t
; RUN: FileCheck --check-prefix=RM %s < %t
target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"
target triple = "i686-pc-windows-msvc"
$foo = comdat largest
@foo = global i32 42, comdat
; CHECK-DAG: @foo = global i64 43, comdat
; RM-NOT: @alias =
@alias = alias i32, i32* @foo
; We should arguably reject an out of comdat reference to int_alias. Given that
; the verifier accepts it, test that we at least produce an output that passes
; the verifier.
; CHECK-DAG: @int_alias = external global i32
@int_alias = internal alias i32, i32* @foo
@bar = global i32* @int_alias
@func_alias = alias void (), void ()* @func
@zed = global void()* @func_alias
; CHECK-DAG: @zed = global void ()* @func_alias
; CHECK-DAG: declare void @func_alias()
; RM-NOT: @func()
define void @func() comdat($foo) {
ret void
}
; RM-NOT: var
@var = global i32 42, comdat($foo)