[K/N] Avoid string copying when setting up bridge debug info.
The name of the function was copied at least 4 times. This reduces a 56 seconds codegen phase in a non-optimized build by 2 seconds.
This commit is contained in:
+3
-6
@@ -275,20 +275,17 @@ internal fun setupBridgeDebugInfo(generationState: NativeGenerationState, functi
|
|||||||
val file = debugInfo.compilerGeneratedFile
|
val file = debugInfo.compilerGeneratedFile
|
||||||
|
|
||||||
// TODO: can we share the scope among all bridges?
|
// TODO: can we share the scope among all bridges?
|
||||||
val scope: DIScopeOpaqueRef = DICreateFunction(
|
val scope: DIScopeOpaqueRef = DICreateBridgeFunction(
|
||||||
builder = debugInfo.builder,
|
builder = debugInfo.builder,
|
||||||
scope = file.reinterpret(),
|
scope = file.reinterpret(),
|
||||||
name = function.name,
|
function = function,
|
||||||
linkageName = function.name,
|
|
||||||
file = file,
|
file = file,
|
||||||
lineNo = 0,
|
lineNo = 0,
|
||||||
type = debugInfo.subroutineType(generationState.runtime.targetData, emptyList()), // TODO: use proper type.
|
type = debugInfo.subroutineType(generationState.runtime.targetData, emptyList()), // TODO: use proper type.
|
||||||
isLocal = 0,
|
isLocal = 0,
|
||||||
isDefinition = 1,
|
isDefinition = 1,
|
||||||
scopeLine = 0
|
scopeLine = 0
|
||||||
)!!.also {
|
)!!.reinterpret()
|
||||||
DIFunctionAddSubprogram(function, it)
|
|
||||||
}.reinterpret()
|
|
||||||
|
|
||||||
return LocationInfo(scope, 1, 0)
|
return LocationInfo(scope, 1, 0)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,11 +81,11 @@ DIModuleRef DICreateModule(DIBuilderRef builder, DIScopeOpaqueRef scope,
|
|||||||
return llvm::wrap(llvm::unwrap(builder)->createModule(llvm::unwrap(scope), name, configurationMacro, includePath, iSysRoot));
|
return llvm::wrap(llvm::unwrap(builder)->createModule(llvm::unwrap(scope), name, configurationMacro, includePath, iSysRoot));
|
||||||
}
|
}
|
||||||
|
|
||||||
DISubprogramRef DICreateFunction(DIBuilderRef builderRef, DIScopeOpaqueRef scope,
|
static DISubprogramRef DICreateFunctionShared(DIBuilderRef builderRef, DIScopeOpaqueRef scope,
|
||||||
const char* name, const char *linkageName,
|
llvm::StringRef name, llvm::StringRef linkageName,
|
||||||
DIFileRef file, unsigned lineNo,
|
DIFileRef file, unsigned lineNo,
|
||||||
DISubroutineTypeRef type, int isLocal,
|
DISubroutineTypeRef type, int isLocal,
|
||||||
int isDefinition, unsigned scopeLine) {
|
int isDefinition, unsigned scopeLine) {
|
||||||
auto builder = llvm::unwrap(builderRef);
|
auto builder = llvm::unwrap(builderRef);
|
||||||
auto subprogram = builder->createFunction(llvm::unwrap(scope),
|
auto subprogram = builder->createFunction(llvm::unwrap(scope),
|
||||||
name,
|
name,
|
||||||
@@ -102,6 +102,26 @@ DISubprogramRef DICreateFunction(DIBuilderRef builderRef, DIScopeOpaqueRef scope
|
|||||||
return llvm::wrap(subprogram);
|
return llvm::wrap(subprogram);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DISubprogramRef DICreateFunction(DIBuilderRef builderRef, DIScopeOpaqueRef scope,
|
||||||
|
const char* name, const char *linkageName,
|
||||||
|
DIFileRef file, unsigned lineNo,
|
||||||
|
DISubroutineTypeRef type, int isLocal,
|
||||||
|
int isDefinition, unsigned scopeLine) {
|
||||||
|
return DICreateFunctionShared(builderRef, scope, name, linkageName, file, lineNo, type, isLocal, isDefinition, scopeLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
DISubprogramRef DICreateBridgeFunction(DIBuilderRef builderRef, DIScopeOpaqueRef scope,
|
||||||
|
LLVMValueRef function,
|
||||||
|
DIFileRef file, unsigned lineNo,
|
||||||
|
DISubroutineTypeRef type, int isLocal,
|
||||||
|
int isDefinition, unsigned scopeLine) {
|
||||||
|
auto fn = llvm::cast<llvm::Function>(llvm::unwrap(function));
|
||||||
|
auto name = fn->getName();
|
||||||
|
auto subprogram = DICreateFunctionShared(builderRef, scope, name, name, file, lineNo, type, isLocal, isDefinition, scopeLine);
|
||||||
|
fn->setSubprogram(llvm::unwrap(subprogram));
|
||||||
|
return subprogram;
|
||||||
|
}
|
||||||
|
|
||||||
DIScopeOpaqueRef DICreateLexicalBlockFile(DIBuilderRef builderRef, DIScopeOpaqueRef scopeRef, DIFileRef fileRef) {
|
DIScopeOpaqueRef DICreateLexicalBlockFile(DIBuilderRef builderRef, DIScopeOpaqueRef scopeRef, DIFileRef fileRef) {
|
||||||
return llvm::wrap(llvm::unwrap(builderRef)->createLexicalBlockFile(llvm::unwrap(scopeRef), llvm::unwrap(fileRef)));
|
return llvm::wrap(llvm::unwrap(builderRef)->createLexicalBlockFile(llvm::unwrap(scopeRef), llvm::unwrap(fileRef)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,12 @@ DISubprogramRef DICreateFunction(DIBuilderRef builder, DIScopeOpaqueRef scope,
|
|||||||
DISubroutineTypeRef type, int isLocal,
|
DISubroutineTypeRef type, int isLocal,
|
||||||
int isDefinition, unsigned scopeLine);
|
int isDefinition, unsigned scopeLine);
|
||||||
|
|
||||||
|
DISubprogramRef DICreateBridgeFunction(DIBuilderRef builder, DIScopeOpaqueRef scope,
|
||||||
|
LLVMValueRef function,
|
||||||
|
DIFileRef file, unsigned lineNo,
|
||||||
|
DISubroutineTypeRef type, int isLocal,
|
||||||
|
int isDefinition, unsigned scopeLine);
|
||||||
|
|
||||||
DISubroutineTypeRef DICreateSubroutineType(DIBuilderRef builder,
|
DISubroutineTypeRef DICreateSubroutineType(DIBuilderRef builder,
|
||||||
DITypeOpaqueRef* types,
|
DITypeOpaqueRef* types,
|
||||||
unsigned typesCount);
|
unsigned typesCount);
|
||||||
|
|||||||
Reference in New Issue
Block a user