[patch] Handle calls in GlobalStatus

Benjamin Kramer benny.kra at gmail.com
Fri Oct 25 14:24:22 PDT 2013


On 25.10.2013, at 02:55, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:

> Attached a new version that also handles invokes for completeness.
> 
> diff --git a/lib/Transforms/Utils/GlobalStatus.cpp b/lib/Transforms/Utils/GlobalStatus.cpp
> index 8fb79aa..a1be6e4 100644
> --- a/lib/Transforms/Utils/GlobalStatus.cpp
> +++ b/lib/Transforms/Utils/GlobalStatus.cpp
> @@ -11,6 +11,7 @@
>  #include "llvm/IR/BasicBlock.h"
>  #include "llvm/IR/GlobalVariable.h"
>  #include "llvm/IR/IntrinsicInst.h"
> +#include "llvm/Support/CallSite.h"
>  #include "llvm/Transforms/Utils/GlobalStatus.h"
>  
>  using namespace llvm;
> @@ -148,6 +149,11 @@ static bool analyzeGlobalAux(const Value *V, GlobalStatus &GS,
>          if (MSI->isVolatile())
>            return true;
>          GS.StoredType = GlobalStatus::Stored;
> +      } else if (isa<CallInst>(I) || isa<InvokeInst>(I)) {

Just one nit: you could fold the ImmutableCallSite declaration into the if. Otherwise LGTM!

- Ben

> +        ImmutableCallSite C(I);
> +        if (!C.isCallee(UI))
> +          return true;
> +        GS.IsLoaded = true;
>        } else {
>          return true; // Any other non-load instruction might take address!
>        }




More information about the llvm-commits mailing list