Skip to content

[SelectionDAG] [KCFI] Allow "kcfi" on invoke #148742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3355,7 +3355,7 @@ void SelectionDAGBuilder::visitInvoke(const InvokeInst &I) {
{LLVMContext::OB_deopt, LLVMContext::OB_gc_transition,
LLVMContext::OB_gc_live, LLVMContext::OB_funclet,
LLVMContext::OB_cfguardtarget, LLVMContext::OB_ptrauth,
LLVMContext::OB_clang_arc_attachedcall}))
LLVMContext::OB_clang_arc_attachedcall, LLVMContext::OB_kcfi}))
reportFatalUsageError(
"cannot lower invokes with arbitrary operand bundles!");

Expand Down
23 changes: 23 additions & 0 deletions llvm/test/CodeGen/X86/kcfi.ll
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,29 @@ define void @f8() {
ret void
}

declare i32 @__gxx_personality_v0(...)

define void @f9() personality ptr @__gxx_personality_v0 {
; MIR-LABEL: name: f9
; MIR: body:
; ISEL: CALL64m killed %0, 1, $noreg, 0, $noreg, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, cfi-type 12345678
; KCFI: $r11 = MOV64rm killed renamable $rax, 1, $noreg, 0, $noreg
; KCFI-NEXT: BUNDLE{{.*}} {
; KCFI-NEXT: KCFI_CHECK $r11, 12345678, implicit-def $r10, implicit-def $r11, implicit-def $eflags
; KCFI-NEXT: CALL64r internal $r11, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp
; KCFI-NEXT: }
%1 = load ptr, ptr @g, align 8
invoke void %1() [ "kcfi"(i32 12345678) ]
to label %cont
unwind label %err
cont:
ret void
err:
%exn = landingpad { i8*, i32 }
catch i8* null
resume { i8*, i32 } %exn
}

attributes #0 = { "target-features"="+retpoline-indirect-branches,+retpoline-indirect-calls" }

!llvm.module.flags = !{!0}
Expand Down
Loading