[LLVMdev] Is sizeof(pointer) known in LLVM IR?

Philip Reames listmail at philipreames.com
Fri Dec 20 14:44:19 PST 2013


Looking through the IR documentation, I have been unable to establish if 
the size of a pointer value is knowable to an LLVM optimization pass.  
For an IR->IR optimization pass, is the pass allowed to assume anything 
about the size of a pointer value?  Or is making such an assumption 
explicitly disallowed?

Once target specific information gets introduced, I'm assuming that the 
size of a pointer value becomes known.  Is this true?

The context of my question is that I'm working on a project where being 
able to categorically disallow certain types of optimizations would be 
quite helpful.  For example, we'd like to be able to "prove" that no 
LLVM pass we run can store a non-pointer value into a pointer typed 
field in an object.  (If the relative sizes aren't known, this is trivial.)

Just to note, I'm not asking about implementation; I'm only asking about 
intended semantics.  If the current implementation violates the intended 
semantics slightly, we're happy to contribute patches.

Philip



More information about the llvm-dev mailing list