Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EH: Should turn invoke+resume into call #2285

Closed
lattner opened this issue Jan 14, 2008 · 2 comments
Closed

EH: Should turn invoke+resume into call #2285

lattner opened this issue Jan 14, 2008 · 2 comments
Labels
bugzilla Issues migrated from bugzilla code-quality slow-compile

Comments

@lattner
Copy link
Collaborator

lattner commented Jan 14, 2008

Bugzilla Link 1913
Resolution FIXED
Resolved on Oct 14, 2011 21:22
Version trunk
OS All
CC @asl,@efriedma-quic,@nlewycky

Extended Description

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
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

@efriedma-quic
Copy link
Collaborator

This works correctly now.

@llvmbot
Copy link
Collaborator

llvmbot commented Nov 26, 2021

mentioned in issue llvm/llvm-bugzilla-archive#1916

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
trevor-m pushed a commit to trevor-m/llvm-project that referenced this issue Apr 20, 2023
llvm#1450 and llvm#2205 as complete; they are just wording changes in the standard. Mark issues llvm#2359, llvm#2320 and llvm#2322 as complete - libc++ implements them already.

llvm-svn: 202671
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla code-quality slow-compile
Projects
None yet
Development

No branches or pull requests

3 participants