[PATCH] D106383: [Attributor] Preserve BBs and instructions added in AA manifests
Giorgis Georgakoudis via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 20 10:34:31 PDT 2021
ggeorgakoudis created this revision.
Herald added subscribers: ormris, okura, kuter, uenoku, hiraditya.
Herald added a reviewer: uenoku.
Herald added a reviewer: homerdin.
ggeorgakoudis requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added a reviewer: baziotis.
Herald added subscribers: llvm-commits, bbn.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D106383
Files:
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/Transforms/IPO/Attributor.cpp
Index: llvm/lib/Transforms/IPO/Attributor.cpp
===================================================================
--- llvm/lib/Transforms/IPO/Attributor.cpp
+++ llvm/lib/Transforms/IPO/Attributor.cpp
@@ -801,6 +801,9 @@
const IRPosition::CallBaseContext *CBCtx =
QueryingAA ? QueryingAA->getCallBaseContext() : nullptr;
+ if (ManifestAddedBlocks.contains(I.getParent()))
+ return false;
+
if (!FnLivenessAA)
FnLivenessAA =
lookupAAFor<AAIsDead>(IRPosition::function(*I.getFunction(), CBCtx),
@@ -1441,7 +1444,9 @@
<< ToBeDeletedBlocks.size() << " blocks and "
<< ToBeDeletedInsts.size() << " instructions and "
<< ToBeChangedValues.size() << " values and "
- << ToBeChangedUses.size() << " uses\n");
+ << ToBeChangedUses.size() << " uses. "
+ << "Preserve manifest added " << ManifestAddedBlocks.size()
+ << " blocks\n");
SmallVector<WeakTrackingVH, 32> DeadInsts;
SmallVector<Instruction *, 32> TerminatorsToFold;
@@ -1602,6 +1607,9 @@
assert(isRunOn(*BB->getParent()) &&
"Cannot delete a block outside the current SCC!");
CGModifiedFunctions.insert(BB->getParent());
+ // Do not delete BBs added during manifests of AAs.
+ if (ManifestAddedBlocks.contains(BB))
+ continue;
ToBeDeletedBBs.push_back(BB);
}
// Actually we do not delete the blocks but squash them into a single
Index: llvm/include/llvm/Transforms/IPO/Attributor.h
===================================================================
--- llvm/include/llvm/Transforms/IPO/Attributor.h
+++ llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -1487,6 +1487,12 @@
/// triggers deletion of trivially dead istructions.
void deleteAfterManifest(BasicBlock &BB) { ToBeDeletedBlocks.insert(&BB); }
+ // Record that \p BB is added during the manifest of an AA. Added basic blocks
+ // are preserved in the IR.
+ void registerManifestAddedBasicBlock(BasicBlock &BB) {
+ ManifestAddedBlocks.insert(&BB);
+ }
+
/// Record that \p F is deleted after information was manifested.
void deleteAfterManifest(Function &F) {
if (DeleteFns)
@@ -1979,6 +1985,7 @@
///{
SmallPtrSet<Function *, 8> ToBeDeletedFunctions;
SmallPtrSet<BasicBlock *, 8> ToBeDeletedBlocks;
+ SmallPtrSet<BasicBlock *, 8> ManifestAddedBlocks;
SmallDenseSet<WeakVH, 8> ToBeDeletedInsts;
///}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106383.360201.patch
Type: text/x-patch
Size: 2490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210720/6d4586d9/attachment.bin>
More information about the llvm-commits
mailing list