Skip to content

Commit 0d8d4c4

Browse files
authored
Fix translating of compile unit (#1057)
* Fix translating of compile unit It's a patch to fix ignoring of checksum info when translating compile unit
1 parent dd9d1da commit 0d8d4c4

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

lib/SPIRV/SPIRVToLLVMDbgTran.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,10 @@ SPIRVToLLVMDbgTran::transCompileUnit(const SPIRVExtInst *DebugInst) {
126126
using namespace SPIRVDebug::Operand::CompilationUnit;
127127
assert(Ops.size() == OperandCount && "Invalid number of operands");
128128
M->addModuleFlag(llvm::Module::Max, "Dwarf Version", Ops[DWARFVersionIdx]);
129-
SPIRVExtInst *Source = BM->get<SPIRVExtInst>(Ops[SourceIdx]);
130-
SPIRVId FileId = Source->getArguments()[SPIRVDebug::Operand::Source::FileIdx];
131-
std::string File = getString(FileId);
132129
unsigned SourceLang = Ops[LanguageIdx];
133130
auto Producer = findModuleProducer();
134-
CU = Builder.createCompileUnit(SourceLang, getDIFile(File), Producer, false,
135-
"", 0);
131+
CU = Builder.createCompileUnit(SourceLang, getFile(Ops[SourceIdx]), Producer,
132+
false, "", 0);
136133
return CU;
137134
}
138135

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
; RUN: llvm-as %s -o %t.bc
2+
; RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s --check-prefix CHECK-SPIRV
3+
; RUN: llvm-spirv %t.bc -o %t.spv
4+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
5+
; RUN: llvm-dis %t.rev.bc -o %t.rev.ll
6+
; RUN: FileCheck %s --input-file %t.rev.ll --check-prefix CHECK-LLVM
7+
8+
; ModuleID = 'array-transform.bc'
9+
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024"
10+
target triple = "spir64-unknown-unknown"
11+
12+
!llvm.module.flags = !{!0}
13+
!llvm.dbg.cu = !{!1}
14+
15+
; CHECK-LLVM: !DIFile(filename: "array-transform.cpp"
16+
; CHECK-LLVM-SAME: checksumkind: CSK_MD5, checksum: "7768106c1e51aa084de0ffae6fbe50c4"
17+
; CHECK-SPIRV: String [[#ChecksumInfo:]] "//__CSK_MD5:7768106c1e51aa084de0ffae6fbe50c4"
18+
; CHECK-SPIRV: DebugSource
19+
; CHECK-SPIRV-SAME: [[#ChecksumInfo]]
20+
21+
!0 = !{i32 2, !"Debug Info Version", i32 3}
22+
!1 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !2, producer: "spirv", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !3, imports: !3)
23+
!2 = !DIFile(filename: "array-transform.cpp", directory: "D:\\path\\to", checksumkind: CSK_MD5, checksum: "7768106c1e51aa084de0ffae6fbe50c4")
24+
!3 = !{}

0 commit comments

Comments
 (0)