https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/241647
>From b3c4191f8bb671a5edd178d3ba5bab2cf77031ee Mon Sep 17 00:00:00 2001 From: Vitaly Buka <[email protected]> Date: Wed, 11 Nov 2026 19:06:00 -0800 Subject: [PATCH 1/2] [spr] update Created using spr 2.0.0-beta.2 --- clang/lib/CodeGen/CGClass.cpp | 6 +- clang/test/CodeGenCXX/cfi-ignorelist.cpp | 2 +- clang/test/CodeGenCXX/cfi-vcall-no-trap.cpp | 2 +- .../cfi-vcall-trap-recover-runtime.cpp | 66 +++--- .../cfi-vcall-type-checked-load.cpp | 205 +++++++++--------- compiler-rt/test/cfi/anon-namespace.cpp | 4 +- compiler-rt/test/cfi/overwrite.cpp | 10 +- compiler-rt/test/cfi/simple-fail.cpp | 2 +- compiler-rt/test/cfi/vdtor.cpp | 2 +- 9 files changed, 153 insertions(+), 146 deletions(-) diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index 580ed18fc99b5f..6f0577472c9bad 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -3000,11 +3000,7 @@ bool CodeGenFunction::ShouldEmitVTableTypeCheckedLoad(const CXXRecordDecl *RD) { // GlobalDCE's virtual function elimination only treats vtable slots as live // if they are loaded via llvm.type.checked.load, so it must always be used. - if (CGM.getCodeGenOpts().VirtualFunctionElimination) - return true; - - return ShouldEmitCFICheck && - CGM.getCodeGenOpts().SanitizeTrap.has(SanitizerKind::CFIVCall); + return CGM.getCodeGenOpts().VirtualFunctionElimination || ShouldEmitCFICheck; } llvm::Value *CodeGenFunction::EmitVTableTypeCheckedLoad( diff --git a/clang/test/CodeGenCXX/cfi-ignorelist.cpp b/clang/test/CodeGenCXX/cfi-ignorelist.cpp index e98b357adc944c..aefef23ec69b62 100644 --- a/clang/test/CodeGenCXX/cfi-ignorelist.cpp +++ b/clang/test/CodeGenCXX/cfi-ignorelist.cpp @@ -36,7 +36,7 @@ struct S2 { // NOSTD-VFE-LABEL: define{{.*}}s1f // NOBL: llvm.type.test // NOSTD: llvm.type.test -// NOSTD-WPD: call i1 @llvm.type.test +// NOSTD-WPD: call { ptr, i1 } @llvm.type.checked.load // NOSTD-WPD: call void @__ubsan_handle_cfi_check_fail_abort(ptr // NOSTD-VFE: call { ptr, i1 } @llvm.type.checked.load // NOSTD-VFE: call void @__ubsan_handle_cfi_check_fail_abort(ptr diff --git a/clang/test/CodeGenCXX/cfi-vcall-no-trap.cpp b/clang/test/CodeGenCXX/cfi-vcall-no-trap.cpp index b3db3dac90fdbe..5bb4e0ef6da5a8 100644 --- a/clang/test/CodeGenCXX/cfi-vcall-no-trap.cpp +++ b/clang/test/CodeGenCXX/cfi-vcall-no-trap.cpp @@ -7,7 +7,7 @@ struct S1 { }; // CHECK: define{{.*}}s1f -// CFI: llvm.type.test(ptr {{.*}}, metadata !"{{.*}}S1{{.*}}") +// CFI: llvm.type.checked.load(ptr {{.*}}, i32 0, metadata !"{{.*}}S1{{.*}}") // CFI: llvm.type.test(ptr {{.*}}, metadata !"all-vtables") // CFI-NOT: llvm.assume // NOCFI: llvm.type.test(ptr {{.*}}, metadata !"{{.*}}S1{{.*}}") diff --git a/clang/test/CodeGenCXX/cfi-vcall-trap-recover-runtime.cpp b/clang/test/CodeGenCXX/cfi-vcall-trap-recover-runtime.cpp index 498f3820e11621..7acc6976e22cd8 100644 --- a/clang/test/CodeGenCXX/cfi-vcall-trap-recover-runtime.cpp +++ b/clang/test/CodeGenCXX/cfi-vcall-trap-recover-runtime.cpp @@ -43,18 +43,18 @@ struct S1 { // ABORT-NEXT: store ptr [[S1]], ptr [[S1_ADDR]], align 8 // ABORT-NEXT: [[TMP0:%.*]] = load ptr, ptr [[S1_ADDR]], align 8 // ABORT-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 -// ABORT-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"_ZTS2S1"), !nosanitize [[META8:![0-9]+]] -// ABORT-NEXT: [[TMP2:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META8]] -// ABORT-NEXT: br i1 [[TMP1]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF9:![0-9]+]], !nosanitize [[META8]] +// ABORT-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load(ptr [[VTABLE]], i32 0, metadata !"_ZTS2S1"), !nosanitize [[META8:![0-9]+]] +// ABORT-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1, !nosanitize [[META8]] +// ABORT-NEXT: [[TMP3:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META8]] +// ABORT-NEXT: br i1 [[TMP2]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF9:![0-9]+]], !nosanitize [[META8]] // ABORT: [[HANDLER_CFI_CHECK_FAIL]]: -// ABORT-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META8]] -// ABORT-NEXT: [[TMP4:%.*]] = zext i1 [[TMP2]] to i64, !nosanitize [[META8]] -// ABORT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.00e38160576ab76122d2f8d139d2e390.1, i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR3:[0-9]+]], !nosanitize [[META8]] +// ABORT-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META8]] +// ABORT-NEXT: [[TMP5:%.*]] = zext i1 [[TMP3]] to i64, !nosanitize [[META8]] +// ABORT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.00e38160576ab76122d2f8d139d2e390.1, i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR4:[0-9]+]], !nosanitize [[META8]] // ABORT-NEXT: unreachable, !nosanitize [[META8]] // ABORT: [[CONT]]: -// ABORT-NEXT: [[VFN:%.*]] = getelementptr inbounds ptr, ptr [[VTABLE]], i64 0 -// ABORT-NEXT: [[TMP5:%.*]] = load ptr, ptr [[VFN]], align 8 -// ABORT-NEXT: call void [[TMP5]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) +// ABORT-NEXT: [[TMP6:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 0, !nosanitize [[META8]] +// ABORT-NEXT: call void [[TMP6]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) // ABORT-NEXT: ret void // // RECOVER-LABEL: define hidden void @_Z3s1fP2S1( @@ -64,18 +64,18 @@ struct S1 { // RECOVER-NEXT: store ptr [[S1]], ptr [[S1_ADDR]], align 8 // RECOVER-NEXT: [[TMP0:%.*]] = load ptr, ptr [[S1_ADDR]], align 8 // RECOVER-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 -// RECOVER-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"_ZTS2S1"), !nosanitize [[META8:![0-9]+]] -// RECOVER-NEXT: [[TMP2:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META8]] -// RECOVER-NEXT: br i1 [[TMP1]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF9:![0-9]+]], !nosanitize [[META8]] +// RECOVER-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load(ptr [[VTABLE]], i32 0, metadata !"_ZTS2S1"), !nosanitize [[META8:![0-9]+]] +// RECOVER-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1, !nosanitize [[META8]] +// RECOVER-NEXT: [[TMP3:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META8]] +// RECOVER-NEXT: br i1 [[TMP2]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF9:![0-9]+]], !nosanitize [[META8]] // RECOVER: [[HANDLER_CFI_CHECK_FAIL]]: -// RECOVER-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META8]] -// RECOVER-NEXT: [[TMP4:%.*]] = zext i1 [[TMP2]] to i64, !nosanitize [[META8]] -// RECOVER-NEXT: call void @__ubsan_handle_cfi_check_fail(ptr @anon.00e38160576ab76122d2f8d139d2e390.1, i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR3:[0-9]+]], !nosanitize [[META8]] +// RECOVER-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META8]] +// RECOVER-NEXT: [[TMP5:%.*]] = zext i1 [[TMP3]] to i64, !nosanitize [[META8]] +// RECOVER-NEXT: call void @__ubsan_handle_cfi_check_fail(ptr @anon.00e38160576ab76122d2f8d139d2e390.1, i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR4:[0-9]+]], !nosanitize [[META8]] // RECOVER-NEXT: br label %[[CONT]], !nosanitize [[META8]] // RECOVER: [[CONT]]: -// RECOVER-NEXT: [[VFN:%.*]] = getelementptr inbounds ptr, ptr [[VTABLE]], i64 0 -// RECOVER-NEXT: [[TMP5:%.*]] = load ptr, ptr [[VFN]], align 8 -// RECOVER-NEXT: call void [[TMP5]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) +// RECOVER-NEXT: [[TMP6:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 0, !nosanitize [[META8]] +// RECOVER-NEXT: call void [[TMP6]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) // RECOVER-NEXT: ret void // // ABORT_MIN-LABEL: define hidden void @_Z3s1fP2S1( @@ -85,15 +85,15 @@ struct S1 { // ABORT_MIN-NEXT: store ptr [[S1]], ptr [[S1_ADDR]], align 8 // ABORT_MIN-NEXT: [[TMP0:%.*]] = load ptr, ptr [[S1_ADDR]], align 8 // ABORT_MIN-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 -// ABORT_MIN-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"_ZTS2S1"), !nosanitize [[META5:![0-9]+]] -// ABORT_MIN-NEXT: br i1 [[TMP1]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF6:![0-9]+]], !nosanitize [[META5]] +// ABORT_MIN-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load(ptr [[VTABLE]], i32 0, metadata !"_ZTS2S1"), !nosanitize [[META5:![0-9]+]] +// ABORT_MIN-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1, !nosanitize [[META5]] +// ABORT_MIN-NEXT: br i1 [[TMP2]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF6:![0-9]+]], !nosanitize [[META5]] // ABORT_MIN: [[HANDLER_CFI_CHECK_FAIL]]: // ABORT_MIN-NEXT: call void @__ubsan_handle_cfi_check_fail_minimal_abort() #[[ATTR3:[0-9]+]], !nosanitize [[META5]] // ABORT_MIN-NEXT: unreachable, !nosanitize [[META5]] // ABORT_MIN: [[CONT]]: -// ABORT_MIN-NEXT: [[VFN:%.*]] = getelementptr inbounds ptr, ptr [[VTABLE]], i64 0 -// ABORT_MIN-NEXT: [[TMP2:%.*]] = load ptr, ptr [[VFN]], align 8 -// ABORT_MIN-NEXT: call void [[TMP2]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) +// ABORT_MIN-NEXT: [[TMP3:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 0, !nosanitize [[META5]] +// ABORT_MIN-NEXT: call void [[TMP3]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) // ABORT_MIN-NEXT: ret void // // RECOVER_MIN-LABEL: define hidden void @_Z3s1fP2S1( @@ -103,15 +103,15 @@ struct S1 { // RECOVER_MIN-NEXT: store ptr [[S1]], ptr [[S1_ADDR]], align 8 // RECOVER_MIN-NEXT: [[TMP0:%.*]] = load ptr, ptr [[S1_ADDR]], align 8 // RECOVER_MIN-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 -// RECOVER_MIN-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"_ZTS2S1"), !nosanitize [[META5:![0-9]+]] -// RECOVER_MIN-NEXT: br i1 [[TMP1]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF6:![0-9]+]], !nosanitize [[META5]] +// RECOVER_MIN-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load(ptr [[VTABLE]], i32 0, metadata !"_ZTS2S1"), !nosanitize [[META5:![0-9]+]] +// RECOVER_MIN-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1, !nosanitize [[META5]] +// RECOVER_MIN-NEXT: br i1 [[TMP2]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF6:![0-9]+]], !nosanitize [[META5]] // RECOVER_MIN: [[HANDLER_CFI_CHECK_FAIL]]: // RECOVER_MIN-NEXT: call void @__ubsan_handle_cfi_check_fail_minimal() #[[ATTR3:[0-9]+]], !nosanitize [[META5]] // RECOVER_MIN-NEXT: br label %[[CONT]], !nosanitize [[META5]] // RECOVER_MIN: [[CONT]]: -// RECOVER_MIN-NEXT: [[VFN:%.*]] = getelementptr inbounds ptr, ptr [[VTABLE]], i64 0 -// RECOVER_MIN-NEXT: [[TMP2:%.*]] = load ptr, ptr [[VFN]], align 8 -// RECOVER_MIN-NEXT: call void [[TMP2]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) +// RECOVER_MIN-NEXT: [[TMP3:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 0, !nosanitize [[META5]] +// RECOVER_MIN-NEXT: call void [[TMP3]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) // RECOVER_MIN-NEXT: ret void // // PRESERVE_MIN-LABEL: define hidden void @_Z3s1fP2S1( @@ -121,15 +121,15 @@ struct S1 { // PRESERVE_MIN-NEXT: store ptr [[S1]], ptr [[S1_ADDR]], align 8 // PRESERVE_MIN-NEXT: [[TMP0:%.*]] = load ptr, ptr [[S1_ADDR]], align 8 // PRESERVE_MIN-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 -// PRESERVE_MIN-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"_ZTS2S1"), !nosanitize [[META5:![0-9]+]] -// PRESERVE_MIN-NEXT: br i1 [[TMP1]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF6:![0-9]+]], !nosanitize [[META5]] +// PRESERVE_MIN-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load(ptr [[VTABLE]], i32 0, metadata !"_ZTS2S1"), !nosanitize [[META5:![0-9]+]] +// PRESERVE_MIN-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1, !nosanitize [[META5]] +// PRESERVE_MIN-NEXT: br i1 [[TMP2]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF6:![0-9]+]], !nosanitize [[META5]] // PRESERVE_MIN: [[HANDLER_CFI_CHECK_FAIL]]: // PRESERVE_MIN-NEXT: call preserve_allcc void @__ubsan_handle_cfi_check_fail_minimal_preserve() #[[ATTR3:[0-9]+]], !nosanitize [[META5]] // PRESERVE_MIN-NEXT: br label %[[CONT]], !nosanitize [[META5]] // PRESERVE_MIN: [[CONT]]: -// PRESERVE_MIN-NEXT: [[VFN:%.*]] = getelementptr inbounds ptr, ptr [[VTABLE]], i64 0 -// PRESERVE_MIN-NEXT: [[TMP2:%.*]] = load ptr, ptr [[VFN]], align 8 -// PRESERVE_MIN-NEXT: call void [[TMP2]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) +// PRESERVE_MIN-NEXT: [[TMP3:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 0, !nosanitize [[META5]] +// PRESERVE_MIN-NEXT: call void [[TMP3]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) // PRESERVE_MIN-NEXT: ret void // void s1f(S1 *s1) { diff --git a/clang/test/CodeGenCXX/cfi-vcall-type-checked-load.cpp b/clang/test/CodeGenCXX/cfi-vcall-type-checked-load.cpp index 9e5dabe4fbc9e8..f1d58e2d564967 100644 --- a/clang/test/CodeGenCXX/cfi-vcall-type-checked-load.cpp +++ b/clang/test/CodeGenCXX/cfi-vcall-type-checked-load.cpp @@ -39,15 +39,15 @@ struct DerivedSameLayoutFromPublic : Public {}; // XDSO-NEXT: store ptr [[P]], ptr [[P_ADDR]], align 8 // XDSO-NEXT: [[TMP0:%.*]] = load ptr, ptr [[P_ADDR]], align 8 // XDSO-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 -// XDSO-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"_ZTS6Hidden"), !nosanitize [[META16:![0-9]+]] -// XDSO-NEXT: br i1 [[TMP1]], label %[[CFI_CONT:.*]], label %[[CFI_SLOWPATH:.*]], !prof [[PROF17:![0-9]+]], !nosanitize [[META16]] +// XDSO-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load(ptr [[VTABLE]], i32 8, metadata !"_ZTS6Hidden"), !nosanitize [[META16:![0-9]+]] +// XDSO-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1, !nosanitize [[META16]] +// XDSO-NEXT: br i1 [[TMP2]], label %[[CFI_CONT:.*]], label %[[CFI_SLOWPATH:.*]], !prof [[PROF17:![0-9]+]], !nosanitize [[META16]] // XDSO: [[CFI_SLOWPATH]]: -// XDSO-NEXT: call void @__cfi_slowpath_diag(i64 2113178649093603051, ptr [[VTABLE]], ptr @anon.93ff3a23323713a2f8f8fa200a6533af.1) #[[ATTR7:[0-9]+]], !nosanitize [[META16]] +// XDSO-NEXT: call void @__cfi_slowpath_diag(i64 2113178649093603051, ptr [[VTABLE]], ptr @anon.93ff3a23323713a2f8f8fa200a6533af.1) #[[ATTR8:[0-9]+]], !nosanitize [[META16]] // XDSO-NEXT: br label %[[CFI_CONT]], !nosanitize [[META16]] // XDSO: [[CFI_CONT]]: -// XDSO-NEXT: [[VFN:%.*]] = getelementptr inbounds ptr, ptr [[VTABLE]], i64 1 -// XDSO-NEXT: [[TMP2:%.*]] = load ptr, ptr [[VFN]], align 8 -// XDSO-NEXT: call void [[TMP2]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) +// XDSO-NEXT: [[TMP3:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 0, !nosanitize [[META16]] +// XDSO-NEXT: call void [[TMP3]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) // XDSO-NEXT: ret void // // XDSOT-LABEL: define hidden void @call_hidden( @@ -114,18 +114,18 @@ struct DerivedSameLayoutFromPublic : Public {}; // MS-NEXT: store ptr [[P]], ptr [[P_ADDR]], align 8 // MS-NEXT: [[TMP0:%.*]] = load ptr, ptr [[P_ADDR]], align 8 // MS-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 -// MS-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"?AUHidden@@"), !nosanitize [[META13:![0-9]+]] -// MS-NEXT: [[TMP2:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META13]] -// MS-NEXT: br i1 [[TMP1]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF14:![0-9]+]], !nosanitize [[META13]] +// MS-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load(ptr [[VTABLE]], i32 8, metadata !"?AUHidden@@"), !nosanitize [[META13:![0-9]+]] +// MS-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1, !nosanitize [[META13]] +// MS-NEXT: [[TMP3:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META13]] +// MS-NEXT: br i1 [[TMP2]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF14:![0-9]+]], !nosanitize [[META13]] // MS: [[HANDLER_CFI_CHECK_FAIL]]: -// MS-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META13]] -// MS-NEXT: [[TMP4:%.*]] = zext i1 [[TMP2]] to i64, !nosanitize [[META13]] -// MS-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.d9643cf6d96f91e01d1bcbfe408e7c5c.1, i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR4:[0-9]+]], !nosanitize [[META13]] +// MS-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META13]] +// MS-NEXT: [[TMP5:%.*]] = zext i1 [[TMP3]] to i64, !nosanitize [[META13]] +// MS-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.d9643cf6d96f91e01d1bcbfe408e7c5c.1, i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR5:[0-9]+]], !nosanitize [[META13]] // MS-NEXT: unreachable, !nosanitize [[META13]] // MS: [[CONT]]: -// MS-NEXT: [[VFN:%.*]] = getelementptr inbounds ptr, ptr [[VTABLE]], i64 1 -// MS-NEXT: [[TMP5:%.*]] = load ptr, ptr [[VFN]], align 8 -// MS-NEXT: call void [[TMP5]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) +// MS-NEXT: [[TMP6:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 0, !nosanitize [[META13]] +// MS-NEXT: call void [[TMP6]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) // MS-NEXT: ret void // // REL-LABEL: define hidden void @call_hidden( @@ -135,17 +135,18 @@ struct DerivedSameLayoutFromPublic : Public {}; // REL-NEXT: store ptr [[P]], ptr [[P_ADDR]], align 8 // REL-NEXT: [[TMP0:%.*]] = load ptr, ptr [[P_ADDR]], align 8 // REL-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 -// REL-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"_ZTS6Hidden"), !nosanitize [[META11:![0-9]+]] -// REL-NEXT: [[TMP2:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META11]] -// REL-NEXT: br i1 [[TMP1]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF12:![0-9]+]], !nosanitize [[META11]] +// REL-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load.relative(ptr [[VTABLE]], i32 4, metadata !"_ZTS6Hidden"), !nosanitize [[META11:![0-9]+]] +// REL-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1, !nosanitize [[META11]] +// REL-NEXT: [[TMP3:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META11]] +// REL-NEXT: br i1 [[TMP2]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF12:![0-9]+]], !nosanitize [[META11]] // REL: [[HANDLER_CFI_CHECK_FAIL]]: -// REL-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META11]] -// REL-NEXT: [[TMP4:%.*]] = zext i1 [[TMP2]] to i64, !nosanitize [[META11]] -// REL-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.d9643cf6d96f91e01d1bcbfe408e7c5c.1, i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR5:[0-9]+]], !nosanitize [[META11]] +// REL-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META11]] +// REL-NEXT: [[TMP5:%.*]] = zext i1 [[TMP3]] to i64, !nosanitize [[META11]] +// REL-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.d9643cf6d96f91e01d1bcbfe408e7c5c.1, i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR6:[0-9]+]], !nosanitize [[META11]] // REL-NEXT: unreachable, !nosanitize [[META11]] // REL: [[CONT]]: -// REL-NEXT: [[TMP5:%.*]] = call ptr @llvm.load.relative.i32(ptr [[VTABLE]], i32 4) -// REL-NEXT: call void [[TMP5]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) +// REL-NEXT: [[TMP6:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 0, !nosanitize [[META11]] +// REL-NEXT: call void [[TMP6]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) // REL-NEXT: ret void // // SPEC-LABEL: define hidden void @call_hidden( @@ -188,18 +189,18 @@ struct DerivedSameLayoutFromPublic : Public {}; // STRICT-NEXT: store ptr [[P]], ptr [[P_ADDR]], align 8 // STRICT-NEXT: [[TMP0:%.*]] = load ptr, ptr [[P_ADDR]], align 8 // STRICT-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 -// STRICT-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"_ZTS6Hidden"), !nosanitize [[META14:![0-9]+]] -// STRICT-NEXT: [[TMP2:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META14]] -// STRICT-NEXT: br i1 [[TMP1]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF15:![0-9]+]], !nosanitize [[META14]] +// STRICT-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load(ptr [[VTABLE]], i32 8, metadata !"_ZTS6Hidden"), !nosanitize [[META14:![0-9]+]] +// STRICT-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1, !nosanitize [[META14]] +// STRICT-NEXT: [[TMP3:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META14]] +// STRICT-NEXT: br i1 [[TMP2]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF15:![0-9]+]], !nosanitize [[META14]] // STRICT: [[HANDLER_CFI_CHECK_FAIL]]: -// STRICT-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META14]] -// STRICT-NEXT: [[TMP4:%.*]] = zext i1 [[TMP2]] to i64, !nosanitize [[META14]] -// STRICT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.d9643cf6d96f91e01d1bcbfe408e7c5c.1, i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR4:[0-9]+]], !nosanitize [[META14]] +// STRICT-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META14]] +// STRICT-NEXT: [[TMP5:%.*]] = zext i1 [[TMP3]] to i64, !nosanitize [[META14]] +// STRICT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.d9643cf6d96f91e01d1bcbfe408e7c5c.1, i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR5:[0-9]+]], !nosanitize [[META14]] // STRICT-NEXT: unreachable, !nosanitize [[META14]] // STRICT: [[CONT]]: -// STRICT-NEXT: [[VFN:%.*]] = getelementptr inbounds ptr, ptr [[VTABLE]], i64 1 -// STRICT-NEXT: [[TMP5:%.*]] = load ptr, ptr [[VFN]], align 8 -// STRICT-NEXT: call void [[TMP5]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) +// STRICT-NEXT: [[TMP6:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 0, !nosanitize [[META14]] +// STRICT-NEXT: call void [[TMP6]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) // STRICT-NEXT: ret void // extern "C" void call_hidden(Hidden *p) { @@ -216,7 +217,7 @@ extern "C" void call_hidden(Hidden *p) { // XDSO-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"_ZTS6Public"), !nosanitize [[META16]] // XDSO-NEXT: br i1 [[TMP1]], label %[[CFI_CONT:.*]], label %[[CFI_SLOWPATH:.*]], !prof [[PROF17]], !nosanitize [[META16]] // XDSO: [[CFI_SLOWPATH]]: -// XDSO-NEXT: call void @__cfi_slowpath_diag(i64 7659278028533726273, ptr [[VTABLE]], ptr @anon.93ff3a23323713a2f8f8fa200a6533af.3) #[[ATTR7]], !nosanitize [[META16]] +// XDSO-NEXT: call void @__cfi_slowpath_diag(i64 7659278028533726273, ptr [[VTABLE]], ptr @anon.93ff3a23323713a2f8f8fa200a6533af.3) #[[ATTR8]], !nosanitize [[META16]] // XDSO-NEXT: br label %[[CFI_CONT]], !nosanitize [[META16]] // XDSO: [[CFI_CONT]]: // XDSO-NEXT: [[VFN:%.*]] = getelementptr inbounds ptr, ptr [[VTABLE]], i64 0 @@ -468,15 +469,15 @@ extern "C" __attribute__((no_sanitize("cfi-vcall"))) void call_no_sanitize(Hidde // XDSO-NEXT: br i1 [[ISNULL]], label %[[DELETE_END:.*]], label %[[DELETE_NOTNULL:.*]] // XDSO: [[DELETE_NOTNULL]]: // XDSO-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 -// XDSO-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"_ZTS6Hidden"), !nosanitize [[META16]] -// XDSO-NEXT: br i1 [[TMP1]], label %[[CFI_CONT:.*]], label %[[CFI_SLOWPATH:.*]], !prof [[PROF17]], !nosanitize [[META16]] +// XDSO-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load(ptr [[VTABLE]], i32 24, metadata !"_ZTS6Hidden"), !nosanitize [[META16]] +// XDSO-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1, !nosanitize [[META16]] +// XDSO-NEXT: br i1 [[TMP2]], label %[[CFI_CONT:.*]], label %[[CFI_SLOWPATH:.*]], !prof [[PROF17]], !nosanitize [[META16]] // XDSO: [[CFI_SLOWPATH]]: -// XDSO-NEXT: call void @__cfi_slowpath_diag(i64 2113178649093603051, ptr [[VTABLE]], ptr @anon.93ff3a23323713a2f8f8fa200a6533af.4) #[[ATTR7]], !nosanitize [[META16]] +// XDSO-NEXT: call void @__cfi_slowpath_diag(i64 2113178649093603051, ptr [[VTABLE]], ptr @anon.93ff3a23323713a2f8f8fa200a6533af.4) #[[ATTR8]], !nosanitize [[META16]] // XDSO-NEXT: br label %[[CFI_CONT]], !nosanitize [[META16]] // XDSO: [[CFI_CONT]]: -// XDSO-NEXT: [[VFN:%.*]] = getelementptr inbounds ptr, ptr [[VTABLE]], i64 3 -// XDSO-NEXT: [[TMP2:%.*]] = load ptr, ptr [[VFN]], align 8 -// XDSO-NEXT: call void [[TMP2]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) #[[ATTR7]] +// XDSO-NEXT: [[TMP3:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 0, !nosanitize [[META16]] +// XDSO-NEXT: call void [[TMP3]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) #[[ATTR8]] // XDSO-NEXT: br label %[[DELETE_END]] // XDSO: [[DELETE_END]]: // XDSO-NEXT: ret void @@ -563,18 +564,18 @@ extern "C" __attribute__((no_sanitize("cfi-vcall"))) void call_no_sanitize(Hidde // MS-NEXT: br i1 [[ISNULL]], label %[[DELETE_END:.*]], label %[[DELETE_NOTNULL:.*]] // MS: [[DELETE_NOTNULL]]: // MS-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 -// MS-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"?AUHidden@@"), !nosanitize [[META13]] -// MS-NEXT: [[TMP2:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META13]] -// MS-NEXT: br i1 [[TMP1]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF14]], !nosanitize [[META13]] +// MS-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load(ptr [[VTABLE]], i32 16, metadata !"?AUHidden@@"), !nosanitize [[META13]] +// MS-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1, !nosanitize [[META13]] +// MS-NEXT: [[TMP3:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META13]] +// MS-NEXT: br i1 [[TMP2]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF14]], !nosanitize [[META13]] // MS: [[HANDLER_CFI_CHECK_FAIL]]: -// MS-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META13]] -// MS-NEXT: [[TMP4:%.*]] = zext i1 [[TMP2]] to i64, !nosanitize [[META13]] -// MS-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.d9643cf6d96f91e01d1bcbfe408e7c5c.2, i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR4]], !nosanitize [[META13]] +// MS-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META13]] +// MS-NEXT: [[TMP5:%.*]] = zext i1 [[TMP3]] to i64, !nosanitize [[META13]] +// MS-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.d9643cf6d96f91e01d1bcbfe408e7c5c.2, i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR5]], !nosanitize [[META13]] // MS-NEXT: unreachable, !nosanitize [[META13]] // MS: [[CONT]]: -// MS-NEXT: [[VFN:%.*]] = getelementptr inbounds ptr, ptr [[VTABLE]], i64 2 -// MS-NEXT: [[TMP5:%.*]] = load ptr, ptr [[VFN]], align 8 -// MS-NEXT: [[CALL:%.*]] = call noundef ptr [[TMP5]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]], i32 noundef 1) #[[ATTR5:[0-9]+]] +// MS-NEXT: [[TMP6:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 0, !nosanitize [[META13]] +// MS-NEXT: [[CALL:%.*]] = call noundef ptr [[TMP6]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]], i32 noundef 1) #[[ATTR6:[0-9]+]] // MS-NEXT: br label %[[DELETE_END]] // MS: [[DELETE_END]]: // MS-NEXT: ret void @@ -589,17 +590,18 @@ extern "C" __attribute__((no_sanitize("cfi-vcall"))) void call_no_sanitize(Hidde // REL-NEXT: br i1 [[ISNULL]], label %[[DELETE_END:.*]], label %[[DELETE_NOTNULL:.*]] // REL: [[DELETE_NOTNULL]]: // REL-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 -// REL-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"_ZTS6Hidden"), !nosanitize [[META11]] -// REL-NEXT: [[TMP2:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META11]] -// REL-NEXT: br i1 [[TMP1]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF12]], !nosanitize [[META11]] +// REL-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load.relative(ptr [[VTABLE]], i32 12, metadata !"_ZTS6Hidden"), !nosanitize [[META11]] +// REL-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1, !nosanitize [[META11]] +// REL-NEXT: [[TMP3:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META11]] +// REL-NEXT: br i1 [[TMP2]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF12]], !nosanitize [[META11]] // REL: [[HANDLER_CFI_CHECK_FAIL]]: -// REL-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META11]] -// REL-NEXT: [[TMP4:%.*]] = zext i1 [[TMP2]] to i64, !nosanitize [[META11]] -// REL-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.d9643cf6d96f91e01d1bcbfe408e7c5c.2, i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR5]], !nosanitize [[META11]] +// REL-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META11]] +// REL-NEXT: [[TMP5:%.*]] = zext i1 [[TMP3]] to i64, !nosanitize [[META11]] +// REL-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.d9643cf6d96f91e01d1bcbfe408e7c5c.2, i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR6]], !nosanitize [[META11]] // REL-NEXT: unreachable, !nosanitize [[META11]] // REL: [[CONT]]: -// REL-NEXT: [[TMP5:%.*]] = call ptr @llvm.load.relative.i32(ptr [[VTABLE]], i32 12) -// REL-NEXT: call void [[TMP5]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) #[[ATTR6:[0-9]+]] +// REL-NEXT: [[TMP6:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 0, !nosanitize [[META11]] +// REL-NEXT: call void [[TMP6]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) #[[ATTR7:[0-9]+]] // REL-NEXT: br label %[[DELETE_END]] // REL: [[DELETE_END]]: // REL-NEXT: ret void @@ -657,18 +659,18 @@ extern "C" __attribute__((no_sanitize("cfi-vcall"))) void call_no_sanitize(Hidde // STRICT-NEXT: br i1 [[ISNULL]], label %[[DELETE_END:.*]], label %[[DELETE_NOTNULL:.*]] // STRICT: [[DELETE_NOTNULL]]: // STRICT-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 -// STRICT-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"_ZTS17DerivedSameLayout"), !nosanitize [[META14]] -// STRICT-NEXT: [[TMP2:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META14]] -// STRICT-NEXT: br i1 [[TMP1]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF15]], !nosanitize [[META14]] +// STRICT-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load(ptr [[VTABLE]], i32 24, metadata !"_ZTS17DerivedSameLayout"), !nosanitize [[META14]] +// STRICT-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1, !nosanitize [[META14]] +// STRICT-NEXT: [[TMP3:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META14]] +// STRICT-NEXT: br i1 [[TMP2]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF15]], !nosanitize [[META14]] // STRICT: [[HANDLER_CFI_CHECK_FAIL]]: -// STRICT-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META14]] -// STRICT-NEXT: [[TMP4:%.*]] = zext i1 [[TMP2]] to i64, !nosanitize [[META14]] -// STRICT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.d9643cf6d96f91e01d1bcbfe408e7c5c.3, i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR4]], !nosanitize [[META14]] +// STRICT-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META14]] +// STRICT-NEXT: [[TMP5:%.*]] = zext i1 [[TMP3]] to i64, !nosanitize [[META14]] +// STRICT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.d9643cf6d96f91e01d1bcbfe408e7c5c.3, i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR5]], !nosanitize [[META14]] // STRICT-NEXT: unreachable, !nosanitize [[META14]] // STRICT: [[CONT]]: -// STRICT-NEXT: [[VFN:%.*]] = getelementptr inbounds ptr, ptr [[VTABLE]], i64 3 -// STRICT-NEXT: [[TMP5:%.*]] = load ptr, ptr [[VFN]], align 8 -// STRICT-NEXT: call void [[TMP5]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) #[[ATTR5:[0-9]+]] +// STRICT-NEXT: [[TMP6:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 0, !nosanitize [[META14]] +// STRICT-NEXT: call void [[TMP6]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) #[[ATTR6:[0-9]+]] // STRICT-NEXT: br label %[[DELETE_END]] // STRICT: [[DELETE_END]]: // STRICT-NEXT: ret void @@ -684,15 +686,15 @@ extern "C" void call_derived_same_layout(DerivedSameLayout *p) { // XDSO-NEXT: store ptr [[P]], ptr [[P_ADDR]], align 8 // XDSO-NEXT: [[TMP0:%.*]] = load ptr, ptr [[P_ADDR]], align 8 // XDSO-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 -// XDSO-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"_ZTS17DerivedFromPublic"), !nosanitize [[META16]] -// XDSO-NEXT: br i1 [[TMP1]], label %[[CFI_CONT:.*]], label %[[CFI_SLOWPATH:.*]], !prof [[PROF17]], !nosanitize [[META16]] +// XDSO-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load(ptr [[VTABLE]], i32 32, metadata !"_ZTS17DerivedFromPublic"), !nosanitize [[META16]] +// XDSO-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1, !nosanitize [[META16]] +// XDSO-NEXT: br i1 [[TMP2]], label %[[CFI_CONT:.*]], label %[[CFI_SLOWPATH:.*]], !prof [[PROF17]], !nosanitize [[META16]] // XDSO: [[CFI_SLOWPATH]]: -// XDSO-NEXT: call void @__cfi_slowpath_diag(i64 -6426894850856698049, ptr [[VTABLE]], ptr @anon.93ff3a23323713a2f8f8fa200a6533af.6) #[[ATTR7]], !nosanitize [[META16]] +// XDSO-NEXT: call void @__cfi_slowpath_diag(i64 -6426894850856698049, ptr [[VTABLE]], ptr @anon.93ff3a23323713a2f8f8fa200a6533af.6) #[[ATTR8]], !nosanitize [[META16]] // XDSO-NEXT: br label %[[CFI_CONT]], !nosanitize [[META16]] // XDSO: [[CFI_CONT]]: -// XDSO-NEXT: [[VFN:%.*]] = getelementptr inbounds ptr, ptr [[VTABLE]], i64 4 -// XDSO-NEXT: [[TMP2:%.*]] = load ptr, ptr [[VFN]], align 8 -// XDSO-NEXT: call void [[TMP2]](ptr noundef nonnull align 8 dereferenceable(16) [[TMP0]]) +// XDSO-NEXT: [[TMP3:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 0, !nosanitize [[META16]] +// XDSO-NEXT: call void [[TMP3]](ptr noundef nonnull align 8 dereferenceable(16) [[TMP0]]) // XDSO-NEXT: ret void // // XDSOT-LABEL: define hidden void @call_derived_public( @@ -773,17 +775,18 @@ extern "C" void call_derived_same_layout(DerivedSameLayout *p) { // REL-NEXT: store ptr [[P]], ptr [[P_ADDR]], align 8 // REL-NEXT: [[TMP0:%.*]] = load ptr, ptr [[P_ADDR]], align 8 // REL-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 -// REL-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"_ZTS17DerivedFromPublic"), !nosanitize [[META11]] -// REL-NEXT: [[TMP2:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META11]] -// REL-NEXT: br i1 [[TMP1]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF12]], !nosanitize [[META11]] +// REL-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load.relative(ptr [[VTABLE]], i32 16, metadata !"_ZTS17DerivedFromPublic"), !nosanitize [[META11]] +// REL-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1, !nosanitize [[META11]] +// REL-NEXT: [[TMP3:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META11]] +// REL-NEXT: br i1 [[TMP2]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF12]], !nosanitize [[META11]] // REL: [[HANDLER_CFI_CHECK_FAIL]]: -// REL-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META11]] -// REL-NEXT: [[TMP4:%.*]] = zext i1 [[TMP2]] to i64, !nosanitize [[META11]] -// REL-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.d9643cf6d96f91e01d1bcbfe408e7c5c.4, i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR5]], !nosanitize [[META11]] +// REL-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META11]] +// REL-NEXT: [[TMP5:%.*]] = zext i1 [[TMP3]] to i64, !nosanitize [[META11]] +// REL-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.d9643cf6d96f91e01d1bcbfe408e7c5c.4, i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR6]], !nosanitize [[META11]] // REL-NEXT: unreachable, !nosanitize [[META11]] // REL: [[CONT]]: -// REL-NEXT: [[TMP5:%.*]] = call ptr @llvm.load.relative.i32(ptr [[VTABLE]], i32 16) -// REL-NEXT: call void [[TMP5]](ptr noundef nonnull align 8 dereferenceable(16) [[TMP0]]) +// REL-NEXT: [[TMP6:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 0, !nosanitize [[META11]] +// REL-NEXT: call void [[TMP6]](ptr noundef nonnull align 8 dereferenceable(16) [[TMP0]]) // REL-NEXT: ret void // // SPEC-LABEL: define hidden void @call_derived_public( @@ -826,18 +829,18 @@ extern "C" void call_derived_same_layout(DerivedSameLayout *p) { // STRICT-NEXT: store ptr [[P]], ptr [[P_ADDR]], align 8 // STRICT-NEXT: [[TMP0:%.*]] = load ptr, ptr [[P_ADDR]], align 8 // STRICT-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 -// STRICT-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"_ZTS17DerivedFromPublic"), !nosanitize [[META14]] -// STRICT-NEXT: [[TMP2:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META14]] -// STRICT-NEXT: br i1 [[TMP1]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF15]], !nosanitize [[META14]] +// STRICT-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load(ptr [[VTABLE]], i32 32, metadata !"_ZTS17DerivedFromPublic"), !nosanitize [[META14]] +// STRICT-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1, !nosanitize [[META14]] +// STRICT-NEXT: [[TMP3:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META14]] +// STRICT-NEXT: br i1 [[TMP2]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF15]], !nosanitize [[META14]] // STRICT: [[HANDLER_CFI_CHECK_FAIL]]: -// STRICT-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META14]] -// STRICT-NEXT: [[TMP4:%.*]] = zext i1 [[TMP2]] to i64, !nosanitize [[META14]] -// STRICT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.d9643cf6d96f91e01d1bcbfe408e7c5c.5, i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR4]], !nosanitize [[META14]] +// STRICT-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META14]] +// STRICT-NEXT: [[TMP5:%.*]] = zext i1 [[TMP3]] to i64, !nosanitize [[META14]] +// STRICT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.d9643cf6d96f91e01d1bcbfe408e7c5c.5, i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR5]], !nosanitize [[META14]] // STRICT-NEXT: unreachable, !nosanitize [[META14]] // STRICT: [[CONT]]: -// STRICT-NEXT: [[VFN:%.*]] = getelementptr inbounds ptr, ptr [[VTABLE]], i64 4 -// STRICT-NEXT: [[TMP5:%.*]] = load ptr, ptr [[VFN]], align 8 -// STRICT-NEXT: call void [[TMP5]](ptr noundef nonnull align 8 dereferenceable(16) [[TMP0]]) +// STRICT-NEXT: [[TMP6:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 0, !nosanitize [[META14]] +// STRICT-NEXT: call void [[TMP6]](ptr noundef nonnull align 8 dereferenceable(16) [[TMP0]]) // STRICT-NEXT: ret void // extern "C" void call_derived_public(DerivedFromPublic *p) { @@ -857,12 +860,12 @@ extern "C" void call_derived_public(DerivedFromPublic *p) { // XDSO-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"_ZTS6Public"), !nosanitize [[META16]] // XDSO-NEXT: br i1 [[TMP1]], label %[[CFI_CONT:.*]], label %[[CFI_SLOWPATH:.*]], !prof [[PROF17]], !nosanitize [[META16]] // XDSO: [[CFI_SLOWPATH]]: -// XDSO-NEXT: call void @__cfi_slowpath_diag(i64 7659278028533726273, ptr [[VTABLE]], ptr @anon.93ff3a23323713a2f8f8fa200a6533af.7) #[[ATTR7]], !nosanitize [[META16]] +// XDSO-NEXT: call void @__cfi_slowpath_diag(i64 7659278028533726273, ptr [[VTABLE]], ptr @anon.93ff3a23323713a2f8f8fa200a6533af.7) #[[ATTR8]], !nosanitize [[META16]] // XDSO-NEXT: br label %[[CFI_CONT]], !nosanitize [[META16]] // XDSO: [[CFI_CONT]]: // XDSO-NEXT: [[VFN:%.*]] = getelementptr inbounds ptr, ptr [[VTABLE]], i64 3 // XDSO-NEXT: [[TMP2:%.*]] = load ptr, ptr [[VFN]], align 8 -// XDSO-NEXT: call void [[TMP2]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) #[[ATTR7]] +// XDSO-NEXT: call void [[TMP2]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) #[[ATTR8]] // XDSO-NEXT: br label %[[DELETE_END]] // XDSO: [[DELETE_END]]: // XDSO-NEXT: ret void @@ -942,7 +945,7 @@ extern "C" void call_derived_public(DerivedFromPublic *p) { // MS-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 // MS-NEXT: [[VFN:%.*]] = getelementptr inbounds ptr, ptr [[VTABLE]], i64 2 // MS-NEXT: [[TMP1:%.*]] = load ptr, ptr [[VFN]], align 8 -// MS-NEXT: [[CALL:%.*]] = call noundef ptr [[TMP1]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]], i32 noundef 1) #[[ATTR5]] +// MS-NEXT: [[CALL:%.*]] = call noundef ptr [[TMP1]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]], i32 noundef 1) #[[ATTR6]] // MS-NEXT: br label %[[DELETE_END]] // MS: [[DELETE_END]]: // MS-NEXT: ret void @@ -958,7 +961,7 @@ extern "C" void call_derived_public(DerivedFromPublic *p) { // REL: [[DELETE_NOTNULL]]: // REL-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 // REL-NEXT: [[TMP1:%.*]] = call ptr @llvm.load.relative.i32(ptr [[VTABLE]], i32 12) -// REL-NEXT: call void [[TMP1]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) #[[ATTR6]] +// REL-NEXT: call void [[TMP1]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) #[[ATTR7]] // REL-NEXT: br label %[[DELETE_END]] // REL: [[DELETE_END]]: // REL-NEXT: ret void @@ -1007,18 +1010,18 @@ extern "C" void call_derived_public(DerivedFromPublic *p) { // STRICT-NEXT: br i1 [[ISNULL]], label %[[DELETE_END:.*]], label %[[DELETE_NOTNULL:.*]] // STRICT: [[DELETE_NOTNULL]]: // STRICT-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 -// STRICT-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"_ZTS27DerivedSameLayoutFromPublic"), !nosanitize [[META14]] -// STRICT-NEXT: [[TMP2:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META14]] -// STRICT-NEXT: br i1 [[TMP1]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF15]], !nosanitize [[META14]] +// STRICT-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load(ptr [[VTABLE]], i32 24, metadata !"_ZTS27DerivedSameLayoutFromPublic"), !nosanitize [[META14]] +// STRICT-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1, !nosanitize [[META14]] +// STRICT-NEXT: [[TMP3:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META14]] +// STRICT-NEXT: br i1 [[TMP2]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF15]], !nosanitize [[META14]] // STRICT: [[HANDLER_CFI_CHECK_FAIL]]: -// STRICT-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META14]] -// STRICT-NEXT: [[TMP4:%.*]] = zext i1 [[TMP2]] to i64, !nosanitize [[META14]] -// STRICT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.d9643cf6d96f91e01d1bcbfe408e7c5c.7, i64 [[TMP3]], i64 [[TMP4]]) #[[ATTR4]], !nosanitize [[META14]] +// STRICT-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64, !nosanitize [[META14]] +// STRICT-NEXT: [[TMP5:%.*]] = zext i1 [[TMP3]] to i64, !nosanitize [[META14]] +// STRICT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(ptr @anon.d9643cf6d96f91e01d1bcbfe408e7c5c.7, i64 [[TMP4]], i64 [[TMP5]]) #[[ATTR5]], !nosanitize [[META14]] // STRICT-NEXT: unreachable, !nosanitize [[META14]] // STRICT: [[CONT]]: -// STRICT-NEXT: [[VFN:%.*]] = getelementptr inbounds ptr, ptr [[VTABLE]], i64 3 -// STRICT-NEXT: [[TMP5:%.*]] = load ptr, ptr [[VFN]], align 8 -// STRICT-NEXT: call void [[TMP5]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) #[[ATTR5]] +// STRICT-NEXT: [[TMP6:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 0, !nosanitize [[META14]] +// STRICT-NEXT: call void [[TMP6]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) #[[ATTR6]] // STRICT-NEXT: br label %[[DELETE_END]] // STRICT: [[DELETE_END]]: // STRICT-NEXT: ret void diff --git a/compiler-rt/test/cfi/anon-namespace.cpp b/compiler-rt/test/cfi/anon-namespace.cpp index b352a3e7e5029b..ebf1af21d324b3 100644 --- a/compiler-rt/test/cfi/anon-namespace.cpp +++ b/compiler-rt/test/cfi/anon-namespace.cpp @@ -23,8 +23,8 @@ // RUN: %clangxx -o %t5 %t1.o %t2.o // RUN: %run %t5 2>&1 | FileCheck --check-prefix=NCFI %s -// RUN: %clangxx_cfi_diag -c -DTU1 -o %t1.o %s -// RUN: %clangxx_cfi_diag -c -DTU2 -o %t2.o %S/../cfi/anon-namespace.cpp +// RUN: %clangxx_cfi_diag -c -DTU1 -DB32 -o %t1.o %s +// RUN: %clangxx_cfi_diag -c -DTU2 -DB32 -o %t2.o %S/../cfi/anon-namespace.cpp // RUN: %clangxx_cfi_diag -o %t6 %t1.o %t2.o // RUN: %run %t6 2>&1 | FileCheck --check-prefix=CFI-DIAG %s diff --git a/compiler-rt/test/cfi/overwrite.cpp b/compiler-rt/test/cfi/overwrite.cpp index 95f11d994c60b9..988566b623fdf7 100644 --- a/compiler-rt/test/cfi/overwrite.cpp +++ b/compiler-rt/test/cfi/overwrite.cpp @@ -14,7 +14,10 @@ // RUN: %run %t5 2>&1 | FileCheck --check-prefix=NCFI %s // RUN: %clangxx_cfi_diag -o %t6 %s -// RUN: %run %t6 2>&1 | FileCheck --check-prefix=CFI-DIAG %s +// RUN: %run %t6 2>&1 | FileCheck --check-prefix=%if devirt %{CFI-DEVIRT-DIAG%} %else %{CFI-DIAG%} %s + +// RUN: %clangxx_cfi_diag -DB32 -o %t7 %s +// RUN: %run %t7 2>&1 | FileCheck --check-prefix=CFI-DIAG %s // Tests that the CFI mechanism crashes the program when a virtual table is // replaced with a compatible table of function pointers that does not belong to @@ -47,10 +50,14 @@ int main() { // CFI: 1 // NCFI: 1 + // CFI-DEVIRT-DIAG: 1 fprintf(stderr, "1\n"); // CFI-NOT: foo // NCFI: foo + // CFI-DEVIRT-DIAG-NOT: foo + // CFI-DEVIRT-DIAG-NOT: runtime error + // CFI-DEVIRT-DIAG-NOT: SUMMARY // CFI-DIAG: runtime error: control flow integrity check for type 'A' failed during virtual call // CFI-DIAG-NEXT: note: invalid vtable // CFI-DIAG: SUMMARY: UndefinedBehaviorSanitizer: cfi-vcall @@ -61,5 +68,6 @@ int main() { // rather than crashing. // NCFI: {{^2$}} + // CFI-DEVIRT-DIAG: {{^2$}} fprintf(stderr, "2\n"); } diff --git a/compiler-rt/test/cfi/simple-fail.cpp b/compiler-rt/test/cfi/simple-fail.cpp index d54725a836cddf..9f16a73e819b96 100644 --- a/compiler-rt/test/cfi/simple-fail.cpp +++ b/compiler-rt/test/cfi/simple-fail.cpp @@ -46,7 +46,7 @@ // RUN: %clangxx_cfi -O3 -DBM -o %t16 %s // RUN: %expect_crash %run %t16 2>&1 | FileCheck --check-prefix=CFI %s -// RUN: %clangxx_cfi_diag -o %t17 %s +// RUN: %clangxx_cfi_diag -DB32 -o %t17 %s // RUN: %run %t17 2>&1 | FileCheck --check-prefix=CFI-DIAG %s // RUN: %clangxx -o %t18 %s diff --git a/compiler-rt/test/cfi/vdtor.cpp b/compiler-rt/test/cfi/vdtor.cpp index 31403622a90812..65ddd5f2d0d755 100644 --- a/compiler-rt/test/cfi/vdtor.cpp +++ b/compiler-rt/test/cfi/vdtor.cpp @@ -13,7 +13,7 @@ // RUN: %clangxx -o %t5 %s // RUN: %run %t5 2>&1 | FileCheck --check-prefix=NCFI %s -// RUN: %clangxx_cfi_diag -o %t6 %s +// RUN: %clangxx_cfi_diag -DB32 -o %t6 %s // RUN: %run %t6 2>&1 | FileCheck --check-prefix=CFI-DIAG %s // Tests that the CFI enforcement also applies to virtual destructor calls made >From dc8b2eb5079de0f460c5457b5a4873eb847846d9 Mon Sep 17 00:00:00 2001 From: Vitaly Buka <[email protected]> Date: Wed, 18 Nov 2026 15:40:38 -0800 Subject: [PATCH 2/2] [spr] add -fno-whole-program-vtables cfi_diag test runs Created using spr 2.0.0-beta.2 --- compiler-rt/test/cfi/anon-namespace.cpp | 9 +++++++-- compiler-rt/test/cfi/overwrite.cpp | 5 ++++- compiler-rt/test/cfi/simple-fail.cpp | 5 ++++- compiler-rt/test/cfi/vdtor.cpp | 5 ++++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/compiler-rt/test/cfi/anon-namespace.cpp b/compiler-rt/test/cfi/anon-namespace.cpp index ebf1af21d324b3..83063ef99bf2b4 100644 --- a/compiler-rt/test/cfi/anon-namespace.cpp +++ b/compiler-rt/test/cfi/anon-namespace.cpp @@ -23,10 +23,15 @@ // RUN: %clangxx -o %t5 %t1.o %t2.o // RUN: %run %t5 2>&1 | FileCheck --check-prefix=NCFI %s +// RUN: %clangxx_cfi_diag -fno-whole-program-vtables -c -DTU1 -o %t1.o %s +// RUN: %clangxx_cfi_diag -fno-whole-program-vtables -c -DTU2 -o %t2.o %S/../cfi/anon-namespace.cpp +// RUN: %clangxx_cfi_diag -fno-whole-program-vtables -o %t6 %t1.o %t2.o +// RUN: %run %t6 2>&1 | FileCheck --check-prefix=CFI-DIAG %s + // RUN: %clangxx_cfi_diag -c -DTU1 -DB32 -o %t1.o %s // RUN: %clangxx_cfi_diag -c -DTU2 -DB32 -o %t2.o %S/../cfi/anon-namespace.cpp -// RUN: %clangxx_cfi_diag -o %t6 %t1.o %t2.o -// RUN: %run %t6 2>&1 | FileCheck --check-prefix=CFI-DIAG %s +// RUN: %clangxx_cfi_diag -o %t7 %t1.o %t2.o +// RUN: %run %t7 2>&1 | FileCheck --check-prefix=CFI-DIAG %s // Tests that the CFI mechanism treats classes in the anonymous namespace in // different translation units as having distinct identities. This is done by diff --git a/compiler-rt/test/cfi/overwrite.cpp b/compiler-rt/test/cfi/overwrite.cpp index 988566b623fdf7..79db83980bc2bc 100644 --- a/compiler-rt/test/cfi/overwrite.cpp +++ b/compiler-rt/test/cfi/overwrite.cpp @@ -16,9 +16,12 @@ // RUN: %clangxx_cfi_diag -o %t6 %s // RUN: %run %t6 2>&1 | FileCheck --check-prefix=%if devirt %{CFI-DEVIRT-DIAG%} %else %{CFI-DIAG%} %s -// RUN: %clangxx_cfi_diag -DB32 -o %t7 %s +// RUN: %clangxx_cfi_diag -fno-whole-program-vtables -o %t7 %s // RUN: %run %t7 2>&1 | FileCheck --check-prefix=CFI-DIAG %s +// RUN: %clangxx_cfi_diag -DB32 -o %t8 %s +// RUN: %run %t8 2>&1 | FileCheck --check-prefix=CFI-DIAG %s + // Tests that the CFI mechanism crashes the program when a virtual table is // replaced with a compatible table of function pointers that does not belong to // any class, by manually overwriting the virtual table of an object and diff --git a/compiler-rt/test/cfi/simple-fail.cpp b/compiler-rt/test/cfi/simple-fail.cpp index 9f16a73e819b96..c05d7bb054320a 100644 --- a/compiler-rt/test/cfi/simple-fail.cpp +++ b/compiler-rt/test/cfi/simple-fail.cpp @@ -46,9 +46,12 @@ // RUN: %clangxx_cfi -O3 -DBM -o %t16 %s // RUN: %expect_crash %run %t16 2>&1 | FileCheck --check-prefix=CFI %s -// RUN: %clangxx_cfi_diag -DB32 -o %t17 %s +// RUN: %clangxx_cfi_diag -fno-whole-program-vtables -o %t17 %s // RUN: %run %t17 2>&1 | FileCheck --check-prefix=CFI-DIAG %s +// RUN: %clangxx_cfi_diag -DB32 -o %t20 %s +// RUN: %run %t20 2>&1 | FileCheck --check-prefix=CFI-DIAG %s + // RUN: %clangxx -o %t18 %s // RUN: %run %t18 2>&1 | FileCheck --check-prefix=NCFI %s diff --git a/compiler-rt/test/cfi/vdtor.cpp b/compiler-rt/test/cfi/vdtor.cpp index 65ddd5f2d0d755..769b887393cb55 100644 --- a/compiler-rt/test/cfi/vdtor.cpp +++ b/compiler-rt/test/cfi/vdtor.cpp @@ -13,9 +13,12 @@ // RUN: %clangxx -o %t5 %s // RUN: %run %t5 2>&1 | FileCheck --check-prefix=NCFI %s -// RUN: %clangxx_cfi_diag -DB32 -o %t6 %s +// RUN: %clangxx_cfi_diag -fno-whole-program-vtables -o %t6 %s // RUN: %run %t6 2>&1 | FileCheck --check-prefix=CFI-DIAG %s +// RUN: %clangxx_cfi_diag -DB32 -o %t7 %s +// RUN: %run %t7 2>&1 | FileCheck --check-prefix=CFI-DIAG %s + // Tests that the CFI enforcement also applies to virtual destructor calls made // via 'delete'. _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
