Skip to content

Commit a2247c5

Browse files
committed
Additional fixes
1 parent a3682f7 commit a2247c5

File tree

1 file changed

+6
-27
lines changed

1 file changed

+6
-27
lines changed

llvm/lib/Target/SPIRV/SPIRVEmitNonSemanticDI.cpp

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "SPIRVGlobalRegistry.h"
44
#include "SPIRVRegisterInfo.h"
55
#include "SPIRVTargetMachine.h"
6+
#include "llvm/ADT/SmallString.h"
67
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
78
#include "llvm/CodeGen/MachineBasicBlock.h"
89
#include "llvm/CodeGen/MachineFunction.h"
@@ -66,7 +67,7 @@ bool SPIRVEmitNonSemanticDI::emitGlobalDI(MachineFunction &MF) {
6667

6768
// Required variables to get from metadata search
6869
LLVMContext *Context;
69-
std::string FilePath;
70+
SmallString<128> FilePath;
7071
unsigned SourceLanguage = 0;
7172
int64_t DwarfVersion = 0;
7273
int64_t DebugInfoVersion = 0;
@@ -84,9 +85,7 @@ bool SPIRVEmitNonSemanticDI::emitGlobalDI(MachineFunction &MF) {
8485
for (const auto *Op : DbgCu->operands()) {
8586
if (const auto *CompileUnit = dyn_cast<DICompileUnit>(Op)) {
8687
DIFile *File = CompileUnit->getFile();
87-
FilePath = ((File->getDirectory() + sys::path::get_separator() +
88-
File->getFilename()))
89-
.str();
88+
sys::path::append(FilePath, File->getDirectory(), File->getFilename());
9089
SourceLanguage = CompileUnit->getSourceLanguage();
9190
break;
9291
}
@@ -150,31 +149,11 @@ bool SPIRVEmitNonSemanticDI::emitGlobalDI(MachineFunction &MF) {
150149
// Convert DwarfVersion, DebugInfo and SourceLanguage integers to OpConstant
151150
// instructions required by DebugCompilationUnit
152151
const Register DwarfVersionReg =
153-
MRI.createVirtualRegister(&SPIRV::IDRegClass);
154-
MRI.setType(DwarfVersionReg, LLT::scalar(32));
155-
MIRBuilder.buildInstr(SPIRV::OpConstantI)
156-
.addDef(DwarfVersionReg)
157-
.addUse(GR->getSPIRVTypeID(I32Ty))
158-
.addImm(DwarfVersion);
159-
GR->assignSPIRVTypeToVReg(I32Ty, DwarfVersionReg, MF);
160-
152+
GR->buildConstantInt(DwarfVersion, MIRBuilder, I32Ty, false);
161153
const Register DebugInfoVersionReg =
162-
MRI.createVirtualRegister(&SPIRV::IDRegClass);
163-
MRI.setType(DebugInfoVersionReg, LLT::scalar(32));
164-
MIRBuilder.buildInstr(SPIRV::OpConstantI)
165-
.addDef(DebugInfoVersionReg)
166-
.addUse(GR->getSPIRVTypeID(I32Ty))
167-
.addImm(DebugInfoVersion);
168-
GR->assignSPIRVTypeToVReg(I32Ty, DebugInfoVersionReg, MF);
169-
154+
GR->buildConstantInt(DebugInfoVersion, MIRBuilder, I32Ty, false);
170155
const Register SourceLanguageReg =
171-
MRI.createVirtualRegister(&SPIRV::IDRegClass);
172-
MRI.setType(SourceLanguageReg, LLT::scalar(32));
173-
MIRBuilder.buildInstr(SPIRV::OpConstantI)
174-
.addDef(SourceLanguageReg)
175-
.addUse(GR->getSPIRVTypeID(I32Ty))
176-
.addImm(SourceLanguage);
177-
GR->assignSPIRVTypeToVReg(I32Ty, SourceLanguageReg, MF);
156+
GR->buildConstantInt(SourceLanguage, MIRBuilder, I32Ty, false);
178157

179158
// Emit DebugCompilationUnit
180159
const Register DebugCompUnitResIdReg =

0 commit comments

Comments
 (0)