Skip to content

Commit cc05266

Browse files
authored
[GlobalOpt] Fix unreachable ifunc globalopt crash (#157332) (#157593)
Also fixes (#131488) Unreachable case is triggering `Callees.empty()` assert. Since this was [originally ](02bd5a7#diff-06aba0dac2a263dc14297a15655291d5506b760f54a736385bcf3208f83df843R2524) a `continue` anyway, have applied that as a fix and added a test case. Please let me know if there's a better way. Not sure who/how to get folks to review, tagging a few people (apologies if you're not the right person/this is the wrong way to do it, please let me know what to do in future if so) @labrinea @dtcxzyw @nikic @fhahn
1 parent c71318a commit cc05266

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

llvm/lib/Transforms/IPO/GlobalOpt.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2551,7 +2551,8 @@ static bool OptimizeNonTrivialIFuncs(
25512551
}))
25522552
continue;
25532553

2554-
assert(!Callees.empty() && "Expecting successful collection of versions");
2554+
if (Callees.empty())
2555+
continue;
25552556

25562557
LLVM_DEBUG(dbgs() << "Statically resolving calls to function "
25572558
<< Resolver->getName() << "\n");
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt --passes=globalopt -o - -S < %s | FileCheck %s
3+
4+
define ptr @f1() {
5+
; CHECK-LABEL: define ptr @f1() {
6+
; CHECK-NEXT: unreachable
7+
;
8+
unreachable
9+
}
10+
11+
@i1 = ifunc void(), ptr @f1

0 commit comments

Comments
 (0)