[LLVMbugs] [Bug 1913] New: Should turn invoke+resume into call

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Mon Jan 14 10:06:01 PST 2008


http://llvm.org/bugs/show_bug.cgi?id=1913

           Summary: Should turn invoke+resume into call
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Keywords: code-quality, slow-compile
          Severity: enhancement
          Priority: P2
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sabre at nondot.org
                CC: llvmbugs at cs.uiuc.edu


It is common in C++ code to end up with an invoke whose unwind destination just
does the C++ equivalent of an unwind.  This should be turned into a call,
saving on code size and speeding up unwinding.  For example, here is a
testcase:

#include <string>
int f() {
  std::string s("hola");
  return s.length();
}

This compiles to:

...
 invoke void @_ZNSsC1EPKcRKSaIcE(...)
                        to label %bb69 unwind label %lpad
...
        %tmp116 = invoke i32 @_ZN9__gnu_cxx18__exchange_and_addEPVii( i32*
%tmp114, i32 -1 )
                        to label %invcont115 unwind label %lpad148
...
pad:            ; preds = %entry
 %eh_ptr = call i8* @llvm.eh.exception( )               ; <i8*> [#uses=2]
 %eh_select147 = call i32 (i8*, i8*, ...)* @llvm.eh.selector.i32( i8* 
%eh_ptr, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* null )
 br label %Unwind

lpad148:                ; preds = %bb111
 %eh_ptr149 = call i8* @llvm.eh.exception( )            ; <i8*> [#uses=2]
 %eh_select151 = call i32 (i8*, i8*, ...)* @llvm.eh.selector.i32( i8* 
%eh_ptr149, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* null )
 br label %Unwind

Unwind:         ; preds = %lpad148, %lpad
        %eh_exception.0 = phi i8* [ %eh_ptr, %lpad ], [ %eh_ptr149, %lpad148 ]
        call i32 (...)* @_Unwind_Resume_or_Rethrow( i8* %eh_exception.0 )
 unreachable

Both of these invokes can be turned into (throwing) call instructions, saving
code size and reducing compile time.

-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