1; REQUIRES: x86-registered-target 2 3; Test CFI devirtualization through the thin link and backend when 4; 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 resolution 7; for its type test. The resolution would be exported by the second 8; module, which is set up so that it does not get split (treated as regular 9; LTO because it does not have any external globals from which to create 10; a unique module ID). We should not actually get any resolution for the 11; 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 are 13; converted to type tests that evaluate to false. 14 15; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t.o %s 16; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t1.o %p/Inputs/cfi-unsat.ll 17 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,px 25; RUN: llvm-dis %t3.index.bc -o - | FileCheck %s --check-prefix=INDEX 26; RUN: llvm-dis %t3.0.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR0 27; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR1 28 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 any 37 38define linkonce_odr i32 @test2(ptr %obj, i32 %a) comdat { 39entry: 40 %vtable5 = load ptr, ptr %obj 41 42 %0 = tail call { ptr, i1 } @llvm.type.checked.load(ptr %vtable5, i32 8, metadata !"_ZTS1A") 43 %1 = extractvalue { ptr, i1 } %0, 1 44 br i1 %1, label %cont, label %trap 45 46trap: 47 tail call void @llvm.trap() 48 unreachable 49 50cont: 51 %2 = extractvalue { ptr, i1 } %0, 0 52 53 %call = tail call i32 %2(ptr nonnull %obj, i32 %a) 54 55 ret i32 %call 56} 57 58; CHECK-IR0: define weak_odr i32 @test 59; CHECK-IR0-NEXT: entry: 60; CHECK-IR0-NEXT: %vtable5 = 61; CHECK-IR0-NEXT: tail call void @llvm.trap() 62; CHECK-IR0-NEXT: unreachable 63; CHECK-IR0-NEXT: } 64; CHECK-IR0: define weak_odr i32 @testb 65; CHECK-IR0-NEXT: entry: 66; CHECK-IR0-NEXT: %vtable5 = 67; CHECK-IR0-NEXT: tail call void @llvm.trap() 68; CHECK-IR0-NEXT: unreachable 69; CHECK-IR0-NEXT: } 70 71; CHECK-IR1: define weak_odr i32 @test2 72; CHECK-IR1-NEXT: entry: 73; CHECK-IR1-NEXT: tail call void @llvm.trap() 74; CHECK-IR1-NEXT: unreachable 75; CHECK-IR1-NEXT: } 76 77declare { ptr, i1 } @llvm.type.checked.load(ptr, i32, metadata) 78declare void @llvm.trap() 79