Re: [PATCH 1/2] perf annotate: generalize handling of ret instructions

From: Naveen N. Rao
Date: Fri Jun 10 2016 - 10:07:25 EST


On 2016/06/10 10:30AM, Arnaldo Carvalho de Melo wrote:
> Em Fri, Jun 10, 2016 at 06:32:50PM +0530, Naveen N. Rao escreveu:
> > Introduce helper to detect ret instructions and use the same in the tui.

Hi Arnaldo,
Thanks for the review.

>
> Humm, I think this is simpler and equivalent, since so far we didn't had
> any need for special handling of "retq"/"ret" instructions:
>
> diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
> index 4fc208e82c6f..29cef599a091 100644
> --- a/tools/perf/ui/browsers/annotate.c
> +++ b/tools/perf/ui/browsers/annotate.c
> @@ -226,11 +226,11 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
> ui_browser__write_nstring(browser, " ", 2);
> }
> } else {
> - if (strcmp(dl->name, "retq")) {
> - ui_browser__write_nstring(browser, " ", 2);
> - } else {
> + if (strcmp(dl->name, "retq") == 0 || strcmp(dl->name, "ret") == 0) {

This won't work on powerpc since we don't have a "ret" instruction.
Returning from a function is *usually* done through some variant of a
branch to LR (Link Register) instruction. This logic is encoded in the
powerpc-specific ins__find() in the next patch.

That was the motivation in introducing a helper for handling return
instructions in the tui.

- Naveen