profile
viewpoint

Ask questionsInfinitely expanding file with `remove-nested-function`

For the following file:

struct a {
  template <typename aj> void b(aj) {}
};
auto c() -> a;
auto d() {
  c().b([] {
    a d = c();
    return d;
  });
}

cvise appears to get stuck in an "infinite" loop running:

clang_delta --transformation=remove-nested-function --counter=<idx>

If you run clang_delta --transformation=remove-nested-function --counter=1 manually 10 times (with the new input being the last output), then you get something like this:

struct a {
  template <typename aj> void b(aj) {}
};
auto c() -> a;
auto d() {
  c().b([] {
    a __trans_tmp_10 = c();
    a __trans_tmp_9 = __trans_tmp_10;
    a __trans_tmp_8 = __trans_tmp_9;
    a __trans_tmp_7 = __trans_tmp_8;
    a __trans_tmp_6 = __trans_tmp_7;
    a __trans_tmp_5 = __trans_tmp_6;
    a __trans_tmp_4 = __trans_tmp_5;
    a __trans_tmp_3 = __trans_tmp_4;
    a __trans_tmp_2 = __trans_tmp_3;
    a __trans_tmp_1 = __trans_tmp_2;
    a d = __trans_tmp_1;
    return d;
  });
}

While I was cvising one file, this count got up to 5812 before I killed it; the tail of the cvise log looked like this:

01:27:39 INFO (-545.8%, 608185 bytes, 6636 lines)
01:27:40 INFO (-545.9%, 608282 bytes, 6637 lines)
01:27:41 INFO (-546.0%, 608379 bytes, 6638 lines)
01:27:42 INFO (-546.1%, 608476 bytes, 6639 lines)
01:27:43 INFO (-546.2%, 608573 bytes, 6640 lines)
01:27:44 INFO (-546.3%, 608670 bytes, 6641 lines)
01:27:45 INFO (-546.4%, 608767 bytes, 6642 lines)
01:27:46 INFO (-546.5%, 608864 bytes, 6643 lines)
01:27:48 INFO (-546.6%, 608961 bytes, 6644 lines)
01:27:49 INFO (-546.7%, 609058 bytes, 6645 lines)
01:27:50 INFO (-546.8%, 609155 bytes, 6646 lines)
01:27:51 INFO (-546.9%, 609252 bytes, 6647 lines)
01:27:52 INFO (-547.0%, 609349 bytes, 6648 lines)
01:27:53 INFO (-547.1%, 609446 bytes, 6649 lines)
01:27:54 INFO (-547.2%, 609543 bytes, 6650 lines)
01:27:56 INFO (-547.3%, 609640 bytes, 6651 lines)
01:27:57 INFO (-547.5%, 609737 bytes, 6652 lines)
01:27:58 INFO (-547.6%, 609834 bytes, 6653 lines)
01:27:59 INFO (-547.7%, 609931 bytes, 6654 lines)
01:28:00 INFO (-547.8%, 610028 bytes, 6655 lines)
01:28:01 INFO (-547.9%, 610125 bytes, 6656 lines)
01:28:02 INFO (-548.0%, 610222 bytes, 6657 lines)
01:28:03 INFO (-548.1%, 610319 bytes, 6658 lines)
01:28:05 INFO (-548.2%, 610416 bytes, 6659 lines)
01:28:06 INFO (-548.3%, 610513 bytes, 6660 lines)

and cvise first stated doing --transformation=remove-nested-function at 00:06:27:

00:06:16 INFO ===< ClangPass::remove-namespace >===
00:06:20 INFO ===< ClangPass::aggregate-to-scalar >===
00:06:20 INFO ===< ClangPass::param-to-global >===
00:06:25 INFO ===< ClangPass::param-to-local >===
00:06:27 INFO ===< ClangPass::remove-nested-function >===

and tried no other passes -- that is, it spent 1h21m doing remove-nested-function with the file slowly getting larger every time.

marxin/cvise

Answer questions marxin

All right, so the input has grown 10x during the ClangPass::remove-nested-function pass. I'm going to add a bail-out limit when pass grows an input rapidly.

useful!

Related questions

No questions were found.
source:https://uonfu.com/
Github User Rank List