Attributor: Fix crash on undef in !callees

This commit is contained in:
Matt Arsenault 2021-09-13 21:35:53 -04:00
parent f12174204c
commit fdd9761dd1
2 changed files with 14 additions and 1 deletions

View File

@ -9438,7 +9438,7 @@ struct AACallEdgesCallSite : public AACallEdgesImpl {
// Process callee metadata if available.
if (auto *MD = getCtxI()->getMetadata(LLVMContext::MD_callees)) {
for (auto &Op : MD->operands()) {
Function *Callee = mdconst::extract_or_null<Function>(Op);
Function *Callee = mdconst::dyn_extract_or_null<Function>(Op);
if (Callee)
addCalledFunction(Callee, Change);
}

View File

@ -76,9 +76,22 @@ define void @func7(void ()* %unknown) {
ret void
}
; Check there's no crash if something that isn't a function appears in !callees
define void @undef_in_callees() {
; CHECK-LABEL: @undef_in_callees(
; CHECK-NEXT: cond.end.i:
; CHECK-NEXT: call void undef(i8* undef, i32 undef, i8* undef), !callees !3
; CHECK-NEXT: ret void
;
cond.end.i:
call void undef(i8* undef, i32 undef, i8* undef), !callees !3
ret void
}
!0 = !{!1}
!1 = !{i64 0, i1 false}
!2 = !{void ()* @func3, void ()* @func4}
!3 = distinct !{void (i8*, i32, i8*)* undef, void (i8*, i32, i8*)* null}
; UTC_ARGS: --disable