Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need information for constants #35

Open
gtrepta opened this issue Jan 29, 2025 · 1 comment
Open

Need information for constants #35

gtrepta opened this issue Jan 29, 2025 · 1 comment

Comments

@gtrepta
Copy link

gtrepta commented Jan 29, 2025

Context

An example of a constant (under func) in a call terminator:

                  "terminator": {
                    "kind": {
                      "Call": {
                        "args": [],
                        "destination": {
                          "local": 1,
                          "projection": []
                        },
                        "func": {
                          "Constant": {
                            "const_": {
                              "id": 10,
                              "kind": "ZeroSized",
                              "ty": 25
                            },
                            "span": 51,
                            "user_ty": null
                          }
                        },
                        "target": 1,
                        "unwind": "Continue"
                      }
                    },

Problem

This constant has an id: 10, so somewhere there should be what this constant's value actually is (a function pointer/reference?) in the smir_pretty output, but it doesn't exist anywhere.

Notes

Source which generated the above snippet:

fn test_true() -> bool {
    true
}

fn main() {
    test_true();
}
@jberthold
Copy link
Member

It is far from obvious, but (from my understanding) the function being called by this Call terminator is indicated by the ty field in the constant, Call.func.Constant.const_.ty = 25 . That number should map to the callee's NormalSym name, which then needs to be searched as symbol_name in the items to find the item that we execute next.

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

No branches or pull requests

2 participants