[LLVMdev] hash_map issues with Visual Studio
Morten Ofstad
morten at hue.no
Mon Oct 25 03:21:04 PDT 2004
I have spent some time examining the llvm code now, and it seems most of
the hash_maps are keyed with pointers, and a few with ints. There is
also one place where the keys are std::string. All these are
unproblematic with the Visual Studio std_ext::hash_map since it provides
hash_value functions for all these types (note, it hashes char * as
pointers, not as strings - but char * is not used as a key anywhere in
LLVM). This means that although the way of adding your own hashing
functions is different, the default implementation works for 99% of all
the cases and the ADT/HashExtras.h file is not necessary.
BUT there is one place where llvm defines it's own hashing function, in
include/llvm/Target/TargetSchedInfo.h
template <> struct hash<llvm::OpCodePair> {
size_t operator()(const llvm::OpCodePair& pair) const {
return hash<long>()(pair.val);
}
};
which for Visual Studio can be replaced with:
const size_t hash_value(const llvm::OpCodePair& pair) {
return hash_value((long)pair.val);
}
however, it seems the OpCodePair class is never used - and specifically
never used for hash keys. Should this code be deleted? Also, Paolo is
building LLVM with Visual C, but using a GNU compatible STL. I don't
know how to detect which of these libraries is used, so it's a bit
tricky to make sure the right version is compiled.
I would like some input on these issues before submitting a patch. This
is the last issue remaining before the core of LLVM compiles
unmodified with Visual C...
m.
More information about the llvm-dev
mailing list