-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[DirectX] Remove lifetime intrinsics and run Dead Store Elimination #152636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+130
−10
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
96c7b23
[DirectX] remove lifetime intrinsics and run Dead Store Elimination
farzonl 821e767
DSE removes the unused gep\store, fix up the test to account
farzonl 79a4e9d
Update DXILForwardHandleAccesses.cpp to look at Operand 0 instead of …
farzonl ffd6353
address pr comments
farzonl db049a1
remove comment
farzonl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
#include "llvm/ADT/Statistic.h" | ||
#include "llvm/ADT/StringRef.h" | ||
#include "llvm/Analysis/AliasAnalysis.h" | ||
#include "llvm/Analysis/AssumptionCache.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The old pass manager had this dependency when it was removed so I brought it back. |
||
#include "llvm/Analysis/CaptureTracking.h" | ||
#include "llvm/Analysis/GlobalsModRef.h" | ||
#include "llvm/Analysis/LoopInfo.h" | ||
|
@@ -69,6 +70,7 @@ | |
#include "llvm/IR/PassManager.h" | ||
#include "llvm/IR/PatternMatch.h" | ||
#include "llvm/IR/Value.h" | ||
#include "llvm/InitializePasses.h" | ||
#include "llvm/Support/Casting.h" | ||
#include "llvm/Support/CommandLine.h" | ||
#include "llvm/Support/Debug.h" | ||
|
@@ -2666,3 +2668,79 @@ PreservedAnalyses DSEPass::run(Function &F, FunctionAnalysisManager &AM) { | |
PA.preserve<LoopAnalysis>(); | ||
return PA; | ||
} | ||
|
||
namespace { | ||
|
||
/// A legacy pass for the legacy pass manager that wraps \c DSEPass. | ||
class DSELegacyPass : public FunctionPass { | ||
public: | ||
static char ID; // Pass identification, replacement for typeid | ||
|
||
DSELegacyPass() : FunctionPass(ID) { | ||
initializeDSELegacyPassPass(*PassRegistry::getPassRegistry()); | ||
} | ||
|
||
bool runOnFunction(Function &F) override { | ||
if (skipFunction(F)) | ||
return false; | ||
|
||
AliasAnalysis &AA = getAnalysis<AAResultsWrapperPass>().getAAResults(); | ||
DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree(); | ||
const TargetLibraryInfo &TLI = | ||
getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F); | ||
MemorySSA &MSSA = getAnalysis<MemorySSAWrapperPass>().getMSSA(); | ||
PostDominatorTree &PDT = | ||
getAnalysis<PostDominatorTreeWrapperPass>().getPostDomTree(); | ||
LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo(); | ||
|
||
bool Changed = eliminateDeadStores(F, AA, MSSA, DT, PDT, TLI, LI); | ||
|
||
#ifdef LLVM_ENABLE_STATS | ||
if (AreStatisticsEnabled()) | ||
for (auto &I : instructions(F)) | ||
NumRemainingStores += isa<StoreInst>(&I); | ||
#endif | ||
|
||
return Changed; | ||
} | ||
|
||
void getAnalysisUsage(AnalysisUsage &AU) const override { | ||
AU.setPreservesCFG(); | ||
AU.addRequired<AAResultsWrapperPass>(); | ||
AU.addRequired<TargetLibraryInfoWrapperPass>(); | ||
AU.addPreserved<GlobalsAAWrapperPass>(); | ||
AU.addRequired<DominatorTreeWrapperPass>(); | ||
AU.addPreserved<DominatorTreeWrapperPass>(); | ||
AU.addRequired<PostDominatorTreeWrapperPass>(); | ||
AU.addRequired<MemorySSAWrapperPass>(); | ||
AU.addPreserved<PostDominatorTreeWrapperPass>(); | ||
AU.addPreserved<MemorySSAWrapperPass>(); | ||
AU.addRequired<LoopInfoWrapperPass>(); | ||
AU.addPreserved<LoopInfoWrapperPass>(); | ||
AU.addRequired<AssumptionCacheTracker>(); | ||
} | ||
}; | ||
|
||
} // end anonymous namespace | ||
|
||
char DSELegacyPass::ID = 0; | ||
|
||
INITIALIZE_PASS_BEGIN(DSELegacyPass, "dse", "Dead Store Elimination", false, | ||
false) | ||
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) | ||
INITIALIZE_PASS_DEPENDENCY(PostDominatorTreeWrapperPass) | ||
INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass) | ||
INITIALIZE_PASS_DEPENDENCY(GlobalsAAWrapperPass) | ||
INITIALIZE_PASS_DEPENDENCY(MemorySSAWrapperPass) | ||
INITIALIZE_PASS_DEPENDENCY(MemoryDependenceWrapperPass) | ||
INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass) | ||
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass) | ||
INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker) | ||
INITIALIZE_PASS_END(DSELegacyPass, "dse", "Dead Store Elimination", false, | ||
false) | ||
|
||
namespace llvm { | ||
LLVM_ABI FunctionPass *createDeadStoreEliminationPass() { | ||
return new DSELegacyPass(); | ||
} | ||
} // namespace llvm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.