[cfe-dev] Unexpected behavior of -finstrument-functions

Justin Bogner mail at justinbogner.com
Fri Jul 3 10:20:30 PDT 2015


Jan-Patrick Lehr <my.new.social.email at gmail.com> writes:
> Hi all,
> I was experimenting with Clang and state of the art performance
> profiling and tracing tools such as ScoreP [1]. It basically uses
> compiler instrumentation to generate call-path profiles / traces.
>
> When used with GCC everything works as expected.
>
> Unfortunately, when used with Clang one runs into problems if the code
> under investigation uses exceptions. One example would be the
> 483.Xalancbmk benchmark of the SPEC CPU 2006 suite [2].
>
> The problem is that Clang does function instrumentation in a way that
> the function body itself seems to not getting wrapped in a try/catch.
> Thus, if a callee throws, the instrumentation code does not generate
> "balanced" enter/exit trees.
>
> I already had a look into the Clang sources, but I was unsure how to fix
> this. I will have a look at it and see whether I can supply a patch.
> However, ideas and hints how to do that are well appreciated.

If you haven't found where the current instrumentation is done yet, look
for ShouldInstrumentFunction and EmitFunctionInstrumentation in
CodeGenFunction.cpp. I'm guessing the fix will involve setting up the
call to __cyg_profile_func_exit as a "Cleanup" at some point rather than
just emitting it in FinishFunction.

> Besides this email should I file a bug report somewhere?

Please do, otherwise we might forget about this. The bug tracker is
here: https://llvm.org/bugs/

> Thanks,
> JP
>
> [1] http://www.vi-hps.org/projects/score-p/
> [2] https://www.spec.org/cpu2006/Docs/483.xalancbmk.html
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list