3
3
#include " SPIRVGlobalRegistry.h"
4
4
#include " SPIRVRegisterInfo.h"
5
5
#include " SPIRVTargetMachine.h"
6
+ #include " llvm/ADT/SmallString.h"
6
7
#include " llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
7
8
#include " llvm/CodeGen/MachineBasicBlock.h"
8
9
#include " llvm/CodeGen/MachineFunction.h"
@@ -66,7 +67,7 @@ bool SPIRVEmitNonSemanticDI::emitGlobalDI(MachineFunction &MF) {
66
67
67
68
// Required variables to get from metadata search
68
69
LLVMContext *Context;
69
- std::string FilePath;
70
+ SmallString< 128 > FilePath;
70
71
unsigned SourceLanguage = 0 ;
71
72
int64_t DwarfVersion = 0 ;
72
73
int64_t DebugInfoVersion = 0 ;
@@ -84,9 +85,7 @@ bool SPIRVEmitNonSemanticDI::emitGlobalDI(MachineFunction &MF) {
84
85
for (const auto *Op : DbgCu->operands ()) {
85
86
if (const auto *CompileUnit = dyn_cast<DICompileUnit>(Op)) {
86
87
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 ());
90
89
SourceLanguage = CompileUnit->getSourceLanguage ();
91
90
break ;
92
91
}
@@ -150,31 +149,11 @@ bool SPIRVEmitNonSemanticDI::emitGlobalDI(MachineFunction &MF) {
150
149
// Convert DwarfVersion, DebugInfo and SourceLanguage integers to OpConstant
151
150
// instructions required by DebugCompilationUnit
152
151
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 );
161
153
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 );
170
155
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 );
178
157
179
158
// Emit DebugCompilationUnit
180
159
const Register DebugCompUnitResIdReg =
0 commit comments