[LLVMdev] [Propose] Add address-taken bit to GlobalVariable for disambiguation purpose
Chris Lattner
clattner at apple.com
Wed Oct 30 14:08:46 PDT 2013
On Oct 30, 2013, at 10:37 AM, Shuxin Yang <shuxin.llvm at gmail.com> wrote:
> Nadav:
>
> I don't think this is right approach for engineering.
> The time-complexity of re-analyzing addr_taken for each single alias query depends on
> 1. how many global variable
> 2. how many occurrence of these global variables.
> 3. how many queries the compiler have.
>
> 3) depends on compiler. You never know what we will have in the following few years.
> 1 and 2 depends on the program. You never know what kind of program you will run into.
> How can we use what we have today the extrapolate the future ignoring the highly
> unpredictable complexity.
This logic doesn't make sense to me. You can implement it both ways and get empirical results on *programs we have today* and *in our compiler*. This is not a theoretical exercise.
In practice, walking the use list of a global variable is very fast. As you've noticed, we already use this approach (in an admittedly ad-hoc and decentralized way) throughout the compiler.
> It's interesting that recently, many EE magazine (circuit cellar, Elector, EE times) are
> discussing buggy SW kill people. I remember some posts complaining that some buggy program
> have amazingly large # of global variables. I can find one post in Chinese website:
>
> http://forum.xitek.com/thread-1226816-5-1-1.html
>
> The 1st post says, "a program has 11000 global variables"!
This is just FUD and completely unrelated to the discussion.
> As to "Can you provide this data"? My answer is no, and I will not to implement the analysis
> which perform on-the-fly analysis unless I'm convinced that saving addr_taken bit to llvm::GlobalVariable
> is fundamentally flawed.
You don't have to be convinced. The burden of proof is on you - not on us to convince you.
Here's the deal: there are tons of "potentially useful" things that could be encoded in the IR. Each thing added to IR has a complexity increase on the entire compiler. Passes that work on global variables will have to reason about this bit, and transformations that could invalidate it (e.g. global merging) will have to have code added to update/preserve it.
We are very conservative about changing IR for good reason. We don't add caches to IR unless there is pretty much no other way to achieve the result. In a perfect world, we would have nothing redundant in the IR at all.
That said, I'm open to this attribute, because I think the semantics can be nailed down tightly (though your "volatile" discussion doesn't make any sense to me) it is widely useful, and I don't think the burden of maintaining it will be that high. However, before we do it, you need to demonstrate that lazily computing it from use-def chains is *empirically worse*.
-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131030/bdbd7314/attachment.html>
More information about the llvm-dev
mailing list