[LLVMdev] types in load/store

Jianzhou Zhao jianzhou at seas.upenn.edu
Thu Jul 8 08:09:03 PDT 2010


I have a confusion about types used in load/store,
(http://llvm.org/docs/GetElementPtr.html#types) says that [...]
Furthermore, loads and stores don't have to use the same types as the
type of the underlying object. Types in this context serve only to
specify memory size and alignment. Beyond that there are merely a hint
to the optimizer indicating how the value will likely be used. [...]

I was wondering that in which cases we may have undefined behaviors if
types in load/store don't match the objects'. In C, they need to be
compatible, which means the size of types should be same, otherwise
undefined. Do we follow the same convention in LLVM IR? Does GEP also
follow similar rules when types mismatch?

The other question is about 'when loading a value of a type like i20
with a size that is not an integral number of bytes, the result is
undefined if the value was not originally written using a store of the
same type'. At this case, can we make an assumption that typically we
only load the 20 bits, but ignore extra bits, like what store does at
such a case. Is there any problem that stops such an assumption´╝č


More information about the llvm-dev mailing list