Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
run:
go test -v -tags=llvm${{ matrix.llvm }}
- name: Test default LLVM
if: matrix.llvm == 19
if: matrix.llvm == 20
run:
go test -v
test-linux:
Expand All @@ -57,6 +57,6 @@ jobs:
run:
go test -v -tags=llvm${{ matrix.llvm }}
- name: Test default LLVM
if: matrix.llvm == 19
if: matrix.llvm == 20
run:
go test -v
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/goplus/llvm

go 1.14
go 1.22
6 changes: 6 additions & 0 deletions ir.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,8 @@ func (c Context) X86FP80Type() (t Type) { t.C = C.LLVMX86FP80TypeInContext(c.C)
func (c Context) FP128Type() (t Type) { t.C = C.LLVMFP128TypeInContext(c.C); return }
func (c Context) PPCFP128Type() (t Type) { t.C = C.LLVMPPCFP128TypeInContext(c.C); return }

func (c Context) MetadataType() (t Type) { t.C = C.LLVMMetadataTypeInContext(c.C); return }

// Operations on function types
func FunctionType(returnType Type, paramTypes []Type, isVarArg bool) (t Type) {
var pt *C.LLVMTypeRef
Expand Down Expand Up @@ -828,6 +830,10 @@ func (v Value) ConstantAsMetadata() (md Metadata) {
md.C = C.LLVMConstantAsMetadata(v.C)
return
}
func (c Context) MetadataAsValue(md Metadata) (v Value) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential crash on nil Metadata

LLVMMetadataAsValue in upstream LLVM does not null-guard its MD argument — unlike the custom wrappers in IRBindings.cpp (e.g., LLVMSetMetadata2) which explicitly check if (!MD). Calling this with a zero-valued Metadata{} passes NULL across the CGo boundary and causes an unrecoverable SIGSEGV inside LLVM's C++ runtime.

Consider adding a guard:

func (c Context) MetadataAsValue(md Metadata) (v Value) {
    if md.C == nil {
        return
    }
    v.C = C.LLVMMetadataAsValue(c.C, md.C)
    return
}

v.C = C.LLVMMetadataAsValue(c.C, md.C)
return
}

// Operations on scalar constants
func ConstInt(t Type, n uint64, signExtend bool) (v Value) {
Expand Down
2 changes: 1 addition & 1 deletion llvm_config_llvm19.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !byollvm && !llvm14 && !llvm15 && !llvm16 && !llvm17 && !llvm18 && !llvm20 && !llvm21
//go:build !byollvm && llvm19
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silent breaking change for existing LLVM 19 users

The old tag (!byollvm && !llvm14 && ... && !llvm18 && !llvm20 && !llvm21) made LLVM 19 the default — any build without an explicit version tag would select it. The new tag !byollvm && llvm19 requires an explicit opt-in.

Any CI pipeline or user who was building without a version tag (relying on LLVM 19 as the default) will silently switch to LLVM 20 after this change. There is no compile-time error; the wrong LLVM version is simply picked up transparently.

Consider adding a note in the PR description or README about this migration requirement.


package llvm

Expand Down
2 changes: 1 addition & 1 deletion llvm_config_llvm20.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !byollvm && llvm20
//go:build !byollvm && !llvm14 && !llvm15 && !llvm16 && !llvm17 && !llvm18 && !llvm19 && !llvm21

package llvm

Expand Down
Loading