[PATCH] D106383: [Attributor] Preserve BBs and instructions added in AA manifests
Giorgis Georgakoudis via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 21 01:56:23 PDT 2021
ggeorgakoudis updated this revision to Diff 360387.
ggeorgakoudis added a comment.
Fix for comments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106383/new/
https://reviews.llvm.org/D106383
Files:
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
Index: llvm/lib/Transforms/IPO/OpenMPOpt.cpp
===================================================================
--- llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -3043,6 +3043,14 @@
Kernel, UserCodeEntryBB);
BasicBlock *StateMachineDoneBarrierBB = BasicBlock::Create(
Ctx, "worker_state_machine.done.barrier", Kernel, UserCodeEntryBB);
+ A.registerManifestAddedBasicBlock(*InitBB);
+ A.registerManifestAddedBasicBlock(*UserCodeEntryBB);
+ A.registerManifestAddedBasicBlock(*StateMachineBeginBB);
+ A.registerManifestAddedBasicBlock(*StateMachineFinishedBB);
+ A.registerManifestAddedBasicBlock(*StateMachineIsActiveCheckBB);
+ A.registerManifestAddedBasicBlock(*StateMachineIfCascadeCurrentBB);
+ A.registerManifestAddedBasicBlock(*StateMachineEndParallelBB);
+ A.registerManifestAddedBasicBlock(*StateMachineDoneBarrierBB);
const DebugLoc &DLoc = KernelInitCB->getDebugLoc();
ReturnInst::Create(Ctx, StateMachineFinishedBB)->setDebugLoc(DLoc);
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.360387.patch
Type: text/x-patch
Size: 3551 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210721/007e3588/attachment.bin>
More information about the llvm-commits
mailing list