Skip to content

Commit c50633f

Browse files
committed
XXX
1 parent af34716 commit c50633f

File tree

1 file changed

+31
-52
lines changed

1 file changed

+31
-52
lines changed

Sources/LLVM/DIBuilder.swift

Lines changed: 31 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,14 @@ struct AnyDIType: Metadata, DIType {
486486
}
487487
}
488488

489+
public struct VariableMetadata: Metadata {
490+
internal let llvm: LLVMMetadataRef
491+
492+
public func asMetadata() -> LLVMMetadataRef {
493+
return llvm
494+
}
495+
}
496+
489497
public struct FileMetadata: Metadata {
490498
internal let llvm: LLVMMetadataRef
491499

@@ -548,27 +556,7 @@ public final class DIBuilder {
548556

549557
/// A CompileUnit provides an anchor for all debugging
550558
/// information generated during this instance of compilation.
551-
/// \param Lang Source programming language, eg.
552-
/// \c LLVMDWARFSourceLanguageC99
553-
/// \param File File info.
554-
/// \param Producer Identify the producer of debugging information
555-
/// and code. Usually this is a compiler
556-
/// version string.
557-
/// \param isOptimized A boolean flag which indicates whether optimization
558-
/// is enabled or not.
559-
/// \param Flags This string lists command line options. This
560-
/// string is directly embedded in debug info
561-
/// output which may be used by a tool
562-
/// analyzing generated debugging information.
563-
/// \param RuntimeVer This indicates runtime version for languages like
564-
/// Objective-C.
565-
/// \param SplitName The name of the file that we'll split debug info
566-
/// out into.
567-
/// \param Kind The kind of debug information to generate.
568-
/// \param DWOId The DWOId if this is a split skeleton compile unit.
569-
/// \param SplitDebugInlining Whether to emit inline debug info.
570-
/// \param DebugInfoForProfiling Whether to emit extra debug info for
571-
/// profile collection.
559+
// FIXME: DWOId
572560
public func createCompileUnit(
573561
for lang: DWARFSourceLanguage,
574562
in file: FileMetadata,
@@ -603,6 +591,26 @@ public final class DIBuilder {
603591
return DebugLocation(llvm: loc)
604592
}
605593

594+
/// Insert a new llvm.dbg.declare intrinsic call.
595+
public func insertDeclareAtEnd(for value: IRValue, with info: VariableMetadata, at loc: DebugLocation, in bb: BasicBlock, addressOps: [Int64] = []) {
596+
var ops = addressOps
597+
return ops.withUnsafeMutableBufferPointer { buf in
598+
return LLVMDIBuilderInsertDeclareAtEnd(self.llvm, value.asLLVM(), info.llvm, buf.baseAddress!, UInt32(addressOps.count), loc.llvm, bb.asLLVM())
599+
}
600+
}
601+
602+
/// Insert a new llvm.dbg.value intrinsic call.
603+
// FIXME: complex address expression?
604+
public func insertDebugValueIntrinsicAtEnd(for value: IRValue, at offset: Int, with info: VariableMetadata, at loc: DebugLocation, in bb: BasicBlock, expr: Metadata? = nil) {
605+
LLVMDIBuilderInsertDbgValueIntrinsicAtEnd(self.llvm, value.asLLVM(), UInt64(offset), info.llvm, expr?.asMetadata(), loc.llvm, bb.asLLVM())
606+
}
607+
608+
/// Insert a new llvm.dbg.value intrinsic call.
609+
// FIXME: complex address expression?
610+
public func insertDebugValueIntrinsicBefore(for value: IRValue, at offset: Int, with info: VariableMetadata, at loc: DebugLocation, in bb: BasicBlock, expr: Metadata? = nil) {
611+
LLVMDIBuilderInsertDbgValueIntrinsicBefore(self.llvm, value.asLLVM(), UInt64(offset), info.llvm, expr?.asMetadata(), loc.llvm, bb.asLLVM())
612+
}
613+
606614
/// Create a file descriptor to hold debugging information for a file.
607615
public func createFile(named name: String, in directory: String) -> FileMetadata? {
608616
guard let file = LLVMDIBuilderCreateFile(self.llvm, name, directory) else { return nil }
@@ -659,11 +667,11 @@ public final class DIBuilder {
659667

660668
/// Create a new descriptor for an auto variable. This is a local variable
661669
/// that is not a subprogram parameter.
662-
public func createAutoVariable(in scope: Scope, named name: String, in file: FileMetadata, at line: Int, type: DIType, alwaysPreserve: Bool, flags: DebugInfoFlags, aligned alignInBits: Int) -> Metadata {
670+
public func createAutoVariable(in scope: Scope, named name: String, in file: FileMetadata, at line: Int, type: DIType, alwaysPreserve: Bool, flags: DebugInfoFlags, aligned alignInBits: Int) -> VariableMetadata {
663671
guard let vari = LLVMDIBuilderCreateAutoVariable(self.llvm, scope.llvm, name, file.llvm, UInt32(line), type.asMetadata(with: self), alwaysPreserve ? 1 : 0, flags.llvm, UInt32(alignInBits)) else {
664672
fatalError()
665673
}
666-
return AnyMetadata(llvm: vari)
674+
return VariableMetadata(llvm: vari)
667675
}
668676

669677

@@ -962,35 +970,6 @@ public func LLVMDIBuilderGetOrCreateSubrange(_ Builder: LLVMDIBuilderRef!, _ Lo:
962970
/// Get a DINodeArray, create one if required.
963971
public func LLVMDIBuilderGetOrCreateArray(_ Builder: LLVMDIBuilderRef!, _ Ptr: UnsafeMutablePointer<LLVMMetadataRef?>!, _ Count: UInt32) -> LLVMMetadataRef!
964972

965-
/// Insert a new llvm.dbg.declare intrinsic call.
966-
/// \param Builder The DIBuilder.
967-
/// \param Storage LLVMValueRef of the variable
968-
/// \param VarInfo Variable's debug info descriptor.
969-
/// \param Expr A complex location expression.
970-
/// \param DL Debug info location.
971-
/// \param InsertAtEnd Location for the new intrinsic.
972-
public func LLVMDIBuilderInsertDeclareAtEnd(_ Builder: LLVMDIBuilderRef!, _ V: LLVMValueRef!, _ VarInfo: LLVMMetadataRef!, _ AddrOps: UnsafeMutablePointer<Int64>!, _ AddrOpsCount: UInt32, _ DL: LLVMMetadataRef!, _ InsertAtEnd: LLVMBasicBlockRef!) -> LLVMValueRef!
973-
974-
/// Insert a new llvm.dbg.value intrinsic call.
975-
/// \param Builder The DIBuilder.
976-
/// \param Val LLVMValueRef of the variable
977-
/// \param Offset Offset
978-
/// \param VarInfo Variable's debug info descriptor.
979-
/// \param Expr A complex location expression.
980-
/// \param DL Debug info location.
981-
/// \param InsertAtEnd Location for the new intrinsic.
982-
public func LLVMDIBuilderInsertDbgValueIntrinsicAtEnd(_ Builder: LLVMDIBuilderRef!, _ Val: LLVMValueRef!, _ Offset: UInt64, _ VarInfo: LLVMMetadataRef!, _ Expr: LLVMMetadataRef!, _ Loc: LLVMMetadataRef!, _ InsertAtEnd: LLVMBasicBlockRef!) -> LLVMValueRef!
983-
984-
/// Insert a new llvm.dbg.value intrinsic call.
985-
/// \param Builder The DIBuilder.
986-
/// \param Val LLVMValueRef of the variable
987-
/// \param Offset Offset
988-
/// \param VarInfo Variable's debug info descriptor.
989-
/// \param Expr A complex location expression.
990-
/// \param DL Debug info location.
991-
/// \param InsertBefore Location for the new intrinsic.
992-
public func LLVMDIBuilderInsertDbgValueIntrinsicBefore(_ Builder: LLVMDIBuilderRef!, _ Val: LLVMValueRef!, _ Offset: UInt64, _ VarInfo: LLVMMetadataRef!, _ Expr: LLVMMetadataRef!, _ Loc: LLVMMetadataRef!, _ InsertBefore: LLVMValueRef!) -> LLVMValueRef!
993-
994973
/// Create a single enumerator value.
995974
public func LLVMDIBuilderCreateEnumerator(_ Builder: LLVMDIBuilderRef!, _ Name: UnsafePointer<Int8>!, _ Val: Int64) -> LLVMMetadataRef!
996975

0 commit comments

Comments
 (0)