Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

llvm-gcc generates ton of duplicate landing pads #5736

Open Quuxplusone opened 15 years ago

Quuxplusone commented 15 years ago
Bugzilla Link PR5229
Status REOPENED
Importance P normal
Reported by Chris Lattner (clattner@nondot.org)
Reported on 2009-10-17 16:55:10 -0700
Last modified on 2011-04-12 12:02:43 -0700
Version trunk
Hardware PC All
CC anton@korobeynikov.info, baldrick@free.fr, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Consider this testcase:

struct A
{
  bool foo(int*) const;
} a;

struct B {};

struct B1 : B
{
  bool (A::*pmf)(int*) const;
  const A* pa;

  B1() : pmf(&A::foo), pa(&a) {}
  bool operator()() const { return (pa->*pmf)(new int); }
};

struct B2 : B
{
  B1 b1;

  B2(const B1& _b1) : b1(_b1) {}
  bool operator()() const { return b1(); }
};

template<int> struct C
{
  void bar(B2 b2) { while (b2()) ; }
  C() { bar(B2(B1())); }
};

void baz(int i){
  switch(i) {
    case 0: new C<0>;
    case 1: new C<1>;
    case 2: new C<2>;
  }
}

Compiled with llvm-gcc, it produces a ton of identical landing pads:

lpad:                                             ; preds = %.noexc,
%_ZNK2B2clEv.exit.i.i
  %eh_ptr = tail call i8* @llvm.eh.exception()    ; <i8*> [#uses=2]
  %upgraded.eh_select14 = tail call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* %eh_ptr, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* null) ; <i32> [#uses=0]
  tail call void @_ZdlPv(i8* %0) nounwind
  br label %Unwind

lpad15:                                           ; preds = %.noexc11,
%_ZNK2B2clEv.exit.i.i10
  %eh_ptr16 = tail call i8* @llvm.eh.exception()  ; <i8*> [#uses=2]
  %upgraded.eh_select18 = tail call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* %eh_ptr16, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* null) ; <i32> [#uses=0]
  tail call void @_ZdlPv(i8* %4) nounwind
  br label %Unwind

lpad19:                                           ; preds = %.noexc7,
%_ZNK2B2clEv.exit.i.i6
  %eh_ptr20 = tail call i8* @llvm.eh.exception()  ; <i8*> [#uses=2]
  %upgraded.eh_select22 = tail call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* %eh_ptr20, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* null) ; <i32> [#uses=0]
  tail call void @_ZdlPv(i8* %8) nounwind
  br label %Unwind

This is bad.
Quuxplusone commented 15 years ago
Does it really matter?  It looks like the branch folding pass unifies them
during codegen.
Quuxplusone commented 15 years ago

It is bad for compile time, among other things. The late codegen pass also has lots of limitations on merging.

Quuxplusone commented 13 years ago

LLVM-GCC has reached its end of life as far as llvm.org releases go. Please migrate to Clang or DragonEgg when possible. The llvm-gcc SVN repo will still continue to exist, so additional patches can go into it if you so desire, but since we have no more releases of it coming, it doesn't make sense to track bugs for it anymore.

If this is a problem that still exists with clang or DragonEgg, please file a new bug to track it. Thanks!

-Chris

Quuxplusone commented 13 years ago

Moving to dragonegg.