Changing global variables in MachineFunctionPass

Hello everyone,

is there a way to alter global variables in an MachineFunctionPass?
I know that I can’t add or remove GlobalVariables and that I am not allowed to change the IR representation of those variables but is there any representation in a MachineFunctionPass I could alter?

What I am trying to do is to collect all callsites of certain functions and store them in an array of structs in a specifically named section, so that a runtime library can later find and patch these callsites.
The issue is that I need to exactly label the corresponding assembly call instruction and therefore need to do it as a MachineFunctionPass. I then emit an MCSymbol before the call instructions but how do I get a reference to those labels into my array?

Thank you in advance!

This doesn’t sound like “changing global variables” actually. You’re creating some extra MCSymbol instances, and you want to emit the label addresses into a special purpose section. I suggest you look at how the stack-size section is handled.

Thank you very much for your answer.
What I ended up doing for the moment was to add functions with names the labels will later have in the IR pass and the emit those labels later in the MachineFunctionPass. Just to get the references in the vairables to resolve.

I will definitely have a look at the stack-size section though, maybe I will find a less hacky solution.