diff options
Diffstat (limited to 'test/Transforms/ThinLTOBitcodeWriter')
8 files changed, 273 insertions, 13 deletions
diff --git a/test/Transforms/ThinLTOBitcodeWriter/circular-reference.ll b/test/Transforms/ThinLTOBitcodeWriter/circular-reference.ll new file mode 100644 index 000000000000..eeda79324497 --- /dev/null +++ b/test/Transforms/ThinLTOBitcodeWriter/circular-reference.ll @@ -0,0 +1,9 @@ +; RUN: opt -thinlto-bc -o %t %s +; RUN: llvm-modextract -b -n 0 -o - %t | llvm-dis | FileCheck --check-prefix=M0 %s +; RUN: llvm-modextract -b -n 1 -o - %t | llvm-dis | FileCheck --check-prefix=M1 %s + +; M0: @g = external constant +; M1: @g = constant +@g = constant i8* bitcast (i8** @g to i8*), !type !0 + +!0 = !{i32 0, !"typeid"} diff --git a/test/Transforms/ThinLTOBitcodeWriter/comdat.ll b/test/Transforms/ThinLTOBitcodeWriter/comdat.ll new file mode 100644 index 000000000000..caea48e0a543 --- /dev/null +++ b/test/Transforms/ThinLTOBitcodeWriter/comdat.ll @@ -0,0 +1,80 @@ +; RUN: opt -thinlto-bc -o %t %s +; RUN: llvm-modextract -n 0 -o - %t | llvm-dis | FileCheck --check-prefix=THIN %s +; RUN: llvm-modextract -n 1 -o - %t | llvm-dis | FileCheck --check-prefix=MERGED %s + +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc19.0.24215" + +; Internal comdat leader with type metadata. All comdat members need to live +; in the merged module, and the comdat needs to be renamed. +; MERGED: ${{"?lwt[^ ]+}} = comdat any +$lwt = comdat any + +; External comdat leader, type metadata on non-leader. All comdat +; members need to live in the merged module, internal members need to +; be renamed. +; MERGED: $nlwt = comdat any +$nlwt = comdat any + +; Comdat with two members without type metadata. All comdat members live in +; the ThinLTO module and no renaming needs to take place. +; THIN: $nt = comdat any +$nt = comdat any + +; MERGED: @lwt_aliasee = private unnamed_addr global +; MERGED-SAME: comdat(${{"?lwt[^ ]+}}) +@lwt_aliasee = private unnamed_addr global [1 x i8*] [i8* null], comdat($lwt), !type !0 + +; MERGED: {{@"?lwt_nl[^ ]+}} = hidden unnamed_addr global +; MERGED-SAME: comdat(${{"?lwt[^ ]+}}) +; THIN: {{@"?lwt_nl[^ ]+}} = external hidden +@lwt_nl = internal unnamed_addr global i32 0, comdat($lwt) + +; MERGED: @nlwt_aliasee = private unnamed_addr global +; MERGED-SAME: comdat($nlwt) +@nlwt_aliasee = private unnamed_addr global [1 x i8*] [i8* null], comdat($nlwt), !type !0 + +; MERGED: @nlwt = unnamed_addr global +; MERGED-SAME: comdat +; THIN: @nlwt = external +@nlwt = unnamed_addr global i32 0, comdat + +; THIN: @nt = internal +; THIN-SAME: comdat +@nt = internal unnamed_addr global [1 x i8*] [i8* null], comdat + +; THIN: @nt_nl = internal +; THIN-SAME: comdat($nt) +@nt_nl = internal unnamed_addr global i32 0, comdat($nt) + +; MERGED: {{@"?lwt[^ ]+}} = hidden unnamed_addr alias +; THIN: {{@"?lwt[^ ]+}} = external hidden +@lwt = internal unnamed_addr alias [1 x i8*], [1 x i8*]* @lwt_aliasee + +; MERGED: {{@"?nlwt_nl[^ ]+}} = hidden unnamed_addr alias +; THIN: {{@"?nlwt_nl[^ ]+}} = external hidden +@nlwt_nl = internal unnamed_addr alias [1 x i8*], [1 x i8*]* @nlwt_aliasee + +; The functions below exist just to make sure the globals are used. +define i8* @lwt_fun() { + %1 = load i32, i32* @lwt_nl + %2 = getelementptr inbounds [1 x i8*], [1 x i8*]* @lwt, i32 0, i32 %1 + %3 = load i8*, i8** %2 + ret i8* %3 +} + +define i8* @nlwt_fun() { + %1 = load i32, i32* @nlwt + %2 = getelementptr inbounds [1 x i8*], [1 x i8*]* @nlwt_nl, i32 0, i32 %1 + %3 = load i8*, i8** %2 + ret i8* %3 +} + +define i8* @nt_fun() { + %1 = load i32, i32* @nt_nl + %2 = getelementptr inbounds [1 x i8*], [1 x i8*]* @nt, i32 0, i32 %1 + %3 = load i8*, i8** %2 + ret i8* %3 +} + +!0 = !{i64 8, !"?AVA@@"} diff --git a/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll b/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll new file mode 100644 index 000000000000..d555ab0c1f6d --- /dev/null +++ b/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll @@ -0,0 +1,16 @@ +; RUN: opt -thinlto-bc -o %t %s +; RUN: llvm-modextract -n 0 -o - %t | llvm-dis | FileCheck --check-prefix=CHECK0 %s +; RUN: llvm-modextract -n 1 -o - %t | llvm-dis | FileCheck --check-prefix=CHECK1 %s +; CHECK0: @al = external global i8* +; CHECK1: @al = unnamed_addr alias i8*, + +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc19.0.24215" + +$al = comdat any + +@anon = private unnamed_addr constant { [1 x i8*] } { [1 x i8*] [i8* null] }, comdat($al), !type !0 + +@al = external unnamed_addr alias i8*, getelementptr inbounds ({ [1 x i8*] }, { [1 x i8*] }* @anon, i32 0, i32 0, i32 1) + +!0 = !{i64 8, !"?AVA@@"} diff --git a/test/Transforms/ThinLTOBitcodeWriter/no-type-md.ll b/test/Transforms/ThinLTOBitcodeWriter/no-type-md.ll index f1ada67abe50..753e07a326b7 100644 --- a/test/Transforms/ThinLTOBitcodeWriter/no-type-md.ll +++ b/test/Transforms/ThinLTOBitcodeWriter/no-type-md.ll @@ -1,6 +1,30 @@ -; RUN: opt -thinlto-bc -o %t %s -; RUN: llvm-dis -o - %t | FileCheck %s -; RUN: llvm-bcanalyzer -dump %t | FileCheck --check-prefix=BCA %s +; Generate bitcode files with summary, as well as minimized bitcode without +; the debug metadata for the thin link. +; RUN: opt -thinlto-bc -thin-link-bitcode-file=%t.thinlink.bc -o %t.bc %s +; RUN: llvm-dis -o - %t.bc | FileCheck %s +; RUN: llvm-dis -o - %t.thinlink.bc | FileCheck --check-prefix=NODEBUG %s +; RUN: llvm-bcanalyzer -dump %t.bc | FileCheck --check-prefix=BCA %s + +; Make sure the combined index files produced by both the normal and the +; thin link bitcode files are identical +; RUN: llvm-lto -thinlto -o %t3 %t.bc +; Copy the minimized bitcode to the regular bitcode path so the module +; paths in the index are the same (save and restore the regular bitcode +; for use again further down). +; RUN: mv %t.bc %t.bc.sv +; RUN: cp %t.thinlink.bc %t.bc +; RUN: llvm-lto -thinlto -o %t4 %t.bc +; RUN: mv %t.bc.sv %t.bc +; RUN: diff %t3.thinlto.bc %t4.thinlto.bc + +; Try again using -thinlto-action to produce combined index +; RUN: rm -f %t3.thinlto.bc %t4.thinlto.bc +; RUN: llvm-lto -thinlto-action=thinlink -o %t3.thinlto.bc %t.bc +; Copy the minimized bitcode to the regular bitcode path so the module +; paths in the index are the same. +; RUN: cp %t.thinlink.bc %t.bc +; RUN: llvm-lto -thinlto-action=thinlink -o %t4.thinlto.bc %t.bc +; RUN: diff %t3.thinlto.bc %t4.thinlto.bc ; BCA: <GLOBALVAL_SUMMARY_BLOCK @@ -11,3 +35,10 @@ define void @f() { ret void } + +; CHECK: !llvm.dbg.cu +; NODEBUG-NOT: !llvm.dbg.cu +!llvm.dbg.cu = !{} + +!1 = !{i32 2, !"Debug Info Version", i32 3} +!llvm.module.flags = !{!1} diff --git a/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll b/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll new file mode 100644 index 000000000000..087796b5031c --- /dev/null +++ b/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll @@ -0,0 +1,21 @@ +; RUN: opt -thinlto-bc -o %t %s +; RUN: llvm-modextract -b -n 0 -o - %t | llvm-dis | FileCheck --check-prefix=M0 %s +; RUN: llvm-modextract -b -n 1 -o - %t | llvm-dis | FileCheck --check-prefix=M1 %s + +define [1 x i8*]* @source() { + ret [1 x i8*]* @g +} + +; M0: @"g$84f59439b469192440047efc8de357fb" = external hidden constant [1 x i8*]{{$}} +; M1: @"g$84f59439b469192440047efc8de357fb" = hidden constant [1 x i8*] [i8* bitcast (i64 (i8*)* @"ok$84f59439b469192440047efc8de357fb" to i8*)] +@g = internal constant [1 x i8*] [ + i8* bitcast (i64 (i8*)* @ok to i8*) +], !type !0 + +; M0: define hidden i64 @"ok$84f59439b469192440047efc8de357fb" +; M1: define available_externally hidden i64 @"ok$84f59439b469192440047efc8de357fb" +define internal i64 @ok(i8* %this) { + ret i64 42 +} + +!0 = !{i32 0, !"typeid"} diff --git a/test/Transforms/ThinLTOBitcodeWriter/split-vfunc.ll b/test/Transforms/ThinLTOBitcodeWriter/split-vfunc.ll new file mode 100644 index 000000000000..0793459af414 --- /dev/null +++ b/test/Transforms/ThinLTOBitcodeWriter/split-vfunc.ll @@ -0,0 +1,75 @@ +; RUN: opt -thinlto-bc -o %t %s +; RUN: llvm-modextract -b -n 0 -o - %t | llvm-dis | FileCheck --check-prefix=M0 %s +; RUN: llvm-modextract -b -n 1 -o - %t | llvm-dis | FileCheck --check-prefix=M1 %s + +; M0: @g = external constant [9 x i8*]{{$}} +; M1: @g = constant [9 x i8*] +@g = constant [9 x i8*] [ + i8* bitcast (i64 (i8*)* @ok1 to i8*), + i8* bitcast (i64 (i8*, i64)* @ok2 to i8*), + i8* bitcast (void (i8*)* @wrongtype1 to i8*), + i8* bitcast (i128 (i8*)* @wrongtype2 to i8*), + i8* bitcast (i64 ()* @wrongtype3 to i8*), + i8* bitcast (i64 (i8*, i8*)* @wrongtype4 to i8*), + i8* bitcast (i64 (i8*, i128)* @wrongtype5 to i8*), + i8* bitcast (i64 (i8*)* @usesthis to i8*), + i8* bitcast (i8 (i8*)* @reads to i8*) +], !type !0 + +; M0: define i64 @ok1 +; M1: define available_externally i64 @ok1 +define i64 @ok1(i8* %this) { + ret i64 42 +} + +; M0: define i64 @ok2 +; M1: define available_externally i64 @ok2 +define i64 @ok2(i8* %this, i64 %arg) { + ret i64 %arg +} + +; M0: define void @wrongtype1 +; M1: declare void @wrongtype1() +define void @wrongtype1(i8*) { + ret void +} + +; M0: define i128 @wrongtype2 +; M1: declare void @wrongtype2() +define i128 @wrongtype2(i8*) { + ret i128 0 +} + +; M0: define i64 @wrongtype3 +; M1: declare void @wrongtype3() +define i64 @wrongtype3() { + ret i64 0 +} + +; M0: define i64 @wrongtype4 +; M1: declare void @wrongtype4() +define i64 @wrongtype4(i8*, i8*) { + ret i64 0 +} + +; M0: define i64 @wrongtype5 +; M1: declare void @wrongtype5() +define i64 @wrongtype5(i8*, i128) { + ret i64 0 +} + +; M0: define i64 @usesthis +; M1: declare void @usesthis() +define i64 @usesthis(i8* %this) { + %i = ptrtoint i8* %this to i64 + ret i64 %i +} + +; M0: define i8 @reads +; M1: declare void @reads() +define i8 @reads(i8* %this) { + %l = load i8, i8* %this + ret i8 %l +} + +!0 = !{i32 0, !"typeid"} diff --git a/test/Transforms/ThinLTOBitcodeWriter/split.ll b/test/Transforms/ThinLTOBitcodeWriter/split.ll index e08e92328b51..d37d10bd3560 100644 --- a/test/Transforms/ThinLTOBitcodeWriter/split.ll +++ b/test/Transforms/ThinLTOBitcodeWriter/split.ll @@ -1,20 +1,37 @@ -; RUN: opt -thinlto-bc -o %t %s -; RUN: llvm-modextract -b -n 0 -o %t0 %t -; RUN: llvm-modextract -b -n 1 -o %t1 %t +; Generate bitcode files with summary, as well as minimized bitcode without +; the debug metadata for the thin link. +; RUN: opt -thinlto-bc -thin-link-bitcode-file=%t2 -o %t %s +; RUN: llvm-modextract -b -n 0 -o %t0.bc %t +; RUN: llvm-modextract -b -n 1 -o %t1.bc %t +; RUN: llvm-modextract -b -n 0 -o %t0.thinlink.bc %t2 +; RUN: llvm-modextract -b -n 1 -o %t1.thinlink.bc %t2 ; RUN: not llvm-modextract -b -n 2 -o - %t 2>&1 | FileCheck --check-prefix=ERROR %s -; RUN: llvm-dis -o - %t0 | FileCheck --check-prefix=M0 %s -; RUN: llvm-dis -o - %t1 | FileCheck --check-prefix=M1 %s -; RUN: llvm-bcanalyzer -dump %t0 | FileCheck --check-prefix=BCA0 %s -; RUN: llvm-bcanalyzer -dump %t1 | FileCheck --check-prefix=BCA1 %s +; RUN: llvm-dis -o - %t0.bc | FileCheck --check-prefix=M0 %s +; RUN: llvm-dis -o - %t1.bc | FileCheck --check-prefix=M1 %s +; RUN: llvm-dis -o - %t0.thinlink.bc | FileCheck --check-prefix=NODEBUG %s +; RUN: llvm-dis -o - %t1.thinlink.bc | FileCheck --check-prefix=NODEBUG %s +; RUN: llvm-bcanalyzer -dump %t0.bc | FileCheck --check-prefix=BCA0 %s +; RUN: llvm-bcanalyzer -dump %t1.bc | FileCheck --check-prefix=BCA1 %s + +; Make sure the combined index files produced by both the normal and the +; thin link bitcode files are identical +; RUN: llvm-lto -thinlto -o %t3 %t0.bc +; Copy the minimized bitcode to the regular bitcode path so the module +; paths in the index are the same. +; RUN: cp %t0.thinlink.bc %t0.bc +; RUN: llvm-lto -thinlto -o %t4 %t0.bc +; RUN: diff %t3.thinlto.bc %t4.thinlto.bc ; ERROR: llvm-modextract: error: module index out of range; bitcode file contains 2 module(s) ; BCA0: <GLOBALVAL_SUMMARY_BLOCK ; BCA1-NOT: <GLOBALVAL_SUMMARY_BLOCK +$g = comdat any + ; M0: @g = external global i8{{$}} -; M1: @g = global i8 42, !type !0 -@g = global i8 42, !type !0 +; M1: @g = global i8 42, comdat, !type !0 +@g = global i8 42, comdat, !type !0 ; M0: define i8* @f() ; M1-NOT: @f() @@ -24,3 +41,11 @@ define i8* @f() { ; M1: !0 = !{i32 0, !"typeid"} !0 = !{i32 0, !"typeid"} + +; M0: !llvm.dbg.cu +; M1-NOT: !llvm.dbg.cu +; NODEBUG-NOT: !llvm.dbg.cu +!llvm.dbg.cu = !{} + +!1 = !{i32 2, !"Debug Info Version", i32 3} +!llvm.module.flags = !{!1} diff --git a/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll b/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll index fbc97a000971..718013e39b3e 100644 --- a/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll +++ b/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll @@ -1,6 +1,9 @@ -; RUN: opt -thinlto-bc -o %t %s +; RUN: opt -thinlto-bc -thin-link-bitcode-file=%t2 -o %t %s ; RUN: llvm-dis -o - %t | FileCheck %s ; RUN: llvm-bcanalyzer -dump %t | FileCheck --check-prefix=BCA %s +; When not splitting the module, the thin link bitcode file should simply be a +; copy of the regular module. +; RUN: diff %t %t2 ; BCA-NOT: <GLOBALVAL_SUMMARY_BLOCK |
