brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 10c1dd5 Raw
79 lines · plain
1; REQUIRES: x86-registered-target2 3; Test CFI devirtualization through the thin link and backend when4; a type id is Unsat (not used on any global's type metadata).5;6; In this test case, the first module is split and will import a resolution7; for its type test. The resolution would be exported by the second8; module, which is set up so that it does not get split (treated as regular9; LTO because it does not have any external globals from which to create10; a unique module ID). We should not actually get any resolution for the11; type id in this case, since no globals include it in their type metadata,12; so the resolution is Unsat and the type.checked.load instructions are13; converted to type tests that evaluate to false.14 15; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t.o %s16; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t1.o %p/Inputs/cfi-unsat.ll17 18; RUN: llvm-lto2 run %t.o %t1.o -save-temps -pass-remarks=. \19; RUN:   -whole-program-visibility \20; RUN:   -o %t3 \21; RUN:   -r=%t.o,test2,px \22; RUN:   -r=%t1.o,_ZTV1B,px \23; RUN:   -r=%t1.o,test,px \24; RUN:   -r=%t1.o,testb,px25; RUN: llvm-dis %t3.index.bc -o - | FileCheck %s --check-prefix=INDEX26; RUN: llvm-dis %t3.0.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR027; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR128 29; INDEX-NOT: "typeid:"30 31target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"32target triple = "x86_64-grtev4-linux-gnu"33 34%struct.A = type { ptr }35 36$test2 = comdat any37 38define linkonce_odr i32 @test2(ptr %obj, i32 %a) comdat {39entry:40  %vtable5 = load ptr, ptr %obj41 42  %0 = tail call { ptr, i1 } @llvm.type.checked.load(ptr %vtable5, i32 8, metadata !"_ZTS1A")43  %1 = extractvalue { ptr, i1 } %0, 144  br i1 %1, label %cont, label %trap45 46trap:47  tail call void @llvm.trap()48  unreachable49 50cont:51  %2 = extractvalue { ptr, i1 } %0, 052 53  %call = tail call i32 %2(ptr nonnull %obj, i32 %a)54 55  ret i32 %call56}57 58; CHECK-IR0: define weak_odr i32 @test59; CHECK-IR0-NEXT: entry:60; CHECK-IR0-NEXT: %vtable5 =61; CHECK-IR0-NEXT: tail call void @llvm.trap()62; CHECK-IR0-NEXT: unreachable63; CHECK-IR0-NEXT: }64; CHECK-IR0: define weak_odr i32 @testb65; CHECK-IR0-NEXT: entry:66; CHECK-IR0-NEXT: %vtable5 =67; CHECK-IR0-NEXT: tail call void @llvm.trap()68; CHECK-IR0-NEXT: unreachable69; CHECK-IR0-NEXT: }70 71; CHECK-IR1: define weak_odr i32 @test272; CHECK-IR1-NEXT:   entry:73; CHECK-IR1-NEXT:     tail call void @llvm.trap()74; CHECK-IR1-NEXT:     unreachable75; CHECK-IR1-NEXT:   }76 77declare { ptr, i1 } @llvm.type.checked.load(ptr, i32, metadata)78declare void @llvm.trap()79