package go-hex not working due to an inline asm instruction

Open
#2,576 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
go
Domain
compilers

Research direction

Start with the reported github.com/tmthrgd/go-hex/hex_decode_amd64.s file and the decodeAVX function, then reproduce the minimal program with llgo v1.0.3 on linux/amd64. Investigate how the POR instruction is translated; done means the package builds and the example runs successfully under llgo without the unsupported-instruction error.

Written by the indexing model from the issue text.

Description

Consider the following minimal program for testing the package github.com/tmthrgd/go-hex under llgo [the reason why I 've got into this issue is that this package is used internally by bun orm]

package main

import (
	"fmt"
	"log"

	"github.com/tmthrgd/go-hex"
)

func main() {
	// Original data in bytes
	originalData := []byte("Hello, Go Hex!")
	fmt.Printf("Original data (bytes): %v\n", originalData)
	fmt.Printf("Original data (string): %s\n\n", string(originalData))

	// 1. Encode to Hexadecimal (Lowercase)
	encodedStr := hex.EncodeToString(originalData)
	fmt.Printf("Hexadecimal (Lowercase): %s\n", encodedStr)

	// 2. Decode from Hexadecimal
	decodedData, err := hex.DecodeString(encodedStr)
	if err != nil {
		log.Fatalf("Error decoding: %v", err)
	}
	fmt.Printf("Decoded (string): %s\n", string(decodedData))

}

Under go 1.27.0 program works as follows

$go build
[pablo@minipc hex]$ ./test-go-hex 
Original data (bytes): [72 101 108 108 111 44 32 71 111 32 72 101 120 33]
Original data (string): Hello, Go Hex!

Hexadecimal (Lowercase): 48656c6c6f2c20476f2048657821
Decoded (string): Hello, Go Hex!

Now using llgo v1.0.3 linux/amd64 I've got

$ llgo build
github.com/tmthrgd/go-hex: translate /home/pablo/gopath/pkg/mod/github.com/tmthrgd/go-hex@v0.0.0-20190904060850-447a3041c3bc/hex_decode_amd64.s: github.com/tmthrgd/go-hex: translate /home/pablo/gopath/pkg/mod/github.com/tmthrgd/go-hex@v0.0.0-20190904060850-447a3041c3bc/hex_decode_amd64.s: github.com/tmthrgd/go-hex.decodeAVX: "POR decodeToLower<>(SB), X0": amd64: unsupported instruction POR
Dominant language
LLVM
Stars
758
Forks
49
Avg merge
1d 6h
Merged PRs (30d)
138

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from xgo-dev/llgo

All issues in xgo-dev/llgo

Similar issues

More Compilers issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.