diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index acc0d92..90a4cd4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,7 +34,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - llvm: [14, 15, 16, 17, 18] + llvm: [14, 15, 16, 17, 18, 19] steps: - name: Checkout uses: actions/checkout@v4 @@ -52,6 +52,6 @@ jobs: run: go test -v -tags=llvm${{ matrix.llvm }} - name: Test default LLVM - if: matrix.llvm == 18 + if: matrix.llvm == 19 run: go test -v diff --git a/README.markdown b/README.markdown index e8b4126..3971a0b 100644 --- a/README.markdown +++ b/README.markdown @@ -4,13 +4,13 @@ This library provides bindings to a system-installed LLVM. Currently supported: - * LLVM 17, 16, 15 and 14 from [apt.llvm.org](http://apt.llvm.org/) on Debian/Ubuntu. - * LLVM 17, 16, 15 and 14 from Homebrew on macOS. - * LLVM 15 with a manually built LLVM through the `byollvm` build tag. You + * LLVM 19, 18, 17, 16, 15 and 14 from [apt.llvm.org](http://apt.llvm.org/) on Debian/Ubuntu. + * LLVM 18, 17, 16, 15 and 14 from Homebrew on macOS. + * LLVM 19 with a manually built LLVM through the `byollvm` build tag. You need to set up `CFLAGS`/`LDFLAGS` etc yourself in this case. -You can select the LLVM version using a build tag, for example `-tags=llvm14` -to use LLVM 14. +You can select the LLVM version using a build tag, for example `-tags=llvm17` +to use LLVM 17. ## Usage diff --git a/dibuilder.go b/dibuilder.go index 69e2543..8c98f96 100644 --- a/dibuilder.go +++ b/dibuilder.go @@ -610,22 +610,17 @@ func (d *DIBuilder) CreateExpression(addr []uint64) Metadata { return Metadata{C: result} } -// InsertDeclareAtEnd inserts a call to llvm.dbg.declare at the end of the -// specified basic block for the given value and associated debug metadata. -func (d *DIBuilder) InsertDeclareAtEnd(v Value, diVarInfo, expr Metadata, l DebugLoc, bb BasicBlock) Value { - loc := C.LLVMDIBuilderCreateDebugLocation( - d.m.Context().C, C.uint(l.Line), C.uint(l.Col), l.Scope.C, l.InlinedAt.C) - result := C.LLVMDIBuilderInsertDeclareAtEnd(d.ref, v.C, diVarInfo.C, expr.C, loc, bb.C) - return Value{C: result} -} - // InsertValueAtEnd inserts a call to llvm.dbg.value at the end of the // specified basic block for the given value and associated debug metadata. -func (d *DIBuilder) InsertValueAtEnd(v Value, diVarInfo, expr Metadata, l DebugLoc, bb BasicBlock) Value { +func (d *DIBuilder) InsertValueAtEnd(v Value, diVarInfo, expr Metadata, l DebugLoc, bb BasicBlock) { loc := C.LLVMDIBuilderCreateDebugLocation( d.m.Context().C, C.uint(l.Line), C.uint(l.Col), l.Scope.C, l.InlinedAt.C) - result := C.LLVMDIBuilderInsertDbgValueAtEnd(d.ref, v.C, diVarInfo.C, expr.C, loc, bb.C) - return Value{C: result} + C.LLVMDIBuilderInsertDbgValueRecordAtEnd(d.ref, v.C, diVarInfo.C, expr.C, loc, bb.C) + // Note: this returns a LLVMDbgRecordRef. Previously, InsertValueAtEnd would + // return a Value. But since the type changed, and I'd like to keep the API + // consistent across LLVM versions, I decided to drop the return value. + // There was also a InsertDeclareAtEnd, it can easily be added back if other + // packages require that method. } func (v Value) SetSubprogram(sp Metadata) { diff --git a/ir.go b/ir.go index d9699c3..7e03ec6 100644 --- a/ir.go +++ b/ir.go @@ -921,7 +921,6 @@ func AlignOf(t Type) (v Value) { v.C = C.LLVMAlignOf(t.C); return } func SizeOf(t Type) (v Value) { v.C = C.LLVMSizeOf(t.C); return } func ConstNeg(v Value) (rv Value) { rv.C = C.LLVMConstNeg(v.C); return } func ConstNSWNeg(v Value) (rv Value) { rv.C = C.LLVMConstNSWNeg(v.C); return } -func ConstNUWNeg(v Value) (rv Value) { rv.C = C.LLVMConstNUWNeg(v.C); return } func ConstNot(v Value) (rv Value) { rv.C = C.LLVMConstNot(v.C); return } func ConstAdd(lhs, rhs Value) (v Value) { v.C = C.LLVMConstAdd(lhs.C, rhs.C); return } func ConstNSWAdd(lhs, rhs Value) (v Value) { v.C = C.LLVMConstNSWAdd(lhs.C, rhs.C); return } @@ -934,17 +933,6 @@ func ConstNSWMul(lhs, rhs Value) (v Value) { v.C = C.LLVMConstNSWMul(lhs.C, rhs. func ConstNUWMul(lhs, rhs Value) (v Value) { v.C = C.LLVMConstNUWMul(lhs.C, rhs.C); return } func ConstXor(lhs, rhs Value) (v Value) { v.C = C.LLVMConstXor(lhs.C, rhs.C); return } -func ConstICmp(pred IntPredicate, lhs, rhs Value) (v Value) { - v.C = C.LLVMConstICmp(C.LLVMIntPredicate(pred), lhs.C, rhs.C) - return -} -func ConstFCmp(pred FloatPredicate, lhs, rhs Value) (v Value) { - v.C = C.LLVMConstFCmp(C.LLVMRealPredicate(pred), lhs.C, rhs.C) - return -} - -func ConstShl(lhs, rhs Value) (v Value) { v.C = C.LLVMConstShl(lhs.C, rhs.C); return } - func ConstGEP(t Type, v Value, indices []Value) (rv Value) { ptr, nvals := llvmValueRefs(indices) rv.C = C.LLVMConstGEP2(t.C, v.C, ptr, nvals) @@ -1660,12 +1648,6 @@ func (b Builder) CreateNSWNeg(v Value, name string) (rv Value) { rv.C = C.LLVMBuildNSWNeg(b.C, v.C, cname) return } -func (b Builder) CreateNUWNeg(v Value, name string) (rv Value) { - cname := C.CString(name) - defer C.free(unsafe.Pointer(cname)) - rv.C = C.LLVMBuildNUWNeg(b.C, v.C, cname) - return -} func (b Builder) CreateFNeg(v Value, name string) (rv Value) { cname := C.CString(name) defer C.free(unsafe.Pointer(cname)) diff --git a/llvm_config_linux_llvm18.go b/llvm_config_linux_llvm18.go index 8010f03..a4bbea0 100644 --- a/llvm_config_linux_llvm18.go +++ b/llvm_config_linux_llvm18.go @@ -1,4 +1,4 @@ -//go:build !byollvm && linux && !llvm14 && !llvm15 && !llvm16 && !llvm17 +//go:build !byollvm && linux && llvm18 package llvm diff --git a/llvm_config_linux_llvm19.go b/llvm_config_linux_llvm19.go new file mode 100644 index 0000000..2b274d4 --- /dev/null +++ b/llvm_config_linux_llvm19.go @@ -0,0 +1,10 @@ +//go:build !byollvm && linux && !llvm14 && !llvm15 && !llvm16 && !llvm17 && !llvm18 + +package llvm + +// #cgo CPPFLAGS: -I/usr/include/llvm-19 -I/usr/include/llvm-c-19 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS +// #cgo CXXFLAGS: -std=c++17 +// #cgo LDFLAGS: /usr/lib/llvm-19/lib/libLLVM.so +import "C" + +type run_build_sh int