From 74ba46d3540ecd892d663945f7a805863859bf0a Mon Sep 17 00:00:00 2001 From: Harald van Dijk Date: Mon, 18 Dec 2023 09:50:53 +0000 Subject: [PATCH] More LLVM 18 fixups. * 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. --- modules/compiler/spirv-ll/source/builder_debug_info.cpp | 6 ++++++ modules/compiler/utils/source/barrier_regions.cpp | 5 ++++- .../compiler/vecz/source/transform/basic_mem2reg_pass.cpp | 5 ++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/compiler/spirv-ll/source/builder_debug_info.cpp b/modules/compiler/spirv-ll/source/builder_debug_info.cpp index 2bea1d11b..25f511a7a 100644 --- a/modules/compiler/spirv-ll/source/builder_debug_info.cpp +++ b/modules/compiler/spirv-ll/source/builder_debug_info.cpp @@ -994,9 +994,15 @@ llvm::Expected 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(val), llvm::dwarf::DW_TAG_variable); +#else return getDIBuilder(op).createStaticMemberType(scope, *name, file, op->Line(), base_ty, flags, cast(val)); +#endif } auto size_or_error = getConstantIntValue(op->Size()); diff --git a/modules/compiler/utils/source/barrier_regions.cpp b/modules/compiler/utils/source/barrier_regions.cpp index 133c2329e..1b6c13429 100644 --- a/modules/compiler/utils/source/barrier_regions.cpp +++ b/modules/compiler/utils/source/barrier_regions.cpp @@ -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 DbgIntrinsics; + findDbgDeclares(DbgIntrinsics, member.value); +#elif LLVM_VERSION_GREATER_EQUAL(17, 0) auto DbgIntrinsics = FindDbgDeclareUses(member.value); #else auto DbgIntrinsics = FindDbgAddrUses(member.value); diff --git a/modules/compiler/vecz/source/transform/basic_mem2reg_pass.cpp b/modules/compiler/vecz/source/transform/basic_mem2reg_pass.cpp index 1f662ffe7..b5559151f 100644 --- a/modules/compiler/vecz/source/transform/basic_mem2reg_pass.cpp +++ b/modules/compiler/vecz/source/transform/basic_mem2reg_pass.cpp @@ -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 DbgIntrinsics; + findDbgDeclares(DbgIntrinsics, Alloca); +#elif LLVM_VERSION_GREATER_EQUAL(17, 0) auto DbgIntrinsics = FindDbgDeclareUses(Alloca); #else auto DbgIntrinsics = FindDbgAddrUses(Alloca);