brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.7 KiB · 9e91efe Raw
219 lines · plain
1; REQUIRES: x86-registered-target2 3; Test devirtualization requiring promotion of local targets.4 5; Generate split module with summary for hybrid Thin/Regular LTO WPD.6; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t1.o %s7; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t2.o %p/Inputs/devirt2.ll8 9; Check that we have module flag showing splitting enabled, and that we don't10; generate summary information needed for index-based WPD.11; RUN: llvm-modextract -b -n=0 %t2.o -o %t2.o.012; RUN: llvm-dis -o - %t2.o.0 | FileCheck %s --check-prefix=ENABLESPLITFLAG --implicit-check-not=vTableFuncs --implicit-check-not=typeidCompatibleVTable13; RUN: llvm-modextract -b -n=1 %t2.o -o %t2.o.114; RUN: llvm-dis -o - %t2.o.1 | FileCheck %s --check-prefix=ENABLESPLITFLAG --implicit-check-not=vTableFuncs --implicit-check-not=typeidCompatibleVTable15; ENABLESPLITFLAG: !{i32 1, !"EnableSplitLTOUnit", i32 1}16 17; Generate unsplit module with summary for ThinLTO index-based WPD.18; Force generation of the bitcode index so that we also test lazy metadata19; loader handling of the type metadata.20; RUN: opt -bitcode-mdindex-threshold=0 -thinlto-bc -o %t3.o %s21; RUN: opt -bitcode-mdindex-threshold=0 -thinlto-bc -o %t4.o %p/Inputs/devirt2.ll22 23; Check that we don't have module flag when splitting not enabled for ThinLTO,24; and that we generate summary information needed for index-based WPD.25; RUN: llvm-dis -o - %t4.o | FileCheck %s --check-prefix=NOENABLESPLITFLAG26; NOENABLESPLITFLAG-DAG: !{i32 1, !"EnableSplitLTOUnit", i32 0}27; NOENABLESPLITFLAG-DAG: [[An:\^[0-9]+]] = gv: (name: "_ZN1A1nEi"28; NOENABLESPLITFLAG-DAG: [[Bf:\^[0-9]+]] = gv: (name: "_ZN1B1fEi"29; NOENABLESPLITFLAG-DAG: [[Cf:\^[0-9]+]] = gv: (name: "_ZN1C1fEi"30; NOENABLESPLITFLAG-DAG: [[Dm:\^[0-9]+]] = gv: (name: "_ZN1D1mEi"31; NOENABLESPLITFLAG-DAG: [[B:\^[0-9]+]] = gv: (name: "_ZTV1B", {{.*}} vTableFuncs: ((virtFunc: [[Bf]], offset: 16), (virtFunc: [[An]], offset: 24)), refs: ([[Bf]], [[An]])32; NOENABLESPLITFLAG-DAG: [[C:\^[0-9]+]] = gv: (name: "_ZTV1C", {{.*}} vTableFuncs: ((virtFunc: [[Cf]], offset: 16), (virtFunc: [[An]], offset: 24)), refs: ([[An]], [[Cf]])33; NOENABLESPLITFLAG-DAG: [[D:\^[0-9]+]] = gv: (name: "_ZTV1D", {{.*}} vTableFuncs: ((virtFunc: [[Dm]], offset: 16)), refs: ([[Dm]])34; NOENABLESPLITFLAG-DAG: typeidCompatibleVTable: (name: "_ZTS1A", summary: ((offset: 16, [[B]]), (offset: 16, [[C]])))35; NOENABLESPLITFLAG-DAG: typeidCompatibleVTable: (name: "_ZTS1B", summary: ((offset: 16, [[B]])))36; NOENABLESPLITFLAG-DAG: typeidCompatibleVTable: (name: "_ZTS1C", summary: ((offset: 16, [[C]])))37; NOENABLESPLITFLAG-DAG: typeidCompatibleVTable: (name: "_ZTS1D", summary: ((offset: 16, [[D]])))38 39; Index based WPD40; RUN: llvm-lto2 run %t3.o %t4.o -save-temps -pass-remarks=. \41; RUN:   -whole-program-visibility \42; RUN:   -wholeprogramdevirt-print-index-based \43; RUN:   -o %t5 \44; RUN:   -r=%t3.o,test,px \45; RUN:   -r=%t3.o,_ZTV1B, \46; RUN:   -r=%t3.o,_ZTV1C, \47; RUN:   -r=%t3.o,_ZTV1D, \48; RUN:   -r=%t3.o,_ZN1D1mEi, \49; RUN:   -r=%t3.o,test2, \50; RUN:   -r=%t4.o,_ZN1B1fEi,p \51; RUN:   -r=%t4.o,_ZN1C1fEi,p \52; RUN:   -r=%t4.o,_ZN1D1mEi,p \53; RUN:   -r=%t4.o,test2,px \54; RUN:   -r=%t4.o,_ZTV1B,px \55; RUN:   -r=%t4.o,_ZTV1C,px \56; RUN:   -r=%t4.o,_ZTV1D,px \57; RUN:   -r=%t4.o,_ZTV1E,px 2>&1 | FileCheck %s --check-prefix=REMARK --check-prefix=PRINT58; RUN: llvm-dis %t5.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR159; RUN: llvm-dis %t5.2.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR260; RUN: llvm-nm %t5.1 | FileCheck %s --check-prefix=NM-INDEX161; RUN: llvm-nm %t5.2 | FileCheck %s --check-prefix=NM-INDEX262 63; NM-INDEX1-DAG: U _ZN1A1nEi.llvm.64; NM-INDEX1-DAG: U _ZN1E1mEi.llvm.65; NM-INDEX1-DAG: U _ZN1D1mEi66 67; NM-INDEX2-DAG: T _ZN1A1nEi.llvm.68; NM-INDEX2-DAG: T _ZN1E1mEi.llvm.69; NM-INDEX2-DAG: W _ZN1D1mEi70; NM-INDEX2-DAG: t _ZN1B1fEi71; NM-INDEX2-DAG: t _ZN1C1fEi72 73; Index based WPD, distributed backends74; RUN: llvm-lto2 run %t3.o %t4.o -save-temps \75; RUN:   -whole-program-visibility \76; RUN:   -thinlto-distributed-indexes -wholeprogramdevirt-print-index-based \77; RUN:   -o %t5 \78; RUN:   -r=%t3.o,test,px \79; RUN:   -r=%t3.o,_ZTV1B, \80; RUN:   -r=%t3.o,_ZTV1C, \81; RUN:   -r=%t3.o,_ZTV1D, \82; RUN:   -r=%t3.o,_ZN1D1mEi, \83; RUN:   -r=%t3.o,test2, \84; RUN:   -r=%t4.o,_ZN1B1fEi,p \85; RUN:   -r=%t4.o,_ZN1C1fEi,p \86; RUN:   -r=%t4.o,_ZN1D1mEi,p \87; RUN:   -r=%t4.o,test2,px \88; RUN:   -r=%t4.o,_ZTV1B,px \89; RUN:   -r=%t4.o,_ZTV1C,px \90; RUN:   -r=%t4.o,_ZTV1D,px \91; RUN:   -r=%t4.o,_ZTV1E,px 2>&1 | FileCheck %s --check-prefix=PRINT92 93; PRINT-DAG: Devirtualized call to {{.*}} (_ZN1A1nEi)94; PRINT-DAG: Devirtualized call to {{.*}} (_ZN1E1mEi)95; PRINT-DAG: Devirtualized call to {{.*}} (_ZN1D1mEi)96 97; New PM98; RUN: llvm-lto2 run %t1.o %t2.o -save-temps -pass-remarks=. \99; RUN:   -whole-program-visibility \100; RUN:   -o %t5 \101; RUN:   -r=%t1.o,test,px \102; RUN:   -r=%t1.o,_ZTV1B, \103; RUN:   -r=%t1.o,_ZTV1C, \104; RUN:   -r=%t1.o,_ZTV1D, \105; RUN:   -r=%t1.o,_ZTV1D, \106; RUN:   -r=%t1.o,_ZN1D1mEi, \107; RUN:   -r=%t1.o,_ZN1D1mEi, \108; RUN:   -r=%t1.o,test2, \109; RUN:   -r=%t2.o,_ZN1A1nEi,p \110; RUN:   -r=%t2.o,_ZN1B1fEi,p \111; RUN:   -r=%t2.o,_ZN1C1fEi,p \112; RUN:   -r=%t2.o,_ZN1D1mEi,p \113; RUN:   -r=%t2.o,_ZN1E1mEi,p \114; RUN:   -r=%t2.o,_ZTV1B, \115; RUN:   -r=%t2.o,_ZTV1C, \116; RUN:   -r=%t2.o,_ZTV1D, \117; RUN:   -r=%t2.o,_ZTV1E, \118; RUN:   -r=%t2.o,test2,px \119; RUN:   -r=%t2.o,_ZN1A1nEi, \120; RUN:   -r=%t2.o,_ZN1B1fEi, \121; RUN:   -r=%t2.o,_ZN1C1fEi, \122; RUN:   -r=%t2.o,_ZN1D1mEi, \123; RUN:   -r=%t2.o,_ZN1E1mEi, \124; RUN:   -r=%t2.o,_ZTV1B,px \125; RUN:   -r=%t2.o,_ZTV1C,px \126; RUN:   -r=%t2.o,_ZTV1D,px \127; RUN:   -r=%t2.o,_ZTV1E,px 2>&1 | FileCheck %s --check-prefix=REMARK128; RUN: llvm-dis %t5.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR1129; RUN: llvm-dis %t5.2.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR2130; RUN: llvm-nm %t5.1 | FileCheck %s --check-prefix=NM-HYBRID1131; RUN: llvm-nm %t5.2 | FileCheck %s --check-prefix=NM-HYBRID2132 133; NM-HYBRID1-DAG: U _ZN1A1nEi.{{[0-9a-f]*}}134; NM-HYBRID1-DAG: U _ZN1E1mEi.{{[0-9a-f]*}}135; NM-HYBRID1-DAG: U _ZN1D1mEi136 137; NM-HYBRID2-DAG: T _ZN1A1nEi.{{[0-9a-f]*}}138; NM-HYBRID2-DAG: T _ZN1E1mEi.{{[0-9a-f]*}}139; NM-HYBRID2-DAG: W _ZN1D1mEi140; NM-HYBRID2-DAG: T _ZN1B1fEi141; NM-HYBRID2-DAG: T _ZN1C1fEi142 143; REMARK-DAG: single-impl: devirtualized a call to _ZN1A1nEi144; REMARK-DAG: single-impl: devirtualized a call to _ZN1D1mEi145; We should devirt call to _ZN1E1mEi once in importing module and once146; in original (exporting) module.147; REMARK-DAG: single-impl: devirtualized a call to _ZN1E1mEi148; REMARK-DAG: single-impl: devirtualized a call to _ZN1E1mEi149 150target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"151target triple = "x86_64-grtev4-linux-gnu"152 153%struct.A = type { ptr }154%struct.B = type { %struct.A }155%struct.C = type { %struct.A }156%struct.D = type { ptr }157%struct.E = type { ptr }158 159@_ZTV1B = external constant [4 x ptr]160@_ZTV1C = external constant [4 x ptr]161;@_ZTV1D = external constant [3 x ptr]162@_ZTV1D = linkonce_odr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr undef, ptr @_ZN1D1mEi] }, !type !3163 164define linkonce_odr i32 @_ZN1D1mEi(ptr %this, i32 %a) #0 {165   ret i32 0166}167 168; CHECK-IR1-LABEL: define i32 @test169define i32 @test(ptr %obj, ptr %obj2, ptr %obj3, i32 %a) {170entry:171  %vtable = load ptr, ptr %obj172  %p = call i1 @llvm.type.test(ptr %vtable, metadata !"_ZTS1A")173  call void @llvm.assume(i1 %p)174  %fptrptr = getelementptr ptr, ptr %vtable, i32 1175  %fptr1 = load ptr, ptr %fptrptr, align 8176 177  ; Check that the call was devirtualized. Ignore extra character before178  ; symbol name which would happen if it was promoted during module179  ; splitting for hybrid WPD.180  ; CHECK-IR1: %call = tail call i32 @_ZN1A1nEi181  %call = tail call i32 %fptr1(ptr nonnull %obj, i32 %a)182 183  %fptr22 = load ptr, ptr %vtable, align 8184 185  ; We still have to call it as virtual.186  ; CHECK-IR1: %call3 = tail call i32 %fptr22187  %call3 = tail call i32 %fptr22(ptr nonnull %obj, i32 %call)188 189  %vtable2 = load ptr, ptr %obj2190  %p2 = call i1 @llvm.type.test(ptr %vtable2, metadata !"_ZTS1D")191  call void @llvm.assume(i1 %p2)192 193  %fptr33 = load ptr, ptr %vtable2, align 8194 195  ; Check that the call was devirtualized.196  ; CHECK-IR1: %call4 = tail call i32 @_ZN1D1mEi197  %call4 = tail call i32 %fptr33(ptr nonnull %obj2, i32 %call3)198 199  %call5 = tail call i32 @test2(ptr nonnull %obj3, i32 %call4)200  ret i32 %call5201}202; CHECK-IR1-LABEL: ret i32203; CHECK-IR1-LABEL: }204 205; CHECK-IR2: define noundef i32 @test2206; CHECK-IR2-NEXT: entry:207; Check that the call was devirtualized. Ignore extra character before208; symbol name which would happen if it was promoted during module209; splitting for hybrid WPD.210; CHECK-IR2-NEXT:   %call4 = tail call i32 @{{.*}}_ZN1E1mEi211 212declare i1 @llvm.type.test(ptr, metadata)213declare void @llvm.assume(i1)214declare i32 @test2(ptr %obj, i32 %a)215 216attributes #0 = { noinline optnone }217 218!3 = !{i64 16, !"_ZTS1D"}219