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 797 - Compile VMCore with -fno-exceptions
Summary: Compile VMCore with -fno-exceptions
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Core LLVM classes (show other bugs)
Version: 1.0
Hardware: All All
: P enhancement
Assignee: Reid Spencer
URL:
Keywords: build-problem, code-cleanup
Depends on:
Blocks:
 
Reported: 2006-06-01 19:58 PDT by Reid Spencer
Modified: 2010-02-22 12:47 PST (History)
2 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 Reid Spencer 2006-06-01 19:58:53 PDT
We might be able to reduce the size of libVMCore.a by compiling it with the
-fno-exceptions flag. This prevents the compiler from generating functions that
know how to propagate exceptions. VMCore is very close to being exception
handling free. With a little work, we could make it exception free and turn 
this flag on permanently in the lib/VMCore/Makefile.

Here are the outstanding issues:

Pass.cpp in the constructor of FunctionPass needs to handle exceptions coming
from the bytecode reader when its function is materialized. Possible solutions:
  1. Don't have bytecode reader throw exceptions (big change). This actually 
     implies that any ModuleProvider would not be able to throw exceptions.
  2. Move Pass.cpp out of VMCore
  3. Rearrange the code so that Pass.cpp is not the thing doing the function
     materialization.

Verifier.cpp throws an exception when it checks abortIfBroken(). This is a
feature used by the bcanalyzer and llvm-as.  Both programs could be made to just
abort if the verifier fails.

The libraries VMCore depends upon (Support, bzip2, System) do not throw in
anything that VMCore includes or calls. 

Since VMCore has a lot of functions, this could be a big win for library size.
Comment 1 Chris Lattner 2006-06-02 12:35:04 PDT
I'd like to take this farther: can we eliminate exceptions from all of LLVM?

The single place where they are the most useful is in libsystem, but we've already found that we don't 
catch the exceptions in a majority of cases.  Also, traditional error handling is a well known science...

-Chris
Comment 2 Reid Spencer 2006-06-02 12:49:59 PDT
> I'd like to take this farther: can we eliminate exceptions from all of LLVM?

Certain libraries (Analysis, etc.) already don't throw exceptions. We could turn
on -fno-exceptions generally and then do the same hack we did for -pedantic in
the individual makefiles by removing -fno-exceptions where a given library throws.

> The single place where they are the most useful is in libsystem, but we've
> already found that we don't catch the exceptions in a majority of cases.

We have? Could you give me an example? All the tools have exception handlers in
their main.
Comment 3 Chris Lattner 2006-06-02 13:03:27 PDT
Sounds good.

I don't remember the specifics, but coverity uncovered a number of them, which I fixed back then.
Comment 4 Reid Spencer 2006-07-26 11:23:44 PDT
What's the status of this? Are we trying to remove exceptions from all of LLVM
for 1.8?
Comment 5 Chris Lattner 2006-07-26 13:04:44 PDT
Not going to happen for 1.8.  Hopefully for 1.9, we're pretty close already.

-Chris
Comment 6 Reid Spencer 2006-07-26 15:15:47 PDT
I just built LLVM with -fno-exceptions turned on in LLVMCore. Everything built
fine and it passed regression tests. I suppose that's not enough as the real
test would be to cause an exception?  Perhaps we should have some regression
tests to try a couple exceptions .. say a bad file name or something.
Comment 7 Chris Lattner 2006-07-26 15:20:28 PDT
Right.  I don't see any value in trying to push to get a half-baked solution for 1.8.  We might as well do it 
right for 1.9.

-Chris
Comment 8 Reid Spencer 2006-08-18 01:46:41 PDT
The grep tool tells me that these libraries:

./lib/AsmParser/Makefile
./lib/Bytecode/Archive/Makefile
./lib/Bytecode/Reader/Makefile
./lib/Debugger/Makefile
./lib/Support/Makefile
./lib/System/Makefile

Are the only ones that remain with "REQUIRES_EH". Does anyone know if 
exceptions have been completely removed from any of these? We should get 
this cleaned up so we can eliminate EH from all the tools and finally 
compile llvm with -fno-exceptions.
Comment 10 Chris Lattner 2006-08-18 12:07:01 PDT
nice work on asmparser.  I think that once libsystem/support/bytecode are converted over, we would be 
ready to make the big switch.  Stuff like libdebugger/bugpoint are a  big deal.
Comment 11 Reid Spencer 2006-08-18 12:26:58 PDT
Reminder: This patch:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20060814/036868.html
which comments out setting -fno-exceptions, needs to be reverted once the
Bytecode, Support and System libraries are exception free. 
Comment 12 Reid Spencer 2006-08-24 14:00:09 PDT
With numerous recent patches (too many to list here), we are now exception free
in the lib/System, lib/Support, and lib/VMCore libraries. The only remaining
exception code is in lib/Bytecode and lib/Debugger.

.. getting closer.
Comment 13 Chris Lattner 2006-08-24 17:37:39 PDT
A note: the only tool that uses libdebugger is llvm-db.  Once the .bc handling stuff is EH free, almost all of 
LLVM (everything but libdebugger and llvm-db) could have -fno-exceptions enabled.

-Chris
Comment 14 Reid Spencer 2006-08-24 18:01:25 PDT
Yes, that's what I was planning to do .. leave REQUIRES_EH turned on in
lib/Debugger and tools/llvm-ld and then uncomment the -fno-exceptions lines in
Makefile.rules so that the rest of LLVM is exception free.

Unfortunately, getting the exceptions out of the Archive/Bytecode stuff is
non-trivial, but it will happen soon.

Mine.
Comment 15 Reid Spencer 2006-08-25 14:57:37 PDT
Fixed. LLVM now builds with -fno-exceptions except in lib/Debug and the tools.

This leads to the following reduction in library and executable sizes for
an X86/Linux platform:
                DEBUG BUILD                RELEASE BUILD
         before     after   delta     before   after    delta
lib    162,328K  157,616K   4,712    17,864K  16,416K  1,448K
bin    571,444K  557,156K  14,288    63,296K   56,996K 6,300K

Debug   Improvement: 19,000K (2.59%)
Release Improvement:  7,748K (9.55%)