[llvm] fdd9761 - Attributor: Fix crash on undef in !callees
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 14 17:03:31 PDT 2021
Author: Matt Arsenault
Date: 2021-09-14T19:49:34-04:00
New Revision: fdd9761dd1a971c9f4d6776b511ea54d7765bfeb
URL: https://github.com/llvm/llvm-project/commit/fdd9761dd1a971c9f4d6776b511ea54d7765bfeb
DIFF: https://github.com/llvm/llvm-project/commit/fdd9761dd1a971c9f4d6776b511ea54d7765bfeb.diff
LOG: Attributor: Fix crash on undef in !callees
Added:
Modified:
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/test/Transforms/Attributor/callgraph.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index a6342e219a080..39c8e2478731a 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -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);
}
diff --git a/llvm/test/Transforms/Attributor/callgraph.ll b/llvm/test/Transforms/Attributor/callgraph.ll
index 2b4c5f523b901..e65635bf2cd8b 100644
--- a/llvm/test/Transforms/Attributor/callgraph.ll
+++ b/llvm/test/Transforms/Attributor/callgraph.ll
@@ -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
More information about the llvm-commits
mailing list