[InstCombine] Remove trivially empty lifetime start/end ranges.
authorArnaud A. de Grandmaison <arnaud.degrandmaison@arm.com>
Thu, 1 Oct 2015 14:54:31 +0000 (14:54 +0000)
committerArnaud A. de Grandmaison <arnaud.degrandmaison@arm.com>
Thu, 1 Oct 2015 14:54:31 +0000 (14:54 +0000)
commitf6e1ea73e9366169dc696da82734ebe687b54051
tree648b2f05628d33e2755cc3e27965c6e28e355b36
parent4e00ed4cbf14d443a11a15818510cba6cde1e5f7
[InstCombine] Remove trivially empty lifetime start/end ranges.

Summary:
Some passes may open up opportunities for optimizations, leaving empty
lifetime start/end ranges. For example, with the following code:

    void foo(char *, char *);
    void bar(int Size, bool flag) {
      for (int i = 0; i < Size; ++i) {
        char text[1];
        char buff[1];
        if (flag)
          foo(text, buff); // BBFoo
      }
    }

the loop unswitch pass will create 2 versions of the loop, one with
flag==true, and the other one with flag==false, but always leaving
the BBFoo basic block, with lifetime ranges covering the scope of the for
loop. Simplify CFG will then remove BBFoo in the case where flag==false,
but will leave the lifetime markers.

This patch teaches InstCombine to remove trivially empty lifetime marker
ranges, that is ranges ending right after they were started (ignoring
debug info or other lifetime markers in the range).

This fixes PR24598: excessive compile time after r234581.

Reviewers: reames, chandlerc

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D13305

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249018 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineCalls.cpp
test/Transforms/InstCombine/lifetime.ll [new file with mode: 0644]