1; Test to ensure that comdat is renamed consistently when comdat leader is
2; promoted and renamed due to an import. Required by COFF.
3
4; REQUIRES: x86-registered-target
5
6; RUN: opt -thinlto-bc -o %t1.bc %s
7; RUN: opt -thinlto-bc -o %t2.bc %S/Inputs/comdat.ll
8; RUN: llvm-lto2 run -save-temps -o %t3 %t1.bc %t2.bc \
9; RUN:          -r %t1.bc,lwt_fun,plx \
10; RUN:          -r %t2.bc,main,plx \
11; RUN:          -r %t2.bc,lwt_fun,
12; RUN: llvm-dis -o - %t3.1.3.import.bc | FileCheck %s
13
14target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
15target triple = "x86_64-pc-windows-msvc19.0.24215"
16
17; CHECK: $lwt.llvm.[[HASH:[0-9]+]] = comdat any
18$lwt = comdat any
19
20; CHECK: @lwt_aliasee = private unnamed_addr global {{.*}}, comdat($lwt.llvm.[[HASH]])
21@lwt_aliasee = private unnamed_addr global [1 x i8*] [i8* null], comdat($lwt)
22
23; CHECK: @lwt.llvm.[[HASH]] = hidden unnamed_addr alias
24@lwt = internal unnamed_addr alias [1 x i8*], [1 x i8*]* @lwt_aliasee
25
26; Below function should get imported into other module, resulting in @lwt being
27; promoted and renamed.
28define i8* @lwt_fun() {
29  %1 = getelementptr inbounds [1 x i8*], [1 x i8*]* @lwt, i32 0, i32 0
30  %2 = load i8*, i8** %1
31  ret i8* %2
32}
33