[PATCH] D97735: [Globals] Treat nobuiltin fns as maybe-derefined.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 23 05:45:25 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5913d7705618: [Globals] Treat nobuiltin fns as maybe-derefined. (authored by fhahn).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97735/new/
https://reviews.llvm.org/D97735
Files:
llvm/include/llvm/IR/GlobalValue.h
llvm/lib/IR/Globals.cpp
llvm/test/Transforms/DeadArgElim/pr49022-builtin-nobuiltin.ll
Index: llvm/test/Transforms/DeadArgElim/pr49022-builtin-nobuiltin.ll
===================================================================
--- llvm/test/Transforms/DeadArgElim/pr49022-builtin-nobuiltin.ll
+++ llvm/test/Transforms/DeadArgElim/pr49022-builtin-nobuiltin.ll
@@ -13,7 +13,7 @@
define dso_local i32 @test_fn(ptr %ptr) {
; CHECK-LABEL: @test_fn(
; CHECK-NEXT: entry:
-; CHECK-NEXT: call void @_ZdlPv(ptr poison) #[[ATTR1:[0-9]+]]
+; CHECK-NEXT: call void @_ZdlPv(ptr [[PTR:%.*]]) #[[ATTR1:[0-9]+]]
; CHECK-NEXT: ret i32 1
;
entry:
Index: llvm/lib/IR/Globals.cpp
===================================================================
--- llvm/lib/IR/Globals.cpp
+++ llvm/lib/IR/Globals.cpp
@@ -261,6 +261,13 @@
setGlobalObjectFlag(HasSectionHashEntryBit, !S.empty());
}
+bool GlobalValue::isNobuiltinFnDef() const {
+ const Function *F = dyn_cast<Function>(this);
+ if (!F || F->empty())
+ return false;
+ return F->hasFnAttribute(Attribute::NoBuiltin);
+}
+
bool GlobalValue::isDeclaration() const {
// Globals are definitions if they have an initializer.
if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(this))
Index: llvm/include/llvm/IR/GlobalValue.h
===================================================================
--- llvm/include/llvm/IR/GlobalValue.h
+++ llvm/include/llvm/IR/GlobalValue.h
@@ -145,12 +145,20 @@
case AppendingLinkage:
case InternalLinkage:
case PrivateLinkage:
- return isInterposable();
+ // Optimizations may assume builtin semantics for functions defined as
+ // nobuiltin due to attributes at call-sites. To avoid applying IPO based
+ // on nobuiltin semantics, treat such function definitions as maybe
+ // derefined.
+ return isInterposable() || isNobuiltinFnDef();
}
llvm_unreachable("Fully covered switch above!");
}
+ /// Returns true if the global is a function definition with the nobuiltin
+ /// attribute.
+ bool isNobuiltinFnDef() const;
+
protected:
/// The intrinsic ID for this subclass (which must be a Function).
///
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97735.454804.patch
Type: text/x-patch
Size: 2082 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220823/2d0d239e/attachment.bin>
More information about the llvm-commits
mailing list