This is an archive of the discontinued LLVM Phabricator instance.

Go binding: Add GetCurrentDebugLocation to obtain debug location from builder
ClosedPublic

Authored by rhysd on Mar 27 2017, 10:55 PM.

Details

Summary

Currently Go binding only has SetCurrentDebugLocation method.
I added GetCurrentDebugLocation method to IRBuilder instance.

I added this because I want to save current debug location, change debug location temporary and restore the saved one finally.
This is useful when source location jumps and goes back after while LLVM IR generation.

I also added tests for this to ir_test.go.
I confirmed that all test passed with this patch based on r298890

Diff Detail

Repository
rL LLVM

Event Timeline

rhysd created this revision.Mar 27 2017, 10:55 PM
axw accepted this revision.Mar 29 2017, 5:24 PM

LGTM

This revision is now accepted and ready to land.Mar 29 2017, 5:24 PM
axw requested changes to this revision.EditedMar 29 2017, 7:29 PM

Actually, I've just run the tests and it's asserting:

FAIL: LLVM :: Bindings/Go/go.test (1 of 1)
******************** TEST 'LLVM :: Bindings/Go/go.test' FAILED ********************
Script:
--
/home/andrew/code/src/llvm.org/build/./bin/llvm-go go=/usr/lib/go-1.7/bin/go test llvm.org/llvm/bindings/go/llvm
--
Exit Code: 1

Command Output (stdout):
--
llvm.test: /home/andrew/code/src/llvm.org/llvm/lib/IR/DIBuilder.cpp:45: void llvm::DIBuilder::finalize(): Assertion `!AllowUnresolvedNodes && "creating type nodes without a CU is not supported"' failed.
SIGABRT: abort
PC=0x7f0997eea428 m=0
signal arrived during cgo execution

goroutine 7 [syscall, locked to thread]:
runtime.cgocall(0x111f6f0, 0xc42002bdb8, 0x0)
        /usr/lib/go-1.7/src/runtime/cgocall.go:131 +0x110 fp=0xc42002bd88 sp=0xc42002bd48
llvm.org/llvm/bindings/go/llvm._Cfunc_LLVMDIBuilderFinalize(0x5031680)
        ??:0 +0x41 fp=0xc42002bdb8 sp=0xc42002bd88
llvm.org/llvm/bindings/go/llvm.(*DIBuilder).Finalize(0xc42000c810)
        /tmp/lit_tmp_tlz1QF/gopath176582211/src/llvm.org/llvm/bindings/go/llvm/dibuilder.go:109 +0x78 fp=0xc42002be00 sp=0xc42002bdb8
llvm.org/llvm/bindings/go/llvm.TestDebugLoc.func1(0xc42000c810)
        /tmp/lit_tmp_tlz1QF/gopath176582211/src/llvm.org/llvm/bindings/go/llvm/ir_test.go:110 +0x2b fp=0xc42002be18 sp=0xc42002be00
llvm.org/llvm/bindings/go/llvm.TestDebugLoc(0xc42007e300)
        /tmp/lit_tmp_tlz1QF/gopath176582211/src/llvm.org/llvm/bindings/go/llvm/ir_test.go:137 +0x421 fp=0xc42002bf88 sp=0xc42002be18
testing.tRunner(0xc42007e300, 0x2cd1ab0)
        /usr/lib/go-1.7/src/testing/testing.go:610 +0x81 fp=0xc42002bfb0 sp=0xc42002bf88
runtime.goexit()
        /usr/lib/go-1.7/src/runtime/asm_amd64.s:2086 +0x1 fp=0xc42002bfb8 sp=0xc42002bfb0
created by testing.(*T).Run
        /usr/lib/go-1.7/src/testing/testing.go:646 +0x2ec

goroutine 1 [chan receive]:
testing.(*T).Run(0xc42007e0c0, 0x2cc2f5d, 0xc, 0x2cd1ab0, 0xc42004fd01)
        /usr/lib/go-1.7/src/testing/testing.go:647 +0x316
testing.RunTests.func1(0xc42007e0c0)
        /usr/lib/go-1.7/src/testing/testing.go:793 +0x6d
testing.tRunner(0xc42007e0c0, 0xc42004fe20)
        /usr/lib/go-1.7/src/testing/testing.go:610 +0x81
testing.RunTests(0x2cd1ad8, 0x489b1e0, 0x4, 0x4, 0x104e9e8)
        /usr/lib/go-1.7/src/testing/testing.go:799 +0x2f5
testing.(*M).Run(0xc42004fee8, 0x10c745d)
        /usr/lib/go-1.7/src/testing/testing.go:743 +0x85
main.main()
        llvm.org/llvm/bindings/go/llvm/_test/_testmain.go:60 +0xc6

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        /usr/lib/go-1.7/src/runtime/asm_amd64.s:2086 +0x1

rax    0x0
rbx    0x7f099936c000
rcx    0x7f0997eea428
rdx    0x6
rdi    0x7cc3
rsi    0x7cc3
rbp    0x3b37a88
rsp    0x7ffd911fdae8
r8     0xfefefefefefefeff
r9     0x1
r10    0x8
r11    0x206
r12    0x2d
r13    0x3b38ee0
r14    0xc
r15    0x3
rip    0x7f0997eea428
rflags 0x206
cs     0x33
fs     0x0
gs     0x0
FAIL    llvm.org/llvm/bindings/go/llvm  0.066s
This revision now requires changes to proceed.Mar 29 2017, 7:29 PM

Oh, tests passed because I built LLVM with release config (w/o assertions). I'll try debug config and fix the failure.

rhysd updated this revision to Diff 93494.Mar 30 2017, 9:37 AM
rhysd edited edge metadata.

I addressed the issue. (I incorrectly called finalizer)

rhysd added a comment.Mar 30 2017, 9:38 AM

I confirmed that all tests passed with enabling assertions.

axw accepted this revision.Mar 30 2017, 10:09 PM

Thanks.

This revision is now accepted and ready to land.Mar 30 2017, 10:09 PM
This revision was automatically updated to reflect the committed changes.

Thank you so much for quick review, axw ๐Ÿ˜Š