[llvm] [StackSafetyAnalysis] Bail out when calling ifunc (PR #113841)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 27 16:05:19 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Fangrui Song (MaskRay)
<details>
<summary>Changes</summary>
An assertion failure arises when a call instruction calls a GlobalIFunc.
Since we cannot reason about the underlying function, just bail out.
Fix #<!-- -->87923
---
Full diff: https://github.com/llvm/llvm-project/pull/113841.diff
2 Files Affected:
- (modified) llvm/lib/Analysis/StackSafetyAnalysis.cpp (+1-1)
- (modified) llvm/test/Analysis/StackSafetyAnalysis/local.ll (+16)
``````````diff
diff --git a/llvm/lib/Analysis/StackSafetyAnalysis.cpp b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
index 27360d0e84cb2b..5d81658409dae8 100644
--- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp
+++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
@@ -528,7 +528,7 @@ void StackSafetyLocalAnalysis::analyzeAllUses(Value *Ptr,
// dso_preemptable aliases or aliases with interposable linkage.
const GlobalValue *Callee =
dyn_cast<GlobalValue>(CB.getCalledOperand()->stripPointerCasts());
- if (!Callee) {
+ if (!Callee || isa<GlobalIFunc>(Callee)) {
US.addRange(I, UnknownRange, /*IsSafe=*/false);
break;
}
diff --git a/llvm/test/Analysis/StackSafetyAnalysis/local.ll b/llvm/test/Analysis/StackSafetyAnalysis/local.ll
index 4a833611c78916..02d46c8449bae5 100644
--- a/llvm/test/Analysis/StackSafetyAnalysis/local.ll
+++ b/llvm/test/Analysis/StackSafetyAnalysis/local.ll
@@ -1120,5 +1120,21 @@ define void @NonPointer(ptr %p) {
ret void
}
+ at ifunc = dso_local ifunc i64 (ptr), ptr @ifunc_resolver
+
+define dso_local void @CallIfunc(ptr noundef %uaddr) local_unnamed_addr {
+; CHECK-LABEL: @CallIfunc
+; CHECK-NEXT: args uses:
+; CHECK-NEXT: uaddr[]: full-set
+entry:
+ tail call i64 @ifunc(ptr noundef %uaddr)
+ ret void
+}
+
+define dso_local ptr @ifunc_resolver() {
+entry:
+ ret ptr null
+}
+
declare void @llvm.lifetime.start.p0(i64, ptr nocapture)
declare void @llvm.lifetime.end.p0(i64, ptr nocapture)
``````````
</details>
https://github.com/llvm/llvm-project/pull/113841
More information about the llvm-commits
mailing list