[LLVMbugs] [Bug 5176] New: small testcase shows much badness (EH, constant folding)
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Tue Oct 13 08:58:51 PDT 2009
http://llvm.org/bugs/show_bug.cgi?id=5176
Summary: small testcase shows much badness (EH, constant folding)
Product: tools
Version: 2.2
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: llvm-g++
AssignedTo: unassignedbugs at nondot.org
ReportedBy: clattner at apple.com
CC: llvmbugs at cs.uiuc.edu
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>;
}
}
When compiled with:
$ llvm-gcc t.cc -S -o - -emit-llvm -O3
There are two problems. First, we get a bunch of horrible unfolded constant
expressions like this:
inttoptr (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256
zext (i64 ptrtoint (i8 (%struct.A*, i32*)* @_ZNK1A3fooEPi to i64) to i256),
i256 64), i256 -6277101735386680763495507056286727952638980837032266301441),
i256 6277101735386680763835789423207666416102355444464034512895), i256 shl
(i256 zext (i64 ptrtoint (%struct.A* @a to i64) to i256), i256 192)), i256 64)
to i64) to i8 (%struct.A*, i32*)*)
Quite impressive, but not very useful.
The second problem is EH related, we get 3 copies of the exact same landing
pad:
pad: ; preds = %.noexc,
%_ZNK2B2clEv.exit.i.i
%eh_ptr = tail call i8* @llvm.eh.exception() ; <i8*> [#uses=2]
%eh_select14 = tail call i64 (i8*, i8*, ...)* @llvm.eh.selector.i64(i8*
%eh_ptr, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* null) ;
<i64> [#uses=0]
tail call void @_ZdlPv(i8* %0) nounwind
br label %Unwind
lpad15: ; preds = %.noexc41,
%_ZNK2B2clEv.exit.i.i40
%eh_ptr16 = tail call i8* @llvm.eh.exception() ; <i8*> [#uses=2]
%eh_select18 = tail call i64 (i8*, i8*, ...)* @llvm.eh.selector.i64(i8*
%eh_ptr16, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* null) ;
<i64> [#uses=0]
tail call void @_ZdlPv(i8* %8) nounwind
br label %Unwind
lpad19: ; preds = %.noexc33,
%_ZNK2B2clEv.exit.i.i32
%eh_ptr20 = tail call i8* @llvm.eh.exception() ; <i8*> [#uses=2]
%eh_select22 = tail call i64 (i8*, i8*, ...)* @llvm.eh.selector.i64(i8*
%eh_ptr20, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* null) ;
<i64> [#uses=0]
tail call void @_ZdlPv(i8* %16) nounwind
br label %Unwind
-Chris
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list