[llvm] 318bdd0 - [StackSafetyAnalysis] Bail out when calling ifunc
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 29 09:26:50 PDT 2024
Author: Fangrui Song
Date: 2024-10-29T09:26:47-07:00
New Revision: 318bdd0aeb721c8e9bd67101ac6641e5f9d990f2
URL: https://github.com/llvm/llvm-project/commit/318bdd0aeb721c8e9bd67101ac6641e5f9d990f2
DIFF: https://github.com/llvm/llvm-project/commit/318bdd0aeb721c8e9bd67101ac6641e5f9d990f2.diff
LOG: [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: https://github.com/llvm/llvm-project/pull/113841
Added:
Modified:
llvm/lib/Analysis/StackSafetyAnalysis.cpp
llvm/test/Analysis/StackSafetyAnalysis/local.ll
Removed:
################################################################################
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)
More information about the llvm-commits
mailing list