Skip to content

Commit

Permalink
More LLVM 18 fixups.
Browse files Browse the repository at this point in the history
* FindDbgDeclareUses got refactored, we have to call findDbgDeclares.
* DIBuilder::createStaticMemberType takes a DWARF tag now. Since we are
  processing a DebugTypeMember, we know it is always a data member and
  can set the tag to DW_TAG_variable.
  • Loading branch information
hvdijk committed Dec 18, 2023
1 parent 6c335c1 commit 74ba46d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions modules/compiler/spirv-ll/source/builder_debug_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -994,9 +994,15 @@ llvm::Expected<llvm::MDNode *> DebugInfoBuilder::translate(
getIDAsStr(op->IdResult(), &module) +
" is not an OpConstant");
}
#if LLVM_VERSION_GREATER_EQUAL(18, 0)
return getDIBuilder(op).createStaticMemberType(
scope, *name, file, op->Line(), base_ty, flags,
cast<llvm::Constant>(val), llvm::dwarf::DW_TAG_variable);
#else
return getDIBuilder(op).createStaticMemberType(scope, *name, file,
op->Line(), base_ty, flags,
cast<llvm::Constant>(val));
#endif
}

auto size_or_error = getConstantIntValue(op->Size());
Expand Down
5 changes: 4 additions & 1 deletion modules/compiler/utils/source/barrier_regions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,10 @@ void compiler::utils::Barrier::MakeLiveVariableMemType() {

// Check if the alloca has a debug info source variable attached. If
// so record this and the matching byte offset into the struct.
#if LLVM_VERSION_GREATER_EQUAL(17, 0)
#if LLVM_VERSION_GREATER_EQUAL(18, 0)
SmallVector<DbgDeclareInst *, 1> DbgIntrinsics;
findDbgDeclares(DbgIntrinsics, member.value);
#elif LLVM_VERSION_GREATER_EQUAL(17, 0)
auto DbgIntrinsics = FindDbgDeclareUses(member.value);
#else
auto DbgIntrinsics = FindDbgAddrUses(member.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ bool BasicMem2RegPass::promoteAlloca(AllocaInst *Alloca) const {
StoredValue = Store->getValueOperand();
ToDelete.push_back(Store);
DIBuilder DIB(*Alloca->getModule(), /*AllowUnresolved*/ false);
#if LLVM_VERSION_GREATER_EQUAL(17, 0)
#if LLVM_VERSION_GREATER_EQUAL(18, 0)
SmallVector<DbgDeclareInst *, 1> DbgIntrinsics;
findDbgDeclares(DbgIntrinsics, Alloca);
#elif LLVM_VERSION_GREATER_EQUAL(17, 0)
auto DbgIntrinsics = FindDbgDeclareUses(Alloca);
#else
auto DbgIntrinsics = FindDbgAddrUses(Alloca);
Expand Down

0 comments on commit 74ba46d

Please sign in to comment.