Skip to content

Commit e9cac19

Browse files
lwesiersigcbot
authored andcommitted
Bugfix in IGC Metrics
Fix crash in ResolveGAS
1 parent a4af3e6 commit e9cac19

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

IGC/Compiler/CISACodeGen/ResolveGAS.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ SPDX-License-Identifier: MIT
1111
#include "Compiler/CISACodeGen/CastToGASAnalysis.h"
1212
#include "Compiler/CodeGenContextWrapper.hpp"
1313
#include "Compiler/MetaDataUtilsWrapper.h"
14+
#include "Metrics/IGCMetric.h"
1415
#include "Compiler/IGCPassSupport.h"
1516
#include "WrapperLLVM/Utils.h"
1617
#include "llvm/ADT/PostOrderIterator.h"
@@ -1480,6 +1481,7 @@ namespace IGC
14801481
void updateMetadata(Function* oldFunc, Function* newFunc);
14811482
Function* createFuncWithLoweredArgs(Function* F, GenericPointerArgs& argsInfo);
14821483
std::vector<Function*> findCandidates(CallGraph& CG);
1484+
void replaceValueInDbgInfoIntrinsic(llvm::Value* Old, llvm::Value* New, llvm::Module& M);
14831485
};
14841486
} // End anonymous namespace
14851487

@@ -1765,7 +1767,7 @@ void LowerGPCallArg::updateFunctionArgs(Function* oldFunc, Function* newFunc)
17651767
// used to directly update uses in metadata node. In case of GAS, RAUW asserts because
17661768
// addrspace used in Old/New values are different and this is interpreted as different
17671769
// 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)
17691771
{
17701772
if (Old->isUsedByMetadata())
17711773
{
@@ -1774,10 +1776,10 @@ void replaceValueInDbgInfoIntrinsic(llvm::Value* Old, llvm::Value* New, llvm::Mo
17741776
if (addrSpaceMD)
17751777
{
17761778
llvm::DIBuilder DIB(M);
1777-
std::vector<llvm::DbgInfoIntrinsic*> DbgInfoInstToDelete;
1779+
std::vector<llvm::Instruction*> instToDelete;
17781780
for (auto* User : addrSpaceMD->users())
17791781
{
1780-
if (cast<DbgInfoIntrinsic>(User))
1782+
if (isa<DbgInfoIntrinsic>(User))
17811783
{
17821784
//User->dump();
17831785
if (auto DbgV = cast<DbgValueInst>(User))
@@ -1792,12 +1794,26 @@ void replaceValueInDbgInfoIntrinsic(llvm::Value* Old, llvm::Value* New, llvm::Mo
17921794
DbgD->getVariable(), DbgD->getExpression(), DbgD->getDebugLoc().get(),
17931795
cast<llvm::Instruction>(User));
17941796
}
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));
17961812
}
17971813
}
17981814

1799-
for (auto DbgInfoInst : DbgInfoInstToDelete)
1800-
DbgInfoInst->eraseFromParent();
1815+
for (auto inst : instToDelete)
1816+
inst->eraseFromParent();
18011817
}
18021818
}
18031819
}

0 commit comments

Comments
 (0)