brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.6 KiB · 8f7e834 Raw
174 lines · plain
1; REQUIRES: x86-registered-target2 3; Do setup work for all below tests: generate bitcode and combined index4; RUN: opt -module-summary %s -o %t.bc5; RUN: opt -module-summary %p/Inputs/funcimport.ll -o %t2.bc6; RUN: llvm-lto -thinlto -print-summary-global-ids -o %t3 %t.bc %t2.bc 2>&1 | FileCheck %s --check-prefix=GUID7 8; Do the import now9; RUN: opt -passes=function-import -stats -print-imports -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIMDEF10; Try again with new pass manager11; RUN: opt -passes='function-import' -stats -print-imports -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIMDEF12; RUN: opt -passes='function-import' -debug-only=function-import -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=DUMP13; "-stats" and "-debug-only" require +Asserts.14; REQUIRES: asserts15 16; Test import with smaller instruction limit17; RUN: opt -passes=function-import -enable-import-metadata  -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=5 -S | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIM518; INSTLIM5-NOT: @staticfunc.llvm.19 20; Test force import all21; RUN: llvm-lto -thinlto-action=run -force-import-all %t.bc %t2.bc 2>&1 \22; RUN:  | FileCheck %s --check-prefix=IMPORTALL23; IMPORTALL-DAG: Error importing module: Failed to import function weakalias due to InterposableLinkage24 25target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"26target triple = "x86_64-apple-macosx10.11.0"27 28define i32 @main() #0 {29entry:30  call void (...) @weakalias()31  call void (...) @analias()32  call void (...) @linkoncealias()33  %call = call i32 (...) @referencestatics()34  %call1 = call i32 (...) @referenceglobals()35  %call2 = call i32 (...) @referencecommon()36  call void (...) @setfuncptr()37  call void (...) @callfuncptr()38  call void (...) @weakfunc()39  call void (...) @linkoncefunc2()40  call void (...) @referencelargelinkonce()41  call void (...) @variadic_no_va_start()42  call void (...) @variadic_va_start()43  ret i32 044}45 46; Won't import weak alias47; CHECK-DAG: declare void @weakalias48declare void @weakalias(...) #149 50; External alias imported as available_externally copy of aliasee51; CHECK-DAG: define available_externally void @analias52declare void @analias(...) #153 54; External alias imported as available_externally copy of aliasee55; (linkoncealias is an external alias to a linkonce_odr)56declare void @linkoncealias(...) #157; CHECK-DAG: define available_externally void @linkoncealias()58 59; INSTLIMDEF-DAG: Import referencestatics60; INSTLIMDEF-DAG: define available_externally i32 @referencestatics(i32 %i) !thinlto_src_module !0 !thinlto_src_file !1 {61; INSTLIM5-DAG: declare i32 @referencestatics(...)62declare i32 @referencestatics(...) #163 64; The import of referencestatics will expose call to staticfunc that65; should in turn be imported as a promoted/renamed and hidden function.66; Ensure that the call is to the properly-renamed function.67; INSTLIMDEF-DAG: Import staticfunc68; INSTLIMDEF-DAG: %call = call i32 @staticfunc.llvm.69; INSTLIMDEF-DAG: define available_externally hidden i32 @staticfunc.llvm.{{.*}} !thinlto_src_module !0 !thinlto_src_file !1 {70 71; INSTLIMDEF-DAG: Import referenceglobals72; CHECK-DAG: define available_externally i32 @referenceglobals(i32 %i) !thinlto_src_module !0 !thinlto_src_file !1 {73declare i32 @referenceglobals(...) #174 75; The import of referenceglobals will expose call to globalfunc1 that76; should in turn be imported.77; INSTLIMDEF-DAG: Import globalfunc178; CHECK-DAG: define available_externally void @globalfunc1() !thinlto_src_module !0 !thinlto_src_file !179 80; INSTLIMDEF-DAG: Import referencecommon81; CHECK-DAG: define available_externally i32 @referencecommon(i32 %i) !thinlto_src_module !0 !thinlto_src_file !1 {82declare i32 @referencecommon(...) #183 84; INSTLIMDEF-DAG: Import setfuncptr85; CHECK-DAG: define available_externally void @setfuncptr() !thinlto_src_module !0 !thinlto_src_file !1 {86declare void @setfuncptr(...) #187 88; INSTLIMDEF-DAG: Import callfuncptr89; CHECK-DAG: define available_externally void @callfuncptr() !thinlto_src_module !0 !thinlto_src_file !1 {90declare void @callfuncptr(...) #191 92; Ensure that all uses of local variable @P which has used in setfuncptr93; and callfuncptr are to the same promoted/renamed global.94; CHECK-DAG: @P.llvm.{{.*}} = available_externally hidden global ptr null95; CHECK-DAG: %0 = load ptr, ptr @P.llvm.96; CHECK-DAG: store ptr @staticfunc2.llvm.{{.*}}, ptr @P.llvm.97 98; Ensure that @referencelargelinkonce definition is pulled in, but later we99; also check that the linkonceodr function is not.100; CHECK-DAG: define available_externally void @referencelargelinkonce() !thinlto_src_module !0 !thinlto_src_file !1 {101; INSTLIM5-DAG: declare void @linkonceodr()102declare void @referencelargelinkonce(...)103 104; Won't import weak func105; CHECK-DAG: declare void @weakfunc(...)106declare void @weakfunc(...) #1107 108; Won't import linkonce func109; CHECK-DAG: declare void @linkoncefunc2(...)110declare void @linkoncefunc2(...) #1111 112; INSTLIMDEF-DAG: Import funcwithpersonality113; INSTLIMDEF-DAG: define available_externally hidden void @funcwithpersonality.llvm.{{.*}}() personality ptr @__gxx_personality_v0 !thinlto_src_module !0 !thinlto_src_file !1 {114; INSTLIM5-DAG: declare hidden void @funcwithpersonality.llvm.{{.*}}()115 116; We can import variadic functions without a va_start, since the inliner117; can handle them.118; INSTLIMDEF-DAG: Import variadic_no_va_start119; CHECK-DAG: define available_externally void @variadic_no_va_start(...) !thinlto_src_module !0 !thinlto_src_file !1 {120declare void @variadic_no_va_start(...)121 122; We can import variadic functions with a va_start, since the inliner123; can sometimes handle them.124; CHECK-DAG: define available_externally void @variadic_va_start(...)125declare void @variadic_va_start(...)126 127; INSTLIMDEF-DAG: Import globalfunc2128; INSTLIMDEF-DAG: 15 function-import - Number of functions imported129; INSTLIMDEF-DAG: 4 function-import - Number of global variables imported130 131; CHECK-DAG: !0 = !{!"{{.*}}.bc"}132; CHECK-DAG: !1 = !{!"{{.*}}/Inputs/funcimport.ll"}133 134; The actual GUID values will depend on path to test.135; GUID-DAG: GUID {{.*}} is weakalias136; GUID-DAG: GUID {{.*}} is referenceglobals137; GUID-DAG: GUID {{.*}} is weakfunc138; GUID-DAG: GUID {{.*}} is main139; GUID-DAG: GUID {{.*}} is referencecommon140; GUID-DAG: GUID {{.*}} is analias141; GUID-DAG: GUID {{.*}} is referencestatics142; GUID-DAG: GUID {{.*}} is linkoncealias143; GUID-DAG: GUID {{.*}} is setfuncptr144; GUID-DAG: GUID {{.*}} is callfuncptr145; GUID-DAG: GUID {{.*}} is funcwithpersonality146; GUID-DAG: GUID {{.*}} is setfuncptr147; GUID-DAG: GUID {{.*}} is staticfunc2148; GUID-DAG: GUID {{.*}} is __gxx_personality_v0149; GUID-DAG: GUID {{.*}} is referencestatics150; GUID-DAG: GUID {{.*}} is globalfunc1151; GUID-DAG: GUID {{.*}} is globalfunc2152; GUID-DAG: GUID {{.*}} is P153; GUID-DAG: GUID {{.*}} is staticvar154; GUID-DAG: GUID {{.*}} is commonvar155; GUID-DAG: GUID {{.*}} is weakalias156; GUID-DAG: GUID {{.*}} is staticfunc157; GUID-DAG: GUID {{.*}} is weakfunc158; GUID-DAG: GUID {{.*}} is referenceglobals159; GUID-DAG: GUID {{.*}} is weakvar160; GUID-DAG: GUID {{.*}} is staticconstvar161; GUID-DAG: GUID {{.*}} is analias162; GUID-DAG: GUID {{.*}} is globalvar163; GUID-DAG: GUID {{.*}} is referencecommon164; GUID-DAG: GUID {{.*}} is linkoncealias165; GUID-DAG: GUID {{.*}} is callfuncptr166; GUID-DAG: GUID {{.*}} is linkoncefunc167 168; DUMP:       Module [[M1:.*]] imports from 1 module169; DUMP-NEXT:  15 function definitions and 0 function declarations imported from [[M2:.*]]170; DUMP-NEXT:  4 vars imported from [[M2]]171 172; DUMP:       Imported 15 functions for Module [[M1]]173; DUMP-NEXT:  Imported 4 global variables for Module [[M1]]174