简体   繁体   中英

What does llvm.set_value_name actually do?

I read here that doing something like

Llvm.set_value_name n p

Would set the name of llvalue "p" to whatever string is in "n". But I'm confused about what that actually means?

If I had an integer value like 1, this means that I could name 1 to any string? Where are these names being stored? And what is the scope of this name?

That's a wrapper for Value::setName() , which can be used to set the name of most values. Perhaps even all, but the name isn't used for all values. The 32-bit constant 33 is referred to as i32 33 in all the IR I've seen, even if the API allows setting a name for it.

The name is used for instructions and global values such as functions and global variables, all three of which are values. Instructions' names are printed when you ask for a human-readable representation of the IR code, functions and global variable names are passed to the linker, which uses them to link together multiple compilation units. The following call has name foo and refers to a value that has name malloc: %foo = call %malloc(i32 33) and that illustrates both uses.

That you can set a name for other kinds of values may be regarded as an harmless side effect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM