[llvm-commits] [llvm] r117070 - /llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp

Dan Gohman gohman at apple.com
Mon Oct 25 13:58:57 PDT 2010


On Oct 23, 2010, at 5:08 AM, Duncan Sands wrote:

> Hi Dan,
> 
>>> Both C and C++ say that modifying an object defined with a const qualifier
>>> has undefined results, so while you can't use this for pointer-to-const, you
>>> could use it for const variables after they've been initialized.
>> 
>> 
>> For pointsToConstantMemory, it has to be really constant, so in C, the only
>> thing that could use it is statically initialized const variables.
>> 
>> LLVM already has constant GlobalVariables, so probably the only new
>> theoretical functionality here for C and C++ would be for statically initialized
>> objects which are mostly const but have mutable fields.
>> 
>> For other languages, this feature could be used for runtime library calls
>> which allocate objects and initialize some thereafter-constant fields in
>> the objects, as long as the calls are never inlined.
> 
> this sounds a lot like what you can do with llvm.invariant (initialize a
> variable, then mark it as constant afterwards using llvm.invariant).

It may be theoretically redundant at some level, but there are
some practical differences. llvm.invariant is only visible to passes
using memdep or do some other scanning of multiple instructions. The
TBAA const flag is attached to loads directly, so clients like LICM
and CodeGen which don't do that can easily find them.

Dan





More information about the llvm-commits mailing list