llvm.org GIT mirror llvm / 99655e1
For PR797: Final commit for this bug. This removes the last EH holdouts in LLVM and turns off exception support by using the -fno-exceptions option. This leads to the following reduction in library and executable sizes: 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%) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29882 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Spencer 14 years ago
9 changed file(s) with 32 addition(s) and 45 deletion(s). Raw diff Collapse all Expand all
205205 OPTIMIZE_OPTION := -O2
206206 endif
207207
208 # IF REQUIRES_EH=1 is specified then don't disable exceptions
209 #ifndef REQUIRES_EH
210 # CXX.Flags += -fno-exceptions
211 #endif
212
213208 ifdef ENABLE_PROFILING
214209 BuildMode := Profile
215210 CXX.Flags := $(OPTIMIZE_OPTION) -pg -g
241236 KEEP_SYMBOLS := 1
242237 endif
243238 endif
239
240 # IF REQUIRES_EH=1 is specified then don't disable exceptions
241 #ifndef REQUIRES_EH
242 # CXX.Flags += -fno-exceptions
243 #endif
244244
245245 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
246246 # then disable assertions by defining the appropriate preprocessor symbols.
4343 /// @throws std::string indicating why the program couldn't be opened.
4444 /// @brief Open program as dynamic library.
4545 DynamicLibrary();
46
47 /// This is the constructor for DynamicLibrary instances. It will open
48 /// the dynamic library specified by the filename Path.
49 /// @throws std::string indicating why the library couldn't be opened.
50 /// @brief Open a dynamic library.
51 DynamicLibrary(const char* filename);
5246
5347 /// After destruction, the symbols of the library will no longer be
5448 /// available to the program. It is important to make sure the lifespan
88
99 LEVEL = ../../..
1010 LIBRARYNAME = LLVMArchive
11 REQUIRES_EH := 1
1211
1312 # We only want an archive so only those modules actually used by a tool are
1413 # included.
88
99 LEVEL = ../../..
1010 LIBRARYNAME = LLVMArchive
11 REQUIRES_EH := 1
1211
1312 # We only want an archive so only those modules actually used by a tool are
1413 # included.
88 LEVEL = ../../..
99 LIBRARYNAME = LLVMBCReader
1010 BUILD_ARCHIVE = 1
11 REQUIRES_EH := 1
1211
1312 include $(LEVEL)/Makefile.common
1413
19421942 /// ParseAllFunctionBodies.
19431943 /// @see ParseAllFunctionBodies
19441944 /// @see ParseBytecode
1945 void BytecodeReader::ParseFunction(Function* Func) {
1945 bool BytecodeReader::ParseFunction(Function* Func, std::string* ErrMsg) {
1946
1947 if (setjmp(context))
1948 return true;
1949
19461950 // Find {start, end} pointers and slot in the map. If not there, we're done.
19471951 LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.find(Func);
19481952
19491953 // Make sure we found it
19501954 if (Fi == LazyFunctionLoadMap.end()) {
19511955 error("Unrecognized function of type " + Func->getType()->getDescription());
1952 return;
1956 return true;
19531957 }
19541958
19551959 BlockStart = At = Fi->second.Buf;
19591963 LazyFunctionLoadMap.erase(Fi);
19601964
19611965 this->ParseFunctionBody(Func);
1966 return false;
19621967 }
19631968
19641969 /// The ParseAllFunctionBodies method parses through all the previously
19681973 /// the function definitions are located. This function uses that information
19691974 /// to materialize the functions.
19701975 /// @see ParseBytecode
1971 void BytecodeReader::ParseAllFunctionBodies() {
1976 bool BytecodeReader::ParseAllFunctionBodies(std::string* ErrMsg) {
1977 if (setjmp(context))
1978 return true;
1979
19721980 LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.begin();
19731981 LazyFunctionMap::iterator Fe = LazyFunctionLoadMap.end();
19741982
19801988 ++Fi;
19811989 }
19821990 LazyFunctionLoadMap.clear();
1983
1991 return false;
19841992 }
19851993
19861994 /// Parse the global type list
146146 );
147147
148148 /// @brief Parse all function bodies
149 void ParseAllFunctionBodies();
149 bool ParseAllFunctionBodies(std::string* ErrMsg);
150150
151151 /// @brief Parse the next function of specific type
152 void ParseFunction(Function* Func) ;
152 bool ParseFunction(Function* Func, std::string* ErrMsg) ;
153153
154154 /// This method is abstract in the parent ModuleProvider class. Its
155155 /// implementation is identical to the ParseFunction method.
156156 /// @see ParseFunction
157157 /// @brief Make a specific function materialize.
158 virtual bool materializeFunction(Function *F, std::string *ErrInfo = 0) {
158 virtual bool materializeFunction(Function *F, std::string *ErrMsg = 0) {
159159 LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.find(F);
160 if (Fi == LazyFunctionLoadMap.end()) return false;
161 try {
162 ParseFunction(F);
163 } catch (std::string &ErrStr) {
164 if (ErrInfo) *ErrInfo = ErrStr;
160 if (Fi == LazyFunctionLoadMap.end())
161 return false;
162 if (ParseFunction(F,ErrMsg))
165163 return true;
166 } catch (...) {
167 return true;
168 }
169164 return false;
170165 }
171166
173168 /// implementation is identical to ParseAllFunctionBodies.
174169 /// @see ParseAllFunctionBodies
175170 /// @brief Make the whole module materialize
176 virtual Module* materializeModule(std::string *ErrInfo = 0) {
177 try {
178 ParseAllFunctionBodies();
179 } catch (std::string &ErrStr) {
180 if (ErrInfo) *ErrInfo = ErrStr;
171 virtual Module* materializeModule(std::string *ErrMsg = 0) {
172 if (ParseAllFunctionBodies(ErrMsg))
181173 return 0;
182 } catch (...) {
183 return 0;
184 }
185174 return TheModule;
186175 }
187176
4444 //=== independent code.
4545 //===----------------------------------------------------------------------===//
4646
47 static bool did_initialize_ltdl = false;
48
4947 static inline void check_ltdl_initialization() {
48 static bool did_initialize_ltdl = false;
5049 if (!did_initialize_ltdl) {
51 if (0 != lt_dlinit())
52 throw std::string(lt_dlerror());
50 assert(0 == lt_dlinit() || "Can't init the ltdl library");
5351 did_initialize_ltdl = true;
5452 }
5553 }
6159
6260 lt_dlhandle a_handle = lt_dlopen(0);
6361
64 if (a_handle == 0)
65 throw std::string("Can't open program as dynamic library");
62 assert(a_handle == 0 || "Can't open program as dynamic library");
6663
6764 handle = a_handle;
6865 OpenedHandles.push_back(a_handle);
6966 }
7067
68 /*
7169 DynamicLibrary::DynamicLibrary(const char*filename) : handle(0) {
7270 check_ltdl_initialization();
7371
8280 handle = a_handle;
8381 OpenedHandles.push_back(a_handle);
8482 }
83 */
8584
8685 DynamicLibrary::~DynamicLibrary() {
8786 lt_dlhandle a_handle = (lt_dlhandle) handle;
2424 3. No exposed system-specific functions.
2525 4. No exposed system-specific data.
2626 5. Data in lib/System classes must use only simple C++ intrinsic types.
27 6. Errors are handled by throwing std::string *only*.
28 7. Library must not throw any exceptions except std::string.
27 6. Errors are handled by returning "true" and setting an optional std::string
28 7. Library must not throw any exceptions, period.
2929 8. Interface functions must not have throw() specifications.
3030 9. No duplicate function impementations are permitted within an operating
3131 system class.