diff options
author | Nikita Popov <npopov@redhat.com> | 2025-05-02 09:40:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-02 09:40:50 +0200 |
commit | 4109bac3301eb7b7033eec3c8e8107be8cad9bc9 (patch) | |
tree | e2f28b7cca07f00337268f6a717d461bb2e15591 /llvm/lib/IR/Function.cpp | |
parent | ff28e1a5a92da380c2869aba09971687c26d2f0f (diff) | |
download | llvm-4109bac3301eb7b7033eec3c8e8107be8cad9bc9.zip llvm-4109bac3301eb7b7033eec3c8e8107be8cad9bc9.tar.gz llvm-4109bac3301eb7b7033eec3c8e8107be8cad9bc9.tar.bz2 |
[IR] Do not store Function inside BlockAddress (#137958)
Currently BlockAddresses store both the Function and the BasicBlock they
reference, and the BlockAddress is part of the use list of both the
Function and BasicBlock.
This is quite awkward, because this is not really a use of the function
itself (and walks of function uses generally skip block addresses for
that reason). This also has weird implications on function RAUW (as that
will replace the function in block addresses in a way that generally
doesn't make sense), and causes other peculiar issues, like the ability
to have multiple block addresses for one block (with different
functions).
Instead, I believe it makes more sense to specify only the basic block
and let the function be implied by the BB parent. This does mean that we
may have block addresses without a function (if the BB is not inserted),
but this should only happen during IR construction.
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r-- | llvm/lib/IR/Function.cpp | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index ce0f710..9c64cd1 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -966,9 +966,6 @@ bool Function::hasAddressTaken(const User **PutOffender, bool IgnoreCastedDirectCall) const { for (const Use &U : uses()) { const User *FU = U.getUser(); - if (isa<BlockAddress>(FU)) - continue; - if (IgnoreCallbackUses) { AbstractCallSite ACS(&U); if (ACS && ACS.isCallbackCall()) @@ -1033,12 +1030,7 @@ bool Function::isDefTriviallyDead() const { !hasAvailableExternallyLinkage()) return false; - // Check if the function is used by anything other than a blockaddress. - for (const User *U : users()) - if (!isa<BlockAddress>(U)) - return false; - - return true; + return use_empty(); } /// callsFunctionThatReturnsTwice - Return true if the function has a call to |