Skip to content

Commit 318bdd0

Browse files
authored
[StackSafetyAnalysis] Bail out when calling ifunc
An assertion failure arises when a call instruction calls a GlobalIFunc. Since we cannot reason about the underlying function, just bail out. Fix #87923 Pull Request: #113841
1 parent 4df71ab commit 318bdd0

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

llvm/lib/Analysis/StackSafetyAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ void StackSafetyLocalAnalysis::analyzeAllUses(Value *Ptr,
528528
// dso_preemptable aliases or aliases with interposable linkage.
529529
const GlobalValue *Callee =
530530
dyn_cast<GlobalValue>(CB.getCalledOperand()->stripPointerCasts());
531-
if (!Callee) {
531+
if (!Callee || isa<GlobalIFunc>(Callee)) {
532532
US.addRange(I, UnknownRange, /*IsSafe=*/false);
533533
break;
534534
}

llvm/test/Analysis/StackSafetyAnalysis/local.ll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,5 +1120,21 @@ define void @NonPointer(ptr %p) {
11201120
ret void
11211121
}
11221122

1123+
@ifunc = dso_local ifunc i64 (ptr), ptr @ifunc_resolver
1124+
1125+
define dso_local void @CallIfunc(ptr noundef %uaddr) local_unnamed_addr {
1126+
; CHECK-LABEL: @CallIfunc
1127+
; CHECK-NEXT: args uses:
1128+
; CHECK-NEXT: uaddr[]: full-set
1129+
entry:
1130+
tail call i64 @ifunc(ptr noundef %uaddr)
1131+
ret void
1132+
}
1133+
1134+
define dso_local ptr @ifunc_resolver() {
1135+
entry:
1136+
ret ptr null
1137+
}
1138+
11231139
declare void @llvm.lifetime.start.p0(i64, ptr nocapture)
11241140
declare void @llvm.lifetime.end.p0(i64, ptr nocapture)

0 commit comments

Comments
 (0)