Skip to content

Commit 91e5e73

Browse files
pratikasharigcbot
authored andcommitted
Address review comment.
1 parent bcf67bf commit 91e5e73

File tree

5 files changed

+54
-4
lines changed

5 files changed

+54
-4
lines changed

IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,6 @@ bool PrivateMemoryResolution::resolveAllocaInstructions(bool privateOnStack)
814814

815815
// Construct an empty DebugLoc.
816816
IF_DEBUG_INFO(DebugLoc entryDebugLoc);
817-
// Assign with the function location if available.
818-
IF_DEBUG_INFO_IF(DISubprogram *subprogram = m_currFunction->getSubprogram(), entryDebugLoc = DebugLoc::get(subprogram->getLine(), 0, subprogram););
819817
IF_DEBUG_INFO(entryBuilder.SetCurrentDebugLocation(entryDebugLoc));
820818

821819
if (privateOnStack)
@@ -922,7 +920,7 @@ bool PrivateMemoryResolution::resolveAllocaInstructions(bool privateOnStack)
922920
// correctly. So instead, we set DebugLoc for the instructions generated by lowering
923921
// alloca to mark that they are part of the prologue.
924922
// Note: As per Amjad, later LLVM version has a fix for this in llvm/lib/Transforms/Utils/InlineFunction.cpp.
925-
IF_DEBUG_INFO(builder.SetCurrentDebugLocation(entryDebugLoc));
923+
IF_DEBUG_INFO(builder.SetCurrentDebugLocation(pAI->getDebugLoc()));
926924

927925
// Get buffer information from the analysis
928926
unsigned int scalarBufferOffset = m_ModAllocaInfo->getConstBufferOffset(pAI);

IGC/DebugInfo/DwarfDebug.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,29 @@ namespace IGC
634634

635635
// Store label for each %ip
636636
llvm::DenseMap<unsigned int, llvm::MCSymbol*> LabelsBeforeIp;
637+
638+
// function, inlinedAt
639+
llvm::DenseMap<llvm::DISubprogram*, llvm::SmallPtrSet <llvm::DILocation*, 5>> prologueEnd;
637640
public:
641+
bool prologueEndExists(llvm::DISubprogram* sp, llvm::DILocation* dl, bool add)
642+
{
643+
auto it = prologueEnd.find(sp);
644+
if (it == prologueEnd.end())
645+
{
646+
if (add)
647+
prologueEnd[sp].insert(dl);
648+
return false;
649+
}
650+
651+
if (it->second.find(dl) != it->second.end())
652+
return true;
653+
654+
if (add)
655+
it->second.insert(dl);
656+
657+
return false;
658+
}
659+
638660
bool isStmtExists(unsigned int line, llvm::DILocation* inlinedAt, bool add)
639661
{
640662
auto it = isStmtSet.find(line);

IGC/DebugInfo/VISADebugEmitter.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ IN THE SOFTWARE.
4848
#include "DwarfDebug.hpp"
4949
#include "StreamEmitter.hpp"
5050
#include "VISAModule.hpp"
51+
#include "GenISAIntrinsics/GenIntrinsicInst.h"
5152

5253
#include "Probe/Assertion.h"
5354
#include "secure_mem.h"
@@ -232,7 +233,8 @@ std::vector<char> DebugEmitter::Finalize(bool finalize, DbgDecoder* decodedDbg)
232233
}
233234
}
234235

235-
if (instIt != VISAIndexToInst.end())
236+
if (instIt != VISAIndexToInst.end() &&
237+
m_pVISAModule->IsExecutableInst(*instIt->second))
236238
{
237239
auto loc = instIt->second->getDebugLoc();
238240
if (loc)
@@ -247,6 +249,12 @@ std::vector<char> DebugEmitter::Finalize(bool finalize, DbgDecoder* decodedDbg)
247249
{
248250
Flags |= DWARF2_FLAG_IS_STMT;
249251
}
252+
253+
if (!m_pDwarfDebug->prologueEndExists(loc.get()->getScope()->getSubprogram(),
254+
loc.getInlinedAt(), true))
255+
{
256+
Flags |= DWARF2_FLAG_PROLOGUE_END;
257+
}
250258
m_pStreamEmitter->EmitDwarfLocDirective(src, loc.getLine(), loc.getCol(), Flags, 0, 0, scope->getFilename());
251259

252260
prevSrcLoc = loc;

IGC/DebugInfo/VISAModule.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,21 @@ const std::string& VISAModule::GetTargetTriple() const
239239
return m_triple;
240240
}
241241

242+
bool VISAModule::IsExecutableInst(const llvm::Instruction& inst)
243+
{
244+
// Return false if inst is dbg info intrinsic or if it is
245+
// catch all intrinsic. In both of these cases, we dont want
246+
// to emit associated debug loc since there is no machine
247+
// code generated for them.
248+
if (IsCatchAllIntrinsic(&inst))
249+
return false;
250+
251+
if (llvm::isa<DbgInfoIntrinsic>(inst))
252+
return false;
253+
254+
return true;
255+
}
256+
242257
void VISAModule::buildDirectElfMaps(const IGC::DbgDecoder& VD)
243258
{
244259
const auto* co = getCompileUnit(VD);
@@ -248,6 +263,10 @@ void VISAModule::buildDirectElfMaps(const IGC::DbgDecoder& VD)
248263
{
249264
const Instruction* pInst = *II;
250265

266+
// store VISA mapping only if pInst generates Gen code
267+
if (!IsExecutableInst(*pInst))
268+
continue;
269+
251270
InstInfoMap::const_iterator itr = m_instInfoMap.find(pInst);
252271
if (itr == m_instInfoMap.end())
253272
continue;

IGC/DebugInfo/VISAModule.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,9 @@ namespace IGC
439439
return false;
440440
}
441441

442+
/// @brief return false if inst is a placeholder instruction
443+
bool IsExecutableInst(const llvm::Instruction& inst);
444+
442445
bool isDirectElfInput = false;
443446
// Store first VISA index->llvm::Instruction mapping
444447
std::map<unsigned int, const llvm::Instruction*> VISAIndexToInst;

0 commit comments

Comments
 (0)