Skip to content

ir: add metadata read APIs#37

Merged
xushiwei merged 2 commits intoxgo-dev:goplusfrom
luoliwoshang:codex/metadata-read-api
Apr 14, 2026
Merged

ir: add metadata read APIs#37
xushiwei merged 2 commits intoxgo-dev:goplusfrom
luoliwoshang:codex/metadata-read-api

Conversation

@luoliwoshang
Copy link
Copy Markdown

Summary

  • add receiver-style APIs to read named metadata and MDNode operands from LLVM IR
  • add MDString helpers on Value for metadata parsing workflows
  • add a round-trip test that emits llgo-style metadata, verifies printed IR, parses it back, and reads it through the new APIs

Testing

  • go test ./...
  • go test -run TestNamedMetadataRoundTrip ./...

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several methods to the Module and Value types to support the retrieval of named metadata and metadata node operands, as well as the identification and extraction of MDStrings. A comprehensive test case has been added to verify these operations. Feedback was provided regarding a redundant CString allocation in the NamedMetadataOperands function, which could be optimized to improve efficiency.

Comment thread ir.go
Copy link
Copy Markdown

@fennoai fennoai Bot left a comment

Choose a reason for hiding this comment

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

Code Review: ir: add metadata read APIs

Good addition of metadata read APIs. A few issues worth addressing, ranging from a safety concern to test robustness.

Comment thread ir.go
Comment thread ir.go
Comment thread ir.go
Comment thread metadata_test.go
Comment thread metadata_test.go
@luoliwoshang luoliwoshang force-pushed the codex/metadata-read-api branch from a3a5b78 to c1a0007 Compare April 13, 2026 02:06
@luoliwoshang luoliwoshang force-pushed the codex/metadata-read-api branch from c1a0007 to 5512c9d Compare April 13, 2026 02:07
@xushiwei xushiwei merged commit 01904fe into xgo-dev:goplus Apr 14, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants