[PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-22 Thread Honggyu Kim via cfe-commits
honggyu.kim created this revision. honggyu.kim added reviewers: rjmccall, hans. honggyu.kim added a subscriber: cfe-commits. Since some profiling tools, such as gprof, ftrace, and uftrace, use -pg option to generate a mcount function call at the entry of each function. Function invocation can be d

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-08-09 Thread Saleem Abdulrasool via cfe-commits
compnerd added a comment. Theres a frontend mangler and a backend mangler. You should try this on Windows GNU environments :-). https://reviews.llvm.org/D22666 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/m

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-08-11 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment. In https://reviews.llvm.org/D22666#509904, @compnerd wrote: > Theres a frontend mangler and a backend mangler. You should try this on > Windows GNU environments :-). Thanks for the confirmation :) If so, would it be okay if I put one more backslash for each mcount

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-08-11 Thread Saleem Abdulrasool via cfe-commits
compnerd added a comment. No, the inserted character is a literal SOH, not the string "\01". https://reviews.llvm.org/D22666 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-08-12 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment. In https://reviews.llvm.org/D22666#513465, @compnerd wrote: > No, the inserted character is a literal SOH, not the string "\01". I don't know why the string is passed in a different way but '\01' is shown in IR previously as below $ clang -target armv7-unknown-n

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-08-22 Thread Honggyu Kim via cfe-commits
honggyu.kim added a reviewer: compnerd. honggyu.kim removed a subscriber: compnerd. honggyu.kim updated this revision to Diff 68954. honggyu.kim added a comment. I have fixed SOH character problem by https://reviews.llvm.org/D23792. I've verified that mcount.c and gnu-mcount.c tests are passed n

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-09-01 Thread Honggyu Kim via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL280355: [Frontend] Fix mcount inlining bug (authored by honggyu.kim). Changed prior to commit: https://reviews.llvm.org/D22666?vs=68954&id=69986#toc Repository: rL LLVM https://reviews.llvm.org/D226

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-22 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment. Hi John and Hans, I don't know if I found right reviewers for this patch, but could you please have a look at it? I found this problem while I was trying to profile a binary that is compiled with -pg and -O2 as I reported in bugzilla. https://llvm.org/bugs/show_bug.

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-22 Thread Hal Finkel via cfe-commits
hfinkel added a subscriber: hfinkel. hfinkel added a comment. What's the actual desired behavior here? Should the inliner strip out calls to mcount() as it inlines? https://reviews.llvm.org/D22666 ___ cfe-commits mailing list cfe-commits@lists.llvm

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-22 Thread John McCall via cfe-commits
rjmccall added a comment. In https://reviews.llvm.org/D22666#493026, @hfinkel wrote: > What's the actual desired behavior here? Should the inliner strip out calls > to mcount() as it inlines? I think they basically just want a late pass (as in immediately prior to codegen) to insert the mcoun

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-22 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment. In https://reviews.llvm.org/D22666#493109, @rjmccall wrote: > In https://reviews.llvm.org/D22666#493026, @hfinkel wrote: > > > What's the actual desired behavior here? Should the inliner strip out calls > > to mcount() as it inlines? > > > I think they basically just

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-22 Thread Hal Finkel via cfe-commits
hfinkel added a comment. In https://reviews.llvm.org/D22666#493706, @honggyu.kim wrote: > In https://reviews.llvm.org/D22666#493109, @rjmccall wrote: > > > In https://reviews.llvm.org/D22666#493026, @hfinkel wrote: > > > > > What's the actual desired behavior here? Should the inliner strip out >

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-22 Thread John McCall via cfe-commits
rjmccall added a comment. Note that the presence of the mcount call itself will significantly impact inlining and, really, the entire optimization pipeline. Having this be a late pass seems more in keeping with what I assume is a goal that this instrumentation doesn't drastically change the ge

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-26 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment. In https://reviews.llvm.org/D22666#493708, @rjmccall wrote: > Note that the presence of the mcount call itself will significantly impact > inlining and, really, the entire optimization pipeline. Having this be a > late pass seems more in keeping with what I assume

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-26 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment. One more problem is that -finstrument-functions has the same inlining problem. The code in `llvm/tools/clang/lib/CodeGen/CodeGenFunction.cpp` shows that. void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-26 Thread Hal Finkel via cfe-commits
hfinkel added a comment. In https://reviews.llvm.org/D22666#495978, @honggyu.kim wrote: > In https://reviews.llvm.org/D22666#493708, @rjmccall wrote: > > > Note that the presence of the mcount call itself will significantly impact > > inlining and, really, the entire optimization pipeline. Havi

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-26 Thread Hal Finkel via cfe-commits
hfinkel added a comment. In https://reviews.llvm.org/D22666#496218, @hfinkel wrote: > In https://reviews.llvm.org/D22666#495978, @honggyu.kim wrote: > > > In https://reviews.llvm.org/D22666#493708, @rjmccall wrote: > > > > > Note that the presence of the mcount call itself will significantly > >

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-26 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment. In https://reviews.llvm.org/D22666#496355, @hfinkel wrote: > Here's a patch for the backend part: https://reviews.llvm.org/D22825 - If > this makes sense to everyone, we can change the frontend to add the > corresponding attribute instead of inserting the function c

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-26 Thread Hal Finkel via cfe-commits
hfinkel added a comment. In https://reviews.llvm.org/D22666#497085, @honggyu.kim wrote: > In https://reviews.llvm.org/D22666#496355, @hfinkel wrote: > > > Here's a patch for the backend part: https://reviews.llvm.org/D22825 - If > > this makes sense to everyone, we can change the frontend to add

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-27 Thread Honggyu Kim via cfe-commits
honggyu.kim updated this revision to Diff 65879. honggyu.kim added a comment. I've updated the diff that can be working with https://reviews.llvm.org/D22825. I appreciate your work in backend, Hal. Please correct me if I'm wrong. https://reviews.llvm.org/D22666 Files: lib/CodeGen/CodeGenFun

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-28 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment. I just wrote how I tested this in the bugzilla report page below: https://llvm.org/bugs/show_bug.cgi?id=28660 https://reviews.llvm.org/D22666 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-28 Thread Hal Finkel via cfe-commits
hfinkel accepted this revision. hfinkel added a comment. This revision is now accepted and ready to land. Comments about the comment, but otherwise, LGTM. Comment at: lib/CodeGen/CodeGenFunction.cpp:789 @@ -796,1 +788,3 @@ + // Since emitting mcount call here impacts optimiza

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-28 Thread John McCall via cfe-commits
rjmccall added a comment. LGTM, too. https://reviews.llvm.org/D22666 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-28 Thread Honggyu Kim via cfe-commits
honggyu.kim updated the summary for this revision. honggyu.kim updated this revision to Diff 66072. https://reviews.llvm.org/D22666 Files: lib/CodeGen/CodeGenFunction.cpp Index: lib/CodeGen/CodeGenFunction.cpp === --- lib/CodeGen/

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-28 Thread Honggyu Kim via cfe-commits
honggyu.kim marked 4 inline comments as done. honggyu.kim added a comment. In https://reviews.llvm.org/D22666#499583, @hfinkel wrote: > Comments about the comment, but otherwise, LGTM. Just updated the comment as you mentioned. Thanks for correcting my English :) https://reviews.llvm.org/D226

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-28 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment. Should we also modify clang/test/CodeGen/mcount.c as well? I'm not actually familiar with test infra. $ cat llvm/tools/clang/test/CodeGen/mcount.c // RUN: %clang_cc1 -pg -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -pg -tr

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-28 Thread John McCall via cfe-commits
rjmccall added a comment. In https://reviews.llvm.org/D22666#500326, @honggyu.kim wrote: > Should we also modify clang/test/CodeGen/mcount.c as well? I'm not actually > familiar with test infra. Yes, you'll need to modify it to test for the attribute instead. https://reviews.llvm.org/D22666

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-28 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment. In https://reviews.llvm.org/D22666#500327, @rjmccall wrote: > In https://reviews.llvm.org/D22666#500326, @honggyu.kim wrote: > > > Should we also modify clang/test/CodeGen/mcount.c as well? I'm not > > actually familiar with test infra. > > > Yes, you'll need to mod

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-28 Thread Hal Finkel via cfe-commits
hfinkel added a comment. In https://reviews.llvm.org/D22666#500328, @honggyu.kim wrote: > In https://reviews.llvm.org/D22666#500327, @rjmccall wrote: > > > In https://reviews.llvm.org/D22666#500326, @honggyu.kim wrote: > > > > > Should we also modify clang/test/CodeGen/mcount.c as well? I'm not

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-28 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment. In https://reviews.llvm.org/D22666#500329, @hfinkel wrote: > In this case, I think that making a simple test (changing the current test to > be) like test/CodeGen/stackrealign.c would be fine. If you have any > questions, please feel free to ask. Thanks. Please co

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-28 Thread Hal Finkel via cfe-commits
hfinkel added a comment. In https://reviews.llvm.org/D22666#500338, @honggyu.kim wrote: > In https://reviews.llvm.org/D22666#500329, @hfinkel wrote: > > > In this case, I think that making a simple test (changing the current test > > to be) like test/CodeGen/stackrealign.c would be fine. If you

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-31 Thread Honggyu Kim via cfe-commits
honggyu.kim updated the summary for this revision. honggyu.kim updated this revision to Diff 66276. honggyu.kim added a comment. I've updated the testcase again it adds 2 more tests for -O2 and without -pg. Please have a look at it. $ llvm-lit mcount.c -- Testing: 1 tests, 1 threads -- PASS

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-08-04 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment. Hi Renato and Saleem, I found one more testcase that has to be changed. It's in `llvm/tools/clang/test/Frontend/gnu-mcount.c`. But strangely, some cases provide mcount name with prefix '\01' such as below: class ARMTargetInfo : public TargetInfo { ... public

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-08-05 Thread Saleem Abdulrasool via cfe-commits
compnerd added a comment. The `\01` is to prevent the mangler from touching the function name. If you noticed the check tags in the quoted test, some targets expect it to be decorated and others do not. What exactly do you mean that `lit` has a strings matching with `\01`? Its not a string `

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-08-05 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment. In https://reviews.llvm.org/D22666#506884, @compnerd wrote: > The `\01` is to prevent the mangler from touching the function name. If you > noticed the check tags in the quoted test, some targets expect it to be > decorated and others do not. What exactly do you m

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-08-05 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment. I see the difference now. Below is the originally generated IR without this patch. It shows `\01` clearly in `call void @"\01__gnu_mcount_nc"()`. $ clang -target armv7-unknown-none-eabi -pg -meabi gnu -S -emit-llvm -o - test-mcount.c ; ModuleID = 'mcount.c' s

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-08-07 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment. In https://reviews.llvm.org/D22666#506884, @compnerd wrote: > The `\01` is to prevent the mangler from touching the function name. If you > noticed the check tags in the quoted test, some targets expect it to be > decorated and others do not. What exactly do you m