[cfe-dev] Allowing checkers to mark symbols as live
Jordy Rose
jediknil at belkadan.com
Wed Aug 11 16:38:48 PDT 2010
On Wed, 11 Aug 2010 15:06:34 +0800, Zhongxing Xu <xuzhongxing at gmail.com>
wrote:
> -bool SymbolReaper::isLive(const VarRegion *VR) const {
> - const StackFrameContext *SFC = VR->getStackFrame();
> +bool SymbolReaper::isLive(const MemRegion *MR) {
> + MR = MR->getBaseRegion();
>
> - if (SFC == LCtx->getCurrentStackFrame())
> - return LCtx->getLiveVariables()->isLive(Loc, VR->getDecl());
> - else
> + if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(MR))
> + return isLive(SR->getSymbol());
> +
> + if (const VarRegion *VR = dyn_cast<VarRegion>(MR)) {
> + const StackFrameContext *SFC = VR->getStackFrame();
> +
> + if (SFC == LCtx->getCurrentStackFrame())
> + return LCtx->getLiveVariables()->isLive(Loc, VR->getDecl());
> +
> return SFC->isParentOf(LCtx->getCurrentStackFrame());
> + }
> +
> + // FIXME: This is a gross over-approximation. What we really need is
a
> way to
> + // tell if anything still refers to this region. Unlike
SymbolicRegions,
> + // AllocaRegions don't have associated symbols, though, so we don't
> actually
> + // have a way to track their liveness.
> + if (isa<AllocaRegion>(MR))
> + return true;
> +
> + if (isa<MemSpaceRegion>(MR))
> + return true;
> +
> + return false;
> }
>
> I don't think we should generalize the isLive(VarRegion*) interface to
> judge on all MemRegion*. The old interface is clear on what it does
> and it is the one needed by clients.
>
> Also, the implementation here is incomplete. A metadata symbol may
> associated with other kinds of regions not handled here, like
> FieldRegion.
>
> We need some way to collect all live regions. But that is too complex
> to fit in this patch. So I suggest we keep the old interface. and
> focus on adding metadata symbol in this patch.
Sorry, I forgot that this isLive was for use outside of SymbolReaper as
well. I was just trying to take advantage of the fact that SymbolExtent and
SymbolMetadata have roughly the same liveness rules.
I did make sure to get the base region to deal with FieldRegion-based
metadata. I'll move this into a static method and put isLive back the way
it was.
More information about the cfe-dev
mailing list