@@ -11,6 +11,7 @@ SPDX-License-Identifier: MIT
11
11
#include " Compiler/CISACodeGen/CastToGASAnalysis.h"
12
12
#include " Compiler/CodeGenContextWrapper.hpp"
13
13
#include " Compiler/MetaDataUtilsWrapper.h"
14
+ #include " Metrics/IGCMetric.h"
14
15
#include " Compiler/IGCPassSupport.h"
15
16
#include " WrapperLLVM/Utils.h"
16
17
#include " llvm/ADT/PostOrderIterator.h"
@@ -1480,6 +1481,7 @@ namespace IGC
1480
1481
void updateMetadata (Function* oldFunc, Function* newFunc);
1481
1482
Function* createFuncWithLoweredArgs (Function* F, GenericPointerArgs& argsInfo);
1482
1483
std::vector<Function*> findCandidates (CallGraph& CG);
1484
+ void replaceValueInDbgInfoIntrinsic (llvm::Value* Old, llvm::Value* New, llvm::Module& M);
1483
1485
};
1484
1486
} // End anonymous namespace
1485
1487
@@ -1765,7 +1767,7 @@ void LowerGPCallArg::updateFunctionArgs(Function* oldFunc, Function* newFunc)
1765
1767
// used to directly update uses in metadata node. In case of GAS, RAUW asserts because
1766
1768
// addrspace used in Old/New values are different and this is interpreted as different
1767
1769
// types by LLVM and RAUW on different types is forbidden.
1768
- void replaceValueInDbgInfoIntrinsic (llvm::Value* Old, llvm::Value* New, llvm::Module& M)
1770
+ void LowerGPCallArg:: replaceValueInDbgInfoIntrinsic (llvm::Value* Old, llvm::Value* New, llvm::Module& M)
1769
1771
{
1770
1772
if (Old->isUsedByMetadata ())
1771
1773
{
@@ -1774,10 +1776,10 @@ void replaceValueInDbgInfoIntrinsic(llvm::Value* Old, llvm::Value* New, llvm::Mo
1774
1776
if (addrSpaceMD)
1775
1777
{
1776
1778
llvm::DIBuilder DIB (M);
1777
- std::vector<llvm::DbgInfoIntrinsic *> DbgInfoInstToDelete ;
1779
+ std::vector<llvm::Instruction *> instToDelete ;
1778
1780
for (auto * User : addrSpaceMD->users ())
1779
1781
{
1780
- if (cast <DbgInfoIntrinsic>(User))
1782
+ if (isa <DbgInfoIntrinsic>(User))
1781
1783
{
1782
1784
// User->dump();
1783
1785
if (auto DbgV = cast<DbgValueInst>(User))
@@ -1792,12 +1794,26 @@ void replaceValueInDbgInfoIntrinsic(llvm::Value* Old, llvm::Value* New, llvm::Mo
1792
1794
DbgD->getVariable (), DbgD->getExpression (), DbgD->getDebugLoc ().get (),
1793
1795
cast<llvm::Instruction>(User));
1794
1796
}
1795
- DbgInfoInstToDelete.push_back (cast<llvm::DbgInfoIntrinsic>(User));
1797
+
1798
+ instToDelete.push_back (cast<llvm::DbgInfoIntrinsic>(User));
1799
+ }
1800
+ else if (isa<CallInst>(User))
1801
+ {
1802
+ if (auto callInst = cast<CallInst>(User))
1803
+ {
1804
+ if (IGCMetrics::IGCMetric::isMetricFuncCall (
1805
+ cast<CallInst>(User)))
1806
+ {
1807
+ m_ctx->metrics .UpdateVariable (Old, New);
1808
+ }
1809
+ }
1810
+
1811
+ instToDelete.push_back (cast<llvm::CallInst>(User));
1796
1812
}
1797
1813
}
1798
1814
1799
- for (auto DbgInfoInst : DbgInfoInstToDelete )
1800
- DbgInfoInst ->eraseFromParent ();
1815
+ for (auto inst : instToDelete )
1816
+ inst ->eraseFromParent ();
1801
1817
}
1802
1818
}
1803
1819
}
0 commit comments