LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 1913 - EH: Should turn invoke+resume into call
Summary: EH: Should turn invoke+resume into call
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Scalar Optimizations (show other bugs)
Version: trunk
Hardware: PC All
: P enhancement
Assignee: Unassigned LLVM Bugs
URL:
Keywords: code-quality, slow-compile
Depends on:
Blocks:
 
Reported: 2008-01-14 12:06 PST by Chris Lattner
Modified: 2011-10-14 21:22 PDT (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Lattner 2008-01-14 12:06:00 PST
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
Comment 1 Eli Friedman 2011-10-14 21:22:49 PDT
This works correctly now.