1; Check that we promote constant object in the source module and import it 2; even when it is referenced in some other GV initializer and/or is used 3; by store instructions. 4; RUN: opt -thinlto-bc %s -o %t1.bc 5; RUN: opt -thinlto-bc %p/Inputs/import-constant.ll -o %t2.bc 6; RUN: llvm-lto2 run -save-temps %t1.bc %t2.bc -o %t-out \ 7; RUN: -import-constants-with-refs \ 8; RUN: -r=%t1.bc,main,plx \ 9; RUN: -r=%t1.bc,_Z6getObjv,l \ 10; RUN: -r=%t2.bc,_Z6getObjv,pl \ 11; RUN: -r=%t2.bc,val,pl \ 12; RUN: -r=%t2.bc,outer,pl 13; RUN: llvm-dis %t-out.2.1.promote.bc -o - | FileCheck %s --check-prefix=PROMOTE 14; RUN: llvm-dis %t-out.1.3.import.bc -o - | FileCheck %s --check-prefix=IMPORT 15; RUN: llvm-dis %t-out.1.4.opt.bc -o - | FileCheck %s --check-prefix=OPT 16 17; Check that variable has been promoted in the source module 18; PROMOTE: @_ZL3Obj.llvm.{{.*}} = hidden constant %struct.S { i32 4, i32 8, i32* @val } 19 20; @outer is a write-only variable, so it's been converted to zeroinitializer. 21; IMPORT: @outer = internal local_unnamed_addr global %struct.Q zeroinitializer 22; IMPORT-NEXT: @_ZL3Obj.llvm.{{.*}} = available_externally hidden constant %struct.S { i32 4, i32 8, i32* @val } 23; IMPORT-NEXT: @val = external dso_local global i32 24 25; OPT: @outer = internal unnamed_addr global %struct.Q zeroinitializer 26 27; OPT: define dso_local i32 @main() 28; OPT-NEXT: entry: 29; OPT-NEXT: store %struct.S* null, %struct.S** getelementptr inbounds (%struct.Q, %struct.Q* @outer, i64 0, i32 0) 30; OPT-NEXT: ret i32 12 31 32target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 33target triple = "x86_64-unknown-linux-gnu" 34 35%struct.S = type { i32, i32, i32* } 36 37define dso_local i32 @main() local_unnamed_addr { 38entry: 39 %call = tail call %struct.S* @_Z6getObjv() 40 %d = getelementptr inbounds %struct.S, %struct.S* %call, i64 0, i32 0 41 %0 = load i32, i32* %d, align 8 42 %v = getelementptr inbounds %struct.S, %struct.S* %call, i64 0, i32 1 43 %1 = load i32, i32* %v, align 4 44 %add = add nsw i32 %1, %0 45 ret i32 %add 46} 47 48declare dso_local %struct.S* @_Z6getObjv() local_unnamed_addr 49