Skip to content

Commit 19062dd

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.4
2 parents 102c15a + eb39f24 commit 19062dd

File tree

3 files changed

+47
-7
lines changed

3 files changed

+47
-7
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3351,13 +3351,30 @@ void SelectionDAGBuilder::visitInvoke(const InvokeInst &I) {
33513351

33523352
// Deopt and ptrauth bundles are lowered in helper functions, and we don't
33533353
// have to do anything here to lower funclet bundles.
3354-
if (I.hasOperandBundlesOtherThan(
3355-
{LLVMContext::OB_deopt, LLVMContext::OB_gc_transition,
3356-
LLVMContext::OB_gc_live, LLVMContext::OB_funclet,
3357-
LLVMContext::OB_cfguardtarget, LLVMContext::OB_ptrauth,
3358-
LLVMContext::OB_clang_arc_attachedcall}))
3354+
constexpr std::array<uint32_t, 8> kAllowedBundles = {
3355+
LLVMContext::OB_deopt,
3356+
LLVMContext::OB_gc_transition,
3357+
LLVMContext::OB_gc_live,
3358+
LLVMContext::OB_funclet,
3359+
LLVMContext::OB_cfguardtarget,
3360+
LLVMContext::OB_ptrauth,
3361+
LLVMContext::OB_clang_arc_attachedcall,
3362+
LLVMContext::OB_kcfi};
3363+
if (I.hasOperandBundlesOtherThan(kAllowedBundles)) {
3364+
std::string Error;
3365+
for (unsigned i = 0, e = I.getNumOperandBundles(); i != e; ++i) {
3366+
OperandBundleUse U = I.getOperandBundleAt(i);
3367+
bool First = true;
3368+
if (is_contained(kAllowedBundles, U.getTagID()))
3369+
continue;
3370+
if (!First)
3371+
Error += ", ";
3372+
First = false;
3373+
Error += U.getTagName();
3374+
}
33593375
reportFatalUsageError(
3360-
"cannot lower invokes with arbitrary operand bundles!");
3376+
Twine("cannot lower invokes with arbitrary operand bundles: ", Error));
3377+
}
33613378

33623379
const Value *Callee(I.getCalledOperand());
33633380
const Function *Fn = dyn_cast<Function>(Callee);

llvm/test/CodeGen/X86/invalid-operand-bundle-invoke.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; RUN: not llc -mtriple=x86_64-unknown-linux-gnu < %s 2>&1 | FileCheck %s
22

3-
; CHECK: LLVM ERROR: cannot lower invokes with arbitrary operand bundles!
3+
; CHECK: LLVM ERROR: cannot lower invokes with arbitrary operand bundles: foo
44

55
declare void @g()
66
declare i32 @__gxx_personality_v0(...)

llvm/test/CodeGen/X86/kcfi.ll

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,29 @@ define void @f8() {
138138
ret void
139139
}
140140

141+
declare i32 @__gxx_personality_v0(...)
142+
143+
define void @f9() personality ptr @__gxx_personality_v0 {
144+
; MIR-LABEL: name: f9
145+
; MIR: body:
146+
; ISEL: CALL64m killed %0, 1, $noreg, 0, $noreg, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, cfi-type 12345678
147+
; KCFI: $r11 = MOV64rm killed renamable $rax, 1, $noreg, 0, $noreg
148+
; KCFI-NEXT: BUNDLE{{.*}} {
149+
; KCFI-NEXT: KCFI_CHECK $r11, 12345678, implicit-def $r10, implicit-def $r11, implicit-def $eflags
150+
; KCFI-NEXT: CALL64r internal $r11, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp
151+
; KCFI-NEXT: }
152+
%1 = load ptr, ptr @g, align 8
153+
invoke void %1() [ "kcfi"(i32 12345678) ]
154+
to label %cont
155+
unwind label %err
156+
cont:
157+
ret void
158+
err:
159+
%exn = landingpad { i8*, i32 }
160+
catch i8* null
161+
resume { i8*, i32 } %exn
162+
}
163+
141164
attributes #0 = { "target-features"="+retpoline-indirect-branches,+retpoline-indirect-calls" }
142165

143166
!llvm.module.flags = !{!0}

0 commit comments

Comments
 (0)