Skip to content

Commit 9dca92d

Browse files
committed
Use LLVM 19 instead of LLVM 18
1 parent aaff3eb commit 9dca92d

10 files changed

+55
-43
lines changed

.github/workflows/test.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: macos-latest
1111
strategy:
1212
matrix:
13-
llvm: [14, 15, 16, 17, 18]
13+
llvm: [14, 15, 16, 17, 18, 19]
1414
steps:
1515
- name: Checkout
1616
uses: actions/checkout@v4
@@ -27,14 +27,14 @@ jobs:
2727
run:
2828
go test -v -tags=llvm${{ matrix.llvm }}
2929
- name: Test default LLVM
30-
if: matrix.llvm == 18
30+
if: matrix.llvm == 19
3131
run:
3232
go test -v
3333
test-linux:
3434
runs-on: ubuntu-20.04
3535
strategy:
3636
matrix:
37-
llvm: [14, 15, 16, 17, 18]
37+
llvm: [14, 15, 16, 17, 18, 19]
3838
steps:
3939
- name: Checkout
4040
uses: actions/checkout@v4
@@ -52,6 +52,6 @@ jobs:
5252
run:
5353
go test -v -tags=llvm${{ matrix.llvm }}
5454
- name: Test default LLVM
55-
if: matrix.llvm == 18
55+
if: matrix.llvm == 19
5656
run:
5757
go test -v

README.markdown

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ This library provides bindings to a system-installed LLVM.
44

55
Currently supported:
66

7-
* LLVM 17, 16, 15 and 14 from [apt.llvm.org](http://apt.llvm.org/) on Debian/Ubuntu.
8-
* LLVM 17, 16, 15 and 14 from Homebrew on macOS.
9-
* LLVM 15 with a manually built LLVM through the `byollvm` build tag. You
7+
* LLVM 19, 18, 17, 16, 15 and 14 from [apt.llvm.org](http://apt.llvm.org/) on Debian/Ubuntu.
8+
* LLVM 19, 18, 17, 16, 15 and 14 from Homebrew on macOS.
9+
* LLVM 19 with a manually built LLVM through the `byollvm` build tag. You
1010
need to set up `CFLAGS`/`LDFLAGS` etc yourself in this case.
1111

12-
You can select the LLVM version using a build tag, for example `-tags=llvm14`
13-
to use LLVM 14.
12+
You can select the LLVM version using a build tag, for example `-tags=llvm17`
13+
to use LLVM 17.
1414

1515
## Usage
1616

backports.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,17 @@ LLVMMemoryBufferRef LLVMGoWriteThinLTOBitcodeToMemoryBuffer(LLVMModuleRef M) {
4848
#endif
4949
return llvm::wrap(llvm::MemoryBuffer::getMemBufferCopy(OS.str()).release());
5050
}
51+
52+
void LLVMGoDIBuilderInsertDbgValueRecordAtEnd(
53+
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
54+
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block) {
55+
#if LLVM_VERSION_MAJOR >= 19
56+
// Note: this returns a LLVMDbgRecordRef. Previously, InsertValueAtEnd would
57+
// return a Value. But since the type changed, and I'd like to keep the API
58+
// consistent across LLVM versions, I decided to drop the return value.
59+
LLVMDIBuilderInsertDbgValueRecordAtEnd(Builder, Val, VarInfo, Expr, DebugLoc, Block);
60+
#else
61+
// Old llvm.dbg.* API.
62+
LLVMDIBuilderInsertDbgValueAtEnd(Builder, Val, VarInfo, Expr, DebugLoc, Block);
63+
#endif
64+
}

backports.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ void LLVMGlobalObjectAddMetadata(LLVMValueRef objValue, unsigned KindID, LLVMMet
1010

1111
LLVMMemoryBufferRef LLVMGoWriteThinLTOBitcodeToMemoryBuffer(LLVMModuleRef M);
1212

13-
LLVMMetadataRef LLVMGoDIBuilderCreateExpression(LLVMDIBuilderRef Builder,
14-
uint64_t *Addr, size_t Length);
13+
void LLVMGoDIBuilderInsertDbgValueRecordAtEnd(
14+
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
15+
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
1516

1617
#ifdef __cplusplus
1718
}

dibuilder.go

+2-12
Original file line numberDiff line numberDiff line change
@@ -610,22 +610,12 @@ func (d *DIBuilder) CreateExpression(addr []uint64) Metadata {
610610
return Metadata{C: result}
611611
}
612612

613-
// InsertDeclareAtEnd inserts a call to llvm.dbg.declare at the end of the
614-
// specified basic block for the given value and associated debug metadata.
615-
func (d *DIBuilder) InsertDeclareAtEnd(v Value, diVarInfo, expr Metadata, l DebugLoc, bb BasicBlock) Value {
616-
loc := C.LLVMDIBuilderCreateDebugLocation(
617-
d.m.Context().C, C.uint(l.Line), C.uint(l.Col), l.Scope.C, l.InlinedAt.C)
618-
result := C.LLVMDIBuilderInsertDeclareAtEnd(d.ref, v.C, diVarInfo.C, expr.C, loc, bb.C)
619-
return Value{C: result}
620-
}
621-
622613
// InsertValueAtEnd inserts a call to llvm.dbg.value at the end of the
623614
// specified basic block for the given value and associated debug metadata.
624-
func (d *DIBuilder) InsertValueAtEnd(v Value, diVarInfo, expr Metadata, l DebugLoc, bb BasicBlock) Value {
615+
func (d *DIBuilder) InsertValueAtEnd(v Value, diVarInfo, expr Metadata, l DebugLoc, bb BasicBlock) {
625616
loc := C.LLVMDIBuilderCreateDebugLocation(
626617
d.m.Context().C, C.uint(l.Line), C.uint(l.Col), l.Scope.C, l.InlinedAt.C)
627-
result := C.LLVMDIBuilderInsertDbgValueAtEnd(d.ref, v.C, diVarInfo.C, expr.C, loc, bb.C)
628-
return Value{C: result}
618+
C.LLVMGoDIBuilderInsertDbgValueRecordAtEnd(d.ref, v.C, diVarInfo.C, expr.C, loc, bb.C)
629619
}
630620

631621
func (v Value) SetSubprogram(sp Metadata) {

ir.go

-18
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,6 @@ func AlignOf(t Type) (v Value) { v.C = C.LLVMAlignOf(t.C); return }
921921
func SizeOf(t Type) (v Value) { v.C = C.LLVMSizeOf(t.C); return }
922922
func ConstNeg(v Value) (rv Value) { rv.C = C.LLVMConstNeg(v.C); return }
923923
func ConstNSWNeg(v Value) (rv Value) { rv.C = C.LLVMConstNSWNeg(v.C); return }
924-
func ConstNUWNeg(v Value) (rv Value) { rv.C = C.LLVMConstNUWNeg(v.C); return }
925924
func ConstNot(v Value) (rv Value) { rv.C = C.LLVMConstNot(v.C); return }
926925
func ConstAdd(lhs, rhs Value) (v Value) { v.C = C.LLVMConstAdd(lhs.C, rhs.C); return }
927926
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.
934933
func ConstNUWMul(lhs, rhs Value) (v Value) { v.C = C.LLVMConstNUWMul(lhs.C, rhs.C); return }
935934
func ConstXor(lhs, rhs Value) (v Value) { v.C = C.LLVMConstXor(lhs.C, rhs.C); return }
936935

937-
func ConstICmp(pred IntPredicate, lhs, rhs Value) (v Value) {
938-
v.C = C.LLVMConstICmp(C.LLVMIntPredicate(pred), lhs.C, rhs.C)
939-
return
940-
}
941-
func ConstFCmp(pred FloatPredicate, lhs, rhs Value) (v Value) {
942-
v.C = C.LLVMConstFCmp(C.LLVMRealPredicate(pred), lhs.C, rhs.C)
943-
return
944-
}
945-
946-
func ConstShl(lhs, rhs Value) (v Value) { v.C = C.LLVMConstShl(lhs.C, rhs.C); return }
947-
948936
func ConstGEP(t Type, v Value, indices []Value) (rv Value) {
949937
ptr, nvals := llvmValueRefs(indices)
950938
rv.C = C.LLVMConstGEP2(t.C, v.C, ptr, nvals)
@@ -1660,12 +1648,6 @@ func (b Builder) CreateNSWNeg(v Value, name string) (rv Value) {
16601648
rv.C = C.LLVMBuildNSWNeg(b.C, v.C, cname)
16611649
return
16621650
}
1663-
func (b Builder) CreateNUWNeg(v Value, name string) (rv Value) {
1664-
cname := C.CString(name)
1665-
defer C.free(unsafe.Pointer(cname))
1666-
rv.C = C.LLVMBuildNUWNeg(b.C, v.C, cname)
1667-
return
1668-
}
16691651
func (b Builder) CreateFNeg(v Value, name string) (rv Value) {
16701652
cname := C.CString(name)
16711653
defer C.free(unsafe.Pointer(cname))

llvm_config_darwin_llvm18.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !byollvm && darwin && !llvm14 && !llvm15 && !llvm16 && !llvm17
1+
//go:build !byollvm && darwin && llvm18
22

33
package llvm
44

llvm_config_darwin_llvm19.go

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//go:build !byollvm && darwin && !llvm14 && !llvm15 && !llvm16 && !llvm17 && !llvm18
2+
3+
package llvm
4+
5+
// Automatically generated by `make config BUILDDIR=`, do not edit.
6+
7+
// #cgo amd64 CPPFLAGS: -I/usr/local/opt/llvm@19/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
8+
// #cgo amd64 CXXFLAGS: -std=c++17
9+
// #cgo amd64 LDFLAGS: -L/usr/local/opt/llvm@19/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM -lz -lm
10+
// #cgo arm64 CPPFLAGS: -I/opt/homebrew/opt/llvm@19/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
11+
// #cgo arm64 CXXFLAGS: -std=c++17
12+
// #cgo arm64 LDFLAGS: -L/opt/homebrew/opt/llvm@19/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM -lz -lm
13+
import "C"
14+
15+
type run_build_sh int

llvm_config_linux_llvm18.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !byollvm && linux && !llvm14 && !llvm15 && !llvm16 && !llvm17
1+
//go:build !byollvm && linux && llvm18
22

33
package llvm
44

llvm_config_linux_llvm19.go

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//go:build !byollvm && linux && !llvm14 && !llvm15 && !llvm16 && !llvm17 && !llvm18
2+
3+
package llvm
4+
5+
// #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
6+
// #cgo CXXFLAGS: -std=c++17
7+
// #cgo LDFLAGS: -L/usr/lib/llvm-19/lib -lLLVM-19
8+
import "C"
9+
10+
type run_build_sh int

0 commit comments

Comments
 (0)