Exemplo n.º 1
0
Arquivo: debug.go Projeto: hinike/llgo
// Finalize must be called after all compilation units are translated,
// generating the final debug metadata for the module.
func (d *DIBuilder) Finalize() {
	d.module.AddNamedMetadataOperand(
		"llvm.module.flags",
		llvm.MDNode([]llvm.Value{
			llvm.ConstInt(llvm.Int32Type(), 2, false), // Warn on mismatch
			llvm.MDString("Dwarf Version"),
			llvm.ConstInt(llvm.Int32Type(), 4, false),
		}),
	)
	d.module.AddNamedMetadataOperand(
		"llvm.module.flags",
		llvm.MDNode([]llvm.Value{
			llvm.ConstInt(llvm.Int32Type(), 1, false), // Error on mismatch
			llvm.MDString("Debug Info Version"),
			llvm.ConstInt(llvm.Int32Type(), 1, false),
		}),
	)
	d.builder.Finalize()
}
Exemplo n.º 2
0
func (fr *frame) setBranchWeightMetadata(br llvm.Value, trueweight, falseweight uint64) {
	mdprof := llvm.MDKindID("prof")

	mdnode := llvm.MDNode([]llvm.Value{
		llvm.MDString("branch_weights"),
		llvm.ConstInt(llvm.Int32Type(), trueweight, false),
		llvm.ConstInt(llvm.Int32Type(), falseweight, false),
	})

	br.SetMetadata(mdprof, mdnode)
}
Exemplo n.º 3
0
Arquivo: debug.go Projeto: hinike/llgo
// SetLocation sets the current debug location.
func (d *DIBuilder) SetLocation(b llvm.Builder, pos token.Pos) {
	if !pos.IsValid() {
		return
	}
	position := d.fset.Position(pos)
	d.lb = llvm.Value{nil}
	if position.Filename != d.fnFile && position.Filename != "" {
		// This can happen rarely, e.g. in init functions.
		diFile := d.builder.CreateFile(d.remapFilePath(position.Filename), "")
		d.lb = d.builder.CreateLexicalBlockFile(d.scope(), diFile, 0)
	}
	b.SetCurrentDebugLocation(llvm.MDNode([]llvm.Value{
		llvm.ConstInt(llvm.Int32Type(), uint64(position.Line), false),
		llvm.ConstInt(llvm.Int32Type(), uint64(position.Column), false),
		d.scope(),
		llvm.Value{},
	}))
}
Exemplo n.º 4
0
Arquivo: debug.go Projeto: hinike/llgo
func (d *DIBuilder) descriptorNamed(t *types.Named) llvm.Value {
	// Create a placeholder for the named type, to terminate cycles.
	placeholder := llvm.MDNode(nil)
	d.types.Set(t, placeholder)
	var diFile llvm.Value
	var line int
	if file := d.fset.File(t.Obj().Pos()); file != nil {
		line = file.Line(t.Obj().Pos())
		diFile = d.getFile(file)
	}
	typedef := d.builder.CreateTypedef(llvm.DITypedef{
		Type: d.DIType(t.Underlying()),
		Name: t.Obj().Name(),
		File: diFile,
		Line: line,
	})
	placeholder.ReplaceAllUsesWith(typedef)
	return typedef
}