[PATCH 03/11] Record a pointer to the AliasSet

Tobias Grosser tobias at grosser.es
Tue Jun 10 00:21:29 PDT 2014


On 09/06/2014 02:42, Andreas Simbuerger wrote:
> Instead of taking the pointer of the AliasSet reference we directly
> retreive a pointer from the AliasSetTracker. This gives us a pointer
> that should be valid at least until the ScopDetection is destroyed.
> ---
>   lib/Analysis/ScopDetection.cpp | 11 +++++++++--
>   1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/lib/Analysis/ScopDetection.cpp b/lib/Analysis/ScopDetection.cpp
> index cab7af7..fbaf07c 100644
> --- a/lib/Analysis/ScopDetection.cpp
> +++ b/lib/Analysis/ScopDetection.cpp
> @@ -471,8 +471,15 @@ bool ScopDetection::isValidMemoryAccess(Instruction &Inst,
>     // alias, if -basicaa is not available. They actually do not, but as we can
>     // not proof this without -basicaa we would fail. We disable this check to
>     // not cause irrelevant verification failures.
> -  if (!AS.isMustAlias())
> -    return invalid<ReportAlias>(Context, /*Assert=*/true, &Inst, &AS);
> +  if (!AS.isMustAlias()) {
> +    // If we want to be able to use this for diagnostics outside of
> +    // ScopDetection, we need to fetch the AliasSet as a pointer as soon as it
> +    // is created above.
> +    AliasSet *ASPtr = Context.AST.getAliasSetForPointerIfExists(
> +        BaseValue, AliasAnalysis::UnknownSize,
> +        Inst.getMetadata(LLVMContext::MD_tbaa));
> +    return invalid<ReportAlias>(Context, /*Assert=*/false, &Inst, ASPtr);
> +  }

I am slightly confused. Are you saying this will yield another pointer 
than deriving the pointer via '&AS'? Why is this the case? Looking at 
the implementations of getAliasSetForPointer() and 
getAliasSetForPointerIfExists() both call findAliasSetForPointer(), the 
first returning the plain pointer, the second dereferencing it and 
returning it as reference.

Do you have a test case that is fixed by this change?

Cheers,
Tobias



More information about the llvm-commits mailing list