tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] if (0 == 1) { some_code(); }


From: David Mertens
Subject: Re: [Tinycc-devel] if (0 == 1) { some_code(); }
Date: Sun, 24 Apr 2016 07:04:16 -0400

Hello Sergey,

Skipping unneeded code, and not even compiling it, could make tcc a bit faster. However, as test 78 indicates, any implementation of tcc that skips blocks will need some logic to detect the presence of labels.

For example, if gvtst detected a static value that would be false, it could compile the code separately. Then, during the compilation of that block, if it detected a label, it could add what it compiled the code before moving on. Otherwise (since there would be no way to get to the code), it could discard it. The problem with such an approach is that tcc will run slower (maybe only marginal, but slower nonetheless). The resulting object file will be smaller, but that's not tcc's primary aim.

If you want the feature without the compilation overhead, a flag might do it, but I don't like the global nature of that effect. An alternative is to have a pragma that can be applied and lifted locally. The Perl programmer in me much prefers the pragma approach, but others may dissent.

David

On Sun, Apr 24, 2016 at 5:53 AM, Sergey Korshunoff <address@hidden> wrote:
What to do with 78_vla_label test? May be a tcc switch to skip unused code?
void f1(int argc) {
  char test[argc];
  if(0)
  label:
    printf("boom!\n");
  if(argc-- == 0)
    return;
  goto label;
}

_______________________________________________
Tinycc-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/tinycc-devel



--
 "Debugging is twice as hard as writing the code in the first place.
  Therefore, if you write the code as cleverly as possible, you are,
  by definition, not smart enough to debug it." -- Brian Kernighan

reply via email to

[Prev in Thread] Current Thread [Next in Thread]