Mahwish
Mahwish

Reputation: 101

How to get the name of the variable the pointer is pointing to in LLVM

I have a pointer to an array or to a variable. I want to get the name of that array or variable. How to get this in LLVM?

I am trying to instrument a function to which an array or variable is passed through pointer. I want to get the name of that array or variable argument. I am instrumenting my functions using LLVM.

Upvotes: 1

Views: 438

Answers (1)

Eli Bendersky
Eli Bendersky

Reputation: 273706

You need to use debug information for that, because otherwise names from the original C code do not get represented in LLVM IR, in the general case. See the debug info document. In particular, look in the sections about "@llvm.dbg.declare" and "Global Value Descriptors"

Upvotes: 2

Related Questions