Skip to content

Commit 2c28df8

Browse files
jgu222sys_zuul
authored andcommitted
TrivialLocalMem optimization is meant for entry function only. Disable it for subroutines.
Change-Id: I77854c0c055cf7936d4df43b0b5bb0bfd0c87485
1 parent 7d079ed commit 2c28df8

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

IGC/Compiler/CustomSafeOptPass.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,14 @@ bool TrivialLocalMemoryOpsElimination::runOnFunction(Function& F)
16321632
{
16331633
bool change = false;
16341634

1635+
IGCMD::MetaDataUtils* pMdUtil = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
1636+
if (!isEntryFunc(pMdUtil, &F))
1637+
{
1638+
// Skip if it is non-entry function. For example, a subroutine
1639+
// foo ( local int* p) { ...... store v, p; ......}
1640+
// in which no localMemoptimization will be performed.
1641+
return change;
1642+
}
16351643

16361644
visit(F);
16371645
if (!abortPass && (m_LocalLoadsToRemove.empty() ^ m_LocalStoresToRemove.empty()))

IGC/Compiler/CustomSafeOptPass.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2626

2727
#pragma once
2828
#include "Compiler/CodeGenContextWrapper.hpp"
29+
#include "Compiler/MetaDataUtilsWrapper.h"
2930
#include "common/MDFrameWork.h"
3031
#include "common/LLVMWarningsPush.hpp"
3132
#include "llvm/Config/llvm-config.h"
@@ -124,6 +125,7 @@ namespace IGC
124125
virtual void getAnalysisUsage(llvm::AnalysisUsage& AU) const override
125126
{
126127
AU.addRequired<CodeGenContextWrapper>();
128+
AU.addRequired<MetaDataUtilsWrapper>();
127129
AU.setPreservesCFG();
128130
}
129131

0 commit comments

Comments
 (0)