22 changes: 10 additions & 12 deletions llvm/test/ThinLTO/X86/pr35472.ll
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,24 @@ $_ZN5DeltaD2Ev = comdat any
define void @_Z5Bravov() !dbg !7 {
%Hotel = alloca %struct.Delta, align 4
%India = alloca %struct.Echo, align 4
call void @llvm.dbg.declare(metadata %struct.Delta* %Hotel, metadata !10, metadata !DIExpression()), !dbg !22
call void @_ZN4EchoD2Ev(%struct.Echo* %India), !dbg !28
call void @llvm.dbg.declare(metadata ptr %Hotel, metadata !10, metadata !DIExpression()), !dbg !22
call void @_ZN4EchoD2Ev(ptr %India), !dbg !28
ret void, !dbg !28
}

declare void @llvm.dbg.declare(metadata, metadata, metadata)

define linkonce_odr void @_ZN4EchoD2Ev(%struct.Echo* %this) unnamed_addr comdat align 2 {
%this.addr.i = alloca %struct.Charlie*, align 8
call void @llvm.dbg.declare(metadata %struct.Charlie** %this.addr.i, metadata !29, metadata !DIExpression()), !dbg !32
%this1.i = load %struct.Charlie*, %struct.Charlie** %this.addr.i, align 8
%Golf.i = getelementptr inbounds %struct.Charlie, %struct.Charlie* %this1.i, i32 0, i32 0, !dbg !33
define linkonce_odr void @_ZN4EchoD2Ev(ptr %this) unnamed_addr comdat align 2 {
%this.addr.i = alloca ptr, align 8
call void @llvm.dbg.declare(metadata ptr %this.addr.i, metadata !29, metadata !DIExpression()), !dbg !32
%this1.i = load ptr, ptr %this.addr.i, align 8
ret void
}

define linkonce_odr void @_ZN5DeltaD2Ev(%struct.Delta* %this) unnamed_addr comdat align 2 !dbg !36 {
%this.addr.i = alloca %struct.Charlie*, align 8
call void @llvm.dbg.declare(metadata %struct.Charlie** %this.addr.i, metadata !29, metadata !DIExpression()), !dbg !41
%this1.i = load %struct.Charlie*, %struct.Charlie** %this.addr.i, align 8
%Golf.i = getelementptr inbounds %struct.Charlie, %struct.Charlie* %this1.i, i32 0, i32 0, !dbg !48
define linkonce_odr void @_ZN5DeltaD2Ev(ptr %this) unnamed_addr comdat align 2 !dbg !36 {
%this.addr.i = alloca ptr, align 8
call void @llvm.dbg.declare(metadata ptr %this.addr.i, metadata !29, metadata !DIExpression()), !dbg !41
%this1.i = load ptr, ptr %this.addr.i, align 8
ret void
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/ThinLTO/X86/promote-local-name.ll
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ target triple = "x86_64-unknown-linux-gnu"
define i32 @main() {
entry:
%retval = alloca i32, align 4
store i32 0, i32* %retval, align 4
store i32 0, ptr %retval, align 4
%call = call i32 (...) @b()
ret i32 %call
}
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/ThinLTO/X86/reference_non_importable.ll
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ target triple = "x86_64-apple-macosx10.11.0"
; RUN: llvm-dis < %t.o.1.2.internalize.bc | FileCheck %s --check-prefix=PROMOTE
; PROMOTE: @a = private global i8 0, section "__TEXT,__cstring,cstring_literals"
@a = private global i8 0, section "__TEXT,__cstring,cstring_literals"
@b = global i8 *@a
@b = global ptr@a


; We want foo to be imported in the main module!
; RUN: llvm-dis < %t.o.2.3.import.bc | FileCheck %s --check-prefix=IMPORT
; IMPORT: define available_externally dso_local ptr @foo()
define i8 **@foo() {
ret i8 **@b
define ptr@foo() {
ret ptr@b
}
13 changes: 6 additions & 7 deletions llvm/test/ThinLTO/X86/selective-save-temps.ll
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,16 @@
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.S = type { i32, i32, i32* }
%struct.S = type { i32, i32, ptr }

define dso_local i32 @main() local_unnamed_addr {
entry:
%call = tail call %struct.S* @_Z6getObjv()
%d = getelementptr inbounds %struct.S, %struct.S* %call, i64 0, i32 0
%0 = load i32, i32* %d, align 8
%v = getelementptr inbounds %struct.S, %struct.S* %call, i64 0, i32 1
%1 = load i32, i32* %v, align 4
%call = tail call ptr @_Z6getObjv()
%0 = load i32, ptr %call, align 8
%v = getelementptr inbounds %struct.S, ptr %call, i64 0, i32 1
%1 = load i32, ptr %v, align 4
%add = add nsw i32 %1, %0
ret i32 %add
}

declare dso_local %struct.S* @_Z6getObjv() local_unnamed_addr
declare dso_local ptr @_Z6getObjv() local_unnamed_addr
3 changes: 1 addition & 2 deletions llvm/test/ThinLTO/X86/thinlto-internalize-doublepromoted.ll
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ target triple = "x86_64-apple-macosx10.15.0"

; CHECK: define hidden void @foo.llvm.123()
define hidden void @foo.llvm.123() {
%1 = getelementptr inbounds [10 x i8], [10 x i8]* @switch.table.foo.llvm.123, i64 0, i64 0
store i8 1, i8* %1, align 8
store i8 1, ptr @switch.table.foo.llvm.123, align 8
ret void
}
2 changes: 1 addition & 1 deletion llvm/test/ThinLTO/X86/thinlto-internalize-used.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.15.0"

@llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()* @foo to i8*)], section "llvm.metadata"
@llvm.used = appending global [1 x ptr] [ptr @foo], section "llvm.metadata"

; Make sure foo is not internalized.
; CHECK: define i32 @foo()
Expand Down
8 changes: 3 additions & 5 deletions llvm/test/ThinLTO/X86/tli-nobuiltin.ll
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.11.0"

declare i32 @fprintf(%FILE*, i8*, ...)
declare i32 @fprintf(ptr, ptr, ...)

%FILE = type { }

Expand All @@ -37,10 +37,8 @@ declare i32 @fprintf(%FILE*, i8*, ...)

; Check fprintf(fp, "%s", str) -> fwrite(str, fp) only when builtins are enabled

define void @foo(%FILE* %fp) {
%fmt = getelementptr [3 x i8], [3 x i8]* @percent_s, i32 0, i32 0
%str = getelementptr [13 x i8], [13 x i8]* @hello_world, i32 0, i32 0
call i32 (%FILE*, i8*, ...) @fprintf(%FILE* %fp, i8* %fmt, i8* %str)
define void @foo(ptr %fp) {
call i32 (ptr, ptr, ...) @fprintf(ptr %fp, ptr @percent_s, ptr @hello_world)
ret void
}

20 changes: 10 additions & 10 deletions llvm/test/ThinLTO/X86/visibility-elf.ll
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ target triple = "x86_64-unknown-linux-gnu"
@var1 = weak global i32 1, align 4
@var2 = extern_weak global i32

declare void @ext(void ()*)
declare void @ext(ptr)

; CHECK: declare hidden i32 @hidden_def_weak_def()
; CHECK: declare protected void @protected_def_weak_def()
Expand All @@ -53,7 +53,7 @@ declare void @ext(void ()*)

define weak i32 @hidden_def_weak_def() {
entry:
%0 = load i32, i32* @var2
%0 = load i32, ptr @var2
ret i32 %0
}

Expand All @@ -75,13 +75,13 @@ declare hidden void @protected_def_hidden_ref()

define i32 @main() {
entry:
call void @ext(void ()* bitcast (i32 ()* @hidden_def_weak_def to void ()*))
call void @ext(void ()* @protected_def_weak_def)
call void @ext(void ()* @protected_def_weak_hidden_def)
call void @ext(void ()* @hidden_def_ref)
call void @ext(void ()* @hidden_def_weak_ref)
call void @ext(void ()* @protected_def_hidden_ref)
call void @ext(void ()* @not_imported)
call void @ext(ptr @hidden_def_weak_def)
call void @ext(ptr @protected_def_weak_def)
call void @ext(ptr @protected_def_weak_hidden_def)
call void @ext(ptr @hidden_def_ref)
call void @ext(ptr @hidden_def_weak_ref)
call void @ext(ptr @protected_def_hidden_ref)
call void @ext(ptr @not_imported)

;; Calls ensure the functions are imported.
call i32 @hidden_def_weak_def()
Expand All @@ -102,7 +102,7 @@ target triple = "x86_64-unknown-linux-gnu"

define hidden i32 @hidden_def_weak_def() {
entry:
%0 = load i32, i32* @var1
%0 = load i32, ptr @var1
ret i32 %0
}

Expand Down
14 changes: 7 additions & 7 deletions llvm/test/ThinLTO/X86/visibility-macho.ll
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ target triple = "x86_64-apple-macosx10.15.0"
@var1 = weak global i32 1, align 4
@var2 = extern_weak global i32

declare void @ext(void ()*)
declare void @ext(ptr)

; CHECK: declare hidden i32 @hidden_def_weak_def()
;; Currently the visibility is not propagated onto an unimported function,
Expand All @@ -40,7 +40,7 @@ declare void @ext(void ()*)

define weak i32 @hidden_def_weak_def() {
entry:
%0 = load i32, i32* @var2
%0 = load i32, ptr @var2
ret i32 %0
}

Expand All @@ -51,10 +51,10 @@ declare extern_weak void @hidden_def_weak_ref()

define i32 @main() {
entry:
call void @ext(void ()* bitcast (i32 ()* @hidden_def_weak_def to void ()*))
call void @ext(void ()* @hidden_def_ref)
call void @ext(void ()* @hidden_def_weak_ref)
call void @ext(void ()* @not_imported)
call void @ext(ptr @hidden_def_weak_def)
call void @ext(ptr @hidden_def_ref)
call void @ext(ptr @hidden_def_weak_ref)
call void @ext(ptr @not_imported)

;; Calls ensure the functions are imported.
call i32 @hidden_def_weak_def()
Expand All @@ -72,7 +72,7 @@ target triple = "x86_64-apple-macosx10.15.0"

define hidden i32 @hidden_def_weak_def() {
entry:
%0 = load i32, i32* @var1
%0 = load i32, ptr @var1
ret i32 %0
}

Expand Down
13 changes: 6 additions & 7 deletions llvm/test/ThinLTO/X86/weak_externals.ll
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,16 @@ $_ZZN9SingletonI1SE11getInstanceEvE13instance_weak = comdat any

@_ZZN9SingletonI1SE11getInstanceEvE8instance = linkonce_odr dso_local global %struct.S zeroinitializer, comdat, align 8

@_ZZN9SingletonI1SE11getInstanceEvE13instance_weak = weak_odr dso_local global %struct.S* null, comdat, align 8
@_ZZN9SingletonI1SE11getInstanceEvE13instance_weak = weak_odr dso_local global ptr null, comdat, align 8

define dso_local void @_ZL5initSv() {
%1 = call dereferenceable(16) %struct.S* @_ZN9SingletonI1SE11getInstanceEv()
store %struct.S* %1, %struct.S** @_ZZN9SingletonI1SE11getInstanceEvE13instance_weak
%2 = getelementptr inbounds %struct.S, %struct.S* %1, i32 0, i32 0
store i64 1, i64* %2, align 8
%1 = call dereferenceable(16) ptr @_ZN9SingletonI1SE11getInstanceEv()
store ptr %1, ptr @_ZZN9SingletonI1SE11getInstanceEvE13instance_weak
store i64 1, ptr %1, align 8
ret void
}

define linkonce_odr dso_local dereferenceable(16) %struct.S* @_ZN9SingletonI1SE11getInstanceEv() #0 comdat align 2 {
ret %struct.S* @_ZZN9SingletonI1SE11getInstanceEvE8instance
define linkonce_odr dso_local dereferenceable(16) ptr @_ZN9SingletonI1SE11getInstanceEv() #0 comdat align 2 {
ret ptr @_ZZN9SingletonI1SE11getInstanceEvE8instance
}

12 changes: 6 additions & 6 deletions llvm/test/ThinLTO/X86/weak_resolution.ll
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16
target triple = "x86_64-apple-macosx10.11.0"

; Alias are resolved, but can't be turned into "available_externally"
; MOD1: @linkonceodralias = weak_odr alias void (), void ()* @linkonceodrfuncwithalias
; MOD2: @linkonceodralias = linkonce_odr alias void (), void ()* @linkonceodrfuncwithalias
@linkonceodralias = linkonce_odr alias void (), void ()* @linkonceodrfuncwithalias
; MOD1: @linkonceodralias = weak_odr alias void (), ptr @linkonceodrfuncwithalias
; MOD2: @linkonceodralias = linkonce_odr alias void (), ptr @linkonceodrfuncwithalias
@linkonceodralias = linkonce_odr alias void (), ptr @linkonceodrfuncwithalias

; Alias are resolved, but can't be turned into "available_externally"
; MOD1: @linkoncealias = weak alias void (), void ()* @linkoncefuncwithalias
; MOD2: @linkoncealias = linkonce alias void (), void ()* @linkoncefuncwithalias
@linkoncealias = linkonce alias void (), void ()* @linkoncefuncwithalias
; MOD1: @linkoncealias = weak alias void (), ptr @linkoncefuncwithalias
; MOD2: @linkoncealias = linkonce alias void (), ptr @linkoncefuncwithalias
@linkoncealias = linkonce alias void (), ptr @linkoncefuncwithalias

; Function with an alias are resolved to weak_odr in prevailing module, but
; not optimized in non-prevailing module (illegal to have an
Expand Down