brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · c1d0b5f Raw
111 lines · plain
1; REQUIRES: x86-registered-target2 3; Test CFI devirtualization through the thin link and backend.4 5; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t.o %s6 7; RUN: llvm-lto2 run %t.o -save-temps -pass-remarks=. \8; RUN:   -whole-program-visibility \9; RUN:   -o %t3 \10; RUN:   -r=%t.o,test,px \11; RUN:   -r=%t.o,_ZN1A1nEi,p \12; RUN:   -r=%t.o,_ZN1B1fEi,p \13; RUN:   -r=%t.o,_ZN1C1fEi,p \14; RUN:   -r=%t.o,empty,p \15; RUN:   -r=%t.o,_ZTV1B, \16; RUN:   -r=%t.o,_ZTV1C, \17; RUN:   -r=%t.o,_ZN1A1nEi, \18; RUN:   -r=%t.o,_ZN1B1fEi, \19; RUN:   -r=%t.o,_ZN1C1fEi, \20; RUN:   -r=%t.o,_ZTV1B,px \21; RUN:   -r=%t.o,_ZTV1C,px 2>&1 | FileCheck %s --check-prefix=REMARK22; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR23 24; REMARK: single-impl: devirtualized a call to _ZN1A1nEi25 26; Next check that we emit an error when trying to LTO link this module27; containing an llvm.type.checked.load (with a split LTO Unit) with one28; that does not have a split LTO Unit. Use -thinlto-distributed-indexes29; to ensure it is being caught in the thin link.30; RUN: opt -thinlto-bc -o %t2.o %S/Inputs/empty.ll31; RUN: not llvm-lto2 run %t.o %t2.o -thinlto-distributed-indexes \32; RUN:   -whole-program-visibility \33; RUN:   -o %t3 \34; RUN:   -r=%t.o,test,px \35; RUN:   -r=%t.o,_ZN1A1nEi,p \36; RUN:   -r=%t.o,_ZN1B1fEi,p \37; RUN:   -r=%t.o,_ZN1C1fEi,p \38; RUN:   -r=%t.o,empty,p \39; RUN:   -r=%t.o,_ZTV1B, \40; RUN:   -r=%t.o,_ZTV1C, \41; RUN:   -r=%t.o,_ZN1A1nEi, \42; RUN:   -r=%t.o,_ZN1B1fEi, \43; RUN:   -r=%t.o,_ZN1C1fEi, \44; RUN:   -r=%t.o,_ZTV1B,px \45; RUN:   -r=%t.o,_ZTV1C,px 2>&1 | FileCheck %s --check-prefix=ERROR46; ERROR: failed: inconsistent LTO Unit splitting (recompile with -fsplit-lto-unit)47 48target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"49target triple = "x86_64-grtev4-linux-gnu"50 51%struct.A = type { ptr }52%struct.B = type { %struct.A }53%struct.C = type { %struct.A }54 55@_ZTV1B = constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr undef, ptr @_ZN1B1fEi, ptr @_ZN1A1nEi] }, !type !0, !type !156@_ZTV1C = constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr undef, ptr @_ZN1C1fEi, ptr @_ZN1A1nEi] }, !type !0, !type !257 58; Put declaration first to test handling of remarks when the first59; function has no basic blocks.60declare void @empty()61 62; CHECK-IR-LABEL: define i32 @test63define i32 @test(ptr %obj, i32 %a) {64entry:65  %vtable5 = load ptr, ptr %obj66 67  %0 = tail call { ptr, i1 } @llvm.type.checked.load(ptr %vtable5, i32 8, metadata !"_ZTS1A")68  %1 = extractvalue { ptr, i1 } %0, 169  br i1 %1, label %cont, label %trap70 71trap:72  tail call void @llvm.trap()73  unreachable74 75cont:76  %2 = extractvalue { ptr, i1 } %0, 077 78  ; Check that the call was devirtualized.79  ; CHECK-IR: %call = tail call i32 @_ZN1A1nEi80  %call = tail call i32 %2(ptr nonnull %obj, i32 %a)81  %vtable16 = load ptr, ptr %obj82  %3 = tail call { ptr, i1 } @llvm.type.checked.load(ptr %vtable16, i32 0, metadata !"_ZTS1A")83  %4 = extractvalue { ptr, i1 } %3, 184  br i1 %4, label %cont2, label %trap85 86cont2:87  %5 = extractvalue { ptr, i1 } %3, 088 89  ; Check that traps are conditional. Invalid TYPE_ID can cause90  ; unconditional traps.91  ; CHECK-IR: br i1 {{.*}}, label %trap, label %cont292 93  ; We still have to call it as virtual.94  ; CHECK-IR: %call3 = tail call i32 %95  %call3 = tail call i32 %5(ptr nonnull %obj, i32 %call)96  ret i32 %call397}98; CHECK-IR-LABEL: ret i3299; CHECK-IR-LABEL: }100 101declare { ptr, i1 } @llvm.type.checked.load(ptr, i32, metadata)102declare void @llvm.trap()103 104declare i32 @_ZN1B1fEi(ptr %this, i32 %a)105declare i32 @_ZN1A1nEi(ptr %this, i32 %a)106declare i32 @_ZN1C1fEi(ptr %this, i32 %a)107 108!0 = !{i64 16, !"_ZTS1A"}109!1 = !{i64 16, !"_ZTS1B"}110!2 = !{i64 16, !"_ZTS1C"}111