[PATCH] D138634: GlobalIFunc: Make allowed constant expressions stricter
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 26 06:26:52 PST 2022
arsenm updated this revision to Diff 478054.
arsenm added a comment.
Merge tests. split-file wouldn't really help here
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138634/new/
https://reviews.llvm.org/D138634
Files:
llvm/lib/IR/Globals.cpp
llvm/test/Assembler/ifunc-stripPointerCastsAndAliases.ll
llvm/test/Assembler/ifunc-unhandled-constantexpr.ll
llvm/test/Verifier/ifunc-opaque.ll
Index: llvm/test/Verifier/ifunc-opaque.ll
===================================================================
--- /dev/null
+++ llvm/test/Verifier/ifunc-opaque.ll
@@ -0,0 +1,9 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+
+define ptr @resolver() {
+ ret ptr null
+}
+
+; CHECK: IFunc must have a Function resolver
+; CHECK-NEXT: ptr @ifunc_getelementptr
+ at ifunc_getelementptr = ifunc void (), ptr getelementptr (i8, ptr @resolver, i32 4)
Index: llvm/test/Assembler/ifunc-unhandled-constantexpr.ll
===================================================================
--- /dev/null
+++ llvm/test/Assembler/ifunc-unhandled-constantexpr.ll
@@ -0,0 +1,12 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+
+; Make sure nothing asserts on an unhandled constantexpr for the
+; resolver.
+
+; CHECK: IFunc must have a Function resolver
+; CHECK-NEXT: ptr @ifunc_shl
+ at ifunc_shl = ifunc void (), ptr inttoptr (i64 shl (i64 ptrtoint (ptr @resolver to i64), i64 4) to ptr)
+
+define ptr @resolver() {
+ ret ptr null
+}
Index: llvm/test/Assembler/ifunc-stripPointerCastsAndAliases.ll
===================================================================
--- /dev/null
+++ llvm/test/Assembler/ifunc-stripPointerCastsAndAliases.ll
@@ -0,0 +1,23 @@
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+; Check constantexprs which ifunc looks through to find the resolver
+; function.
+
+ at ifunc_addrspacecast_as1_to_as0 = ifunc void (), ptr addrspacecast (ptr addrspace(1) @resolver_as1 to ptr)
+
+; CHECK: @alias_resolver = internal alias i32 (i32), ptr @resolver
+ at alias_resolver = internal alias i32 (i32), ptr @resolver
+
+; CHECK: @ifunc_resolver_is_alias = internal ifunc i32 (i32), ptr @alias_resolver
+ at ifunc_resolver_is_alias = internal ifunc i32 (i32), ptr @alias_resolver
+
+
+; CHECK: define ptr @resolver_as1() addrspace(1) {
+define ptr @resolver_as1() addrspace(1) {
+ ret ptr null
+}
+
+; CHECK: define internal ptr @resolver() {
+define internal ptr @resolver() {
+ ret ptr null
+}
Index: llvm/lib/IR/Globals.cpp
===================================================================
--- llvm/lib/IR/Globals.cpp
+++ llvm/lib/IR/Globals.cpp
@@ -584,9 +584,7 @@
}
const Function *GlobalIFunc::getResolverFunction() const {
- DenseSet<const GlobalAlias *> Aliases;
- return dyn_cast<Function>(
- findBaseObject(getResolver(), Aliases, [](const GlobalValue &) {}));
+ return dyn_cast<Function>(getResolver()->stripPointerCastsAndAliases());
}
void GlobalIFunc::applyAlongResolverPath(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138634.478054.patch
Type: text/x-patch
Size: 2508 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221126/c7ce118f/attachment.bin>
More information about the llvm-commits
mailing list