Adding type qualifies or property


Has anybody tell me how to create some new type qualifies in LVM?
A type qualify, like "const" in C, is useful for program
analysis. I hope that I can set/get the type qualify of any value
in a program analysed.

Or, if I could add a property to the value class and set/get the
property, it is same to add some new type qualifies. So, I simply
insert a "int" private members in the value class in
llvm/Value.h, write a pair of set/get methods for the value
class, and initialize it in Value::Value(const Type *ty, ValueTy vty, const std::string &name). But, when I set the privative
member of a value in my pass, analyse gives me:

analyze(void std::_Destroy<llvm::Use>(llvm::Use*)+0x11)[0x8296921]
analyze(void std::__destroy_aux<llvm::Use*>(llvm::Use*, llvm::Use*, __false_type)+0x1c)[0x8297570]
analyze(void std::_Destroy<llvm::Use*>(llvm::Use*, llvm::Use*)+0x1a)[0x82968f0]
analyze(std::vector<llvm::Use, std::allocator<llvm::Use> >::~vector [in-charge]()+0x19)[0x82972fd]
analyze(llvm::User::~User [not-in-charge]()+0x1e)[0x8295b8c]
analyze(llvm::GlobalValue::~GlobalValue [not-in-charge]()+0x1a)[0x83ba8c0]
analyze(llvm::Function::~Function [in-charge deleting]()+0xb4)[0x8374768]
analyze(llvm::iplist<llvm::Function, llvm::ilist_traits<llvm::Function> >::erase(llvm::ilist_iterator<llvm::Function>)+0x38)[0x8288ba2]
analyze(llvm::iplist<llvm::Function, llvm::ilist_traits<llvm::Function> >::erase(llvm::ilist_iterator<llvm::Function>, llvm::ilist_iterator<llvm::Function>)+0x32)[0x83bb8d4]
analyze(llvm::iplist<llvm::Function, llvm::ilist_traits<llvm::Function> >::clear()+0x3d)[0x83bb5e1]
analyze(llvm::Module::~Module [in-charge]()+0x41)[0x83788b9]

Has anyone encountered this? Any workarounds?


David xia


LLVM doesn't really use type qualifiers the way you're thinking about
it. In LLVM parlance, types are neither const nor non-const, they just
define the fundamental nature of a value. However, LLVM fully supports
Constant Values (see include/llvm/Constant.h) and constant global
variables (see include/llvm/GlobalVariable.h). You might want to read up
on the LLVM IR a bit here:



Also, the error that you got in User::~User() looks more like a problem
in your pass than a problem with the members you added to the Value
class. If you provide a full stack trace (with line numbers, from GDB),
I could tell you more specifically what's wrong. However, it looks like
you have a bad pointer, possibly, in the Operands of your Function.