xref: /llvm-project/llvm/test/ThinLTO/X86/index-const-prop-dead.ll (revision d5d3eb16b7ab72529c83dacb2889811491e48909)
1bf46e741SEugene Leviant; RUN: opt -module-summary %s -o %t1.bc
2bf46e741SEugene Leviant; RUN: opt -module-summary %p/Inputs/index-const-prop-define-g.ll -o %t2.bc
3bf46e741SEugene Leviant; RUN: llvm-lto2 run -save-temps %t2.bc -r=%t2.bc,g,pl \
4bf46e741SEugene Leviant; RUN:               %t1.bc -r=%t1.bc,main,plx -r=%t1.bc,foo,pl -r=%t1.bc,g, -o %t3
5bf46e741SEugene Leviant; RUN: llvm-dis %t3.2.3.import.bc -o - | FileCheck %s
6bf46e741SEugene Leviant
7bf46e741SEugene Leviant; Dead globals are converted to declarations by ThinLTO in dropDeadSymbols
8bf46e741SEugene Leviant; If we try to internalize such we'll get a broken module.
9d2ef8c1fSFangrui Song; CHECK: @g = external global i32
10bf46e741SEugene Leviant
117b1d7937SAmy Huangtarget datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
12bf46e741SEugene Levianttarget triple = "x86_64-unknown-linux-gnu"
13bf46e741SEugene Leviant
14bf46e741SEugene Leviant@g = external global i32
15bf46e741SEugene Leviant
16bf46e741SEugene Leviant; We need at least one live symbol to enable dead stripping
17bf46e741SEugene Leviant; Otherwise ModuleSummaryIndex::isGlobalValueLive will always
18bf46e741SEugene Leviant; return true.
19bf46e741SEugene Leviantdefine i32 @main() {
20bf46e741SEugene Leviant  ret i32 42
21bf46e741SEugene Leviant}
22bf46e741SEugene Leviant
23bf46e741SEugene Leviantdefine i32 @foo() {
24*d5d3eb16SFangrui Song  %v = load i32, ptr @g
25bf46e741SEugene Leviant  ret i32 %v
26bf46e741SEugene Leviant}
27