[PATCH] New alias analysis for static global variables

Sam Parker sam.parker at arm.com
Fri May 29 03:29:17 PDT 2015


In http://reviews.llvm.org/D10059#179482, @hfinkel wrote:

> The compile-time numbers look good (in the sense that there is no significant difference between the even- and odd-numbered runs).
>
> Please comment on exactly what makes this lighter weight than GlobalsModRef AA, and why this should be a separate pass.


Hi Hal,

GlobalsModRef AA analyses all global values with no limit on the depth of the search, whereas this pass only analyses static variables and obeys the search threshold defined in CaptureTracking. In addition, GlobalsModRef also checks for indirect access to global memory and analyses the call graph. I originally implemented this logic in BasicAA to fill a gap in its understanding of global variables, however I was informed that BasicAA is designed to be stateless, so this pass has been created to maintain the state of the module.

Cheers,
sam


================
Comment at: lib/Analysis/IPA/StaticGlobalsAA.cpp:82
@@ +81,3 @@
+
+static bool hasAddressTaken(Value *V) {
+
----------------
hfinkel wrote:
> This function seems to be doing exactly what PointerMayBeCaptured does (see lib/Analysis/CaptureTracking.cpp), can you use that instead?
> 
Looks like it, it also is recursive with a worklist and a threshold

================
Comment at: lib/Analysis/IPA/StaticGlobalsAA.cpp:123
@@ +122,3 @@
+    if (GV.hasLocalLinkage()) {
+      if (!isa<Function>(GV))
+        if (!hasAddressTaken(&GV))
----------------
majnemer wrote:
> How can `GV` be a `Function`?
Ah, good point, I just looked at the inheritance diagram and not properly at the API.

================
Comment at: lib/Analysis/IPA/StaticGlobalsAA.cpp:124
@@ +123,3 @@
+      if (!isa<Function>(GV))
+        if (!hasAddressTaken(&GV))
+          NonAddressTakenGlobals.insert(&GV);
----------------
majnemer wrote:
> What if the local global variable has an external alias?
would it sufficient to additionally check if !isa<GlobalAlias>?

================
Comment at: lib/Transforms/IPO/PassManagerBuilder.cpp:202
@@ -201,2 +201,3 @@
   addInitialAliasAnalysisPasses(MPM);
+  MPM.add(createStaticGlobalAAPass());
 
----------------
hfinkel wrote:
> Should this be part of the preceeding function?
I tried that, but it caused LLVM to crash. I believe its because that function is also called by populateFunctionPassManager function.

http://reviews.llvm.org/D10059

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list