[llvm-commits] [PATCH] Debug info utilities and printer pass
Török Edwin
edwintorok at gmail.com
Wed Dec 10 14:21:31 PST 2008
On 2008-12-10 23:13, Devang Patel wrote:
> Hi Torok,
>
Hi Devang,
> On Dec 10, 2008, at 11:02 AM, Török Edwin wrote:
>
>
>> Hi,
>>
>> [@John Criswell: this is a much improved version of SourceLocator I
>> sent
>> you ages ago ;)]
>>
>> 01-bb.patch:
>> BasicBlock::getUniquePredecessor -> similar to getSinglePredecessor()
>> but works if there is a unique predecessor listed multiple times
>>
>
> This is OK.
>
Thanks, will commit this tomorrow morning.
>
>> 02-intrin.patch:
>> Introduce DbgFuncStart::getDisplayName() (which refers to unmangled C
>> ++
>> name!), and DbgDeclareInst::getVariableName()
>> Introduce include/llvm/Support/DebugInfo.h:
>>
>
> We already have include/llvm/Analysis/DebugInfo.h, so I suggest that
> you use another name for this new header.
>
I named it include/llvm/Support/SourceInfo.h now.
>
> +namespace llvm {
> + class DbgStopPointInst;
> + /// Finds the stoppoint coressponding to this instruction, that is
> the
> + /// stoppoint that dominates this instruction
> + static const DbgStopPointInst *findStopPoint(const Instruction *Inst)
> + {
> + if (isa<DbgStopPointInst>(Inst))
> + return cast<DbgStopPointInst>(Inst);
>
> pl. use dyn_cast instead of isa + cast.
>
Ok.
> +
> + const BasicBlock *BB = Inst->getParent();
> + BasicBlock::const_iterator I = Inst, B;
> + do {
> + B = BB->begin();
> + // a BB consisting only of a terminator, can't have a stoppoint
> + if (I != B) {
> + do {
> + --I;
> + if (isa<DbgStopPointInst>(*I))
> + return cast<DbgStopPointInst>(&*I);
> + } while (I != B);
> + }
> + // this BB didn't have a stoppoint, if there is only one
> + // predecessor, look for a stoppoint there
> + // we could use getIDom(), but that would require dominator info
> + BB = I->getParent()->getUniquePredecessor();
> + if (BB)
> + I = BB->getTerminator();
> + } while (BB != 0);
> + return 0;
> + }
> +
> + /// Finds the stoppoint corresponding to first real (non-debug
> intrinsic)
> + /// instruction in this Basic Block, and returns the stoppoint for
> it.
> + static const DbgStopPointInst *findBBStopPoint(const BasicBlock *BB)
> + {
> + for(BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I !
> = E; ++I) {
> + if (isa<DbgStopPointInst>(*I))
> + return cast<DbgStopPointInst>(&*I);
> + }
> + // fallback to looking for stoppoint of terminator inst
> + // useful if this BB contains no stoppoints, but unique
> predecessor does
> + return findStopPoint(BB->getTerminator());
>
> This will iterate BB again again.
>
Thanks for spotting this, see the updated 02-intrin.patch.
Best regards,
--Edwin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 02-intrin.patch
Type: text/x-diff
Size: 5748 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20081211/6366c243/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 03-pass.patch
Type: text/x-diff
Size: 5730 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20081211/6366c243/attachment-0001.patch>
More information about the llvm-commits
mailing list