mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-04 21:31:03 +00:00
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
This commit is contained in:
parent
f3e4f0e615
commit
99655e16a6
@ -206,11 +206,6 @@ else
|
|||||||
OPTIMIZE_OPTION := -O2
|
OPTIMIZE_OPTION := -O2
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# IF REQUIRES_EH=1 is specified then don't disable exceptions
|
|
||||||
#ifndef REQUIRES_EH
|
|
||||||
# CXX.Flags += -fno-exceptions
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ifdef ENABLE_PROFILING
|
ifdef ENABLE_PROFILING
|
||||||
BuildMode := Profile
|
BuildMode := Profile
|
||||||
CXX.Flags := $(OPTIMIZE_OPTION) -pg -g
|
CXX.Flags := $(OPTIMIZE_OPTION) -pg -g
|
||||||
@ -243,6 +238,11 @@ else
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# IF REQUIRES_EH=1 is specified then don't disable exceptions
|
||||||
|
#ifndef REQUIRES_EH
|
||||||
|
# CXX.Flags += -fno-exceptions
|
||||||
|
#endif
|
||||||
|
|
||||||
# If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
|
# If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
|
||||||
# then disable assertions by defining the appropriate preprocessor symbols.
|
# then disable assertions by defining the appropriate preprocessor symbols.
|
||||||
ifdef DISABLE_ASSERTIONS
|
ifdef DISABLE_ASSERTIONS
|
||||||
|
@ -45,12 +45,6 @@ namespace sys {
|
|||||||
/// @brief Open program as dynamic library.
|
/// @brief Open program as dynamic library.
|
||||||
DynamicLibrary();
|
DynamicLibrary();
|
||||||
|
|
||||||
/// This is the constructor for DynamicLibrary instances. It will open
|
|
||||||
/// the dynamic library specified by the filename Path.
|
|
||||||
/// @throws std::string indicating why the library couldn't be opened.
|
|
||||||
/// @brief Open a dynamic library.
|
|
||||||
DynamicLibrary(const char* filename);
|
|
||||||
|
|
||||||
/// After destruction, the symbols of the library will no longer be
|
/// After destruction, the symbols of the library will no longer be
|
||||||
/// available to the program. It is important to make sure the lifespan
|
/// available to the program. It is important to make sure the lifespan
|
||||||
/// of a DynamicLibrary exceeds the lifetime of the pointers returned
|
/// of a DynamicLibrary exceeds the lifetime of the pointers returned
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
LEVEL = ../../..
|
LEVEL = ../../..
|
||||||
LIBRARYNAME = LLVMArchive
|
LIBRARYNAME = LLVMArchive
|
||||||
REQUIRES_EH := 1
|
|
||||||
|
|
||||||
# We only want an archive so only those modules actually used by a tool are
|
# We only want an archive so only those modules actually used by a tool are
|
||||||
# included.
|
# included.
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
LEVEL = ../../..
|
LEVEL = ../../..
|
||||||
LIBRARYNAME = LLVMArchive
|
LIBRARYNAME = LLVMArchive
|
||||||
REQUIRES_EH := 1
|
|
||||||
|
|
||||||
# We only want an archive so only those modules actually used by a tool are
|
# We only want an archive so only those modules actually used by a tool are
|
||||||
# included.
|
# included.
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
LEVEL = ../../..
|
LEVEL = ../../..
|
||||||
LIBRARYNAME = LLVMBCReader
|
LIBRARYNAME = LLVMBCReader
|
||||||
BUILD_ARCHIVE = 1
|
BUILD_ARCHIVE = 1
|
||||||
REQUIRES_EH := 1
|
|
||||||
|
|
||||||
include $(LEVEL)/Makefile.common
|
include $(LEVEL)/Makefile.common
|
||||||
|
|
||||||
|
@ -1943,14 +1943,18 @@ void BytecodeReader::ParseFunctionLazily() {
|
|||||||
/// ParseAllFunctionBodies.
|
/// ParseAllFunctionBodies.
|
||||||
/// @see ParseAllFunctionBodies
|
/// @see ParseAllFunctionBodies
|
||||||
/// @see ParseBytecode
|
/// @see ParseBytecode
|
||||||
void BytecodeReader::ParseFunction(Function* Func) {
|
bool BytecodeReader::ParseFunction(Function* Func, std::string* ErrMsg) {
|
||||||
|
|
||||||
|
if (setjmp(context))
|
||||||
|
return true;
|
||||||
|
|
||||||
// Find {start, end} pointers and slot in the map. If not there, we're done.
|
// Find {start, end} pointers and slot in the map. If not there, we're done.
|
||||||
LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.find(Func);
|
LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.find(Func);
|
||||||
|
|
||||||
// Make sure we found it
|
// Make sure we found it
|
||||||
if (Fi == LazyFunctionLoadMap.end()) {
|
if (Fi == LazyFunctionLoadMap.end()) {
|
||||||
error("Unrecognized function of type " + Func->getType()->getDescription());
|
error("Unrecognized function of type " + Func->getType()->getDescription());
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockStart = At = Fi->second.Buf;
|
BlockStart = At = Fi->second.Buf;
|
||||||
@ -1960,6 +1964,7 @@ void BytecodeReader::ParseFunction(Function* Func) {
|
|||||||
LazyFunctionLoadMap.erase(Fi);
|
LazyFunctionLoadMap.erase(Fi);
|
||||||
|
|
||||||
this->ParseFunctionBody(Func);
|
this->ParseFunctionBody(Func);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The ParseAllFunctionBodies method parses through all the previously
|
/// The ParseAllFunctionBodies method parses through all the previously
|
||||||
@ -1969,7 +1974,10 @@ void BytecodeReader::ParseFunction(Function* Func) {
|
|||||||
/// the function definitions are located. This function uses that information
|
/// the function definitions are located. This function uses that information
|
||||||
/// to materialize the functions.
|
/// to materialize the functions.
|
||||||
/// @see ParseBytecode
|
/// @see ParseBytecode
|
||||||
void BytecodeReader::ParseAllFunctionBodies() {
|
bool BytecodeReader::ParseAllFunctionBodies(std::string* ErrMsg) {
|
||||||
|
if (setjmp(context))
|
||||||
|
return true;
|
||||||
|
|
||||||
LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.begin();
|
LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.begin();
|
||||||
LazyFunctionMap::iterator Fe = LazyFunctionLoadMap.end();
|
LazyFunctionMap::iterator Fe = LazyFunctionLoadMap.end();
|
||||||
|
|
||||||
@ -1981,7 +1989,7 @@ void BytecodeReader::ParseAllFunctionBodies() {
|
|||||||
++Fi;
|
++Fi;
|
||||||
}
|
}
|
||||||
LazyFunctionLoadMap.clear();
|
LazyFunctionLoadMap.clear();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parse the global type list
|
/// Parse the global type list
|
||||||
|
@ -147,26 +147,21 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
/// @brief Parse all function bodies
|
/// @brief Parse all function bodies
|
||||||
void ParseAllFunctionBodies();
|
bool ParseAllFunctionBodies(std::string* ErrMsg);
|
||||||
|
|
||||||
/// @brief Parse the next function of specific type
|
/// @brief Parse the next function of specific type
|
||||||
void ParseFunction(Function* Func) ;
|
bool ParseFunction(Function* Func, std::string* ErrMsg) ;
|
||||||
|
|
||||||
/// This method is abstract in the parent ModuleProvider class. Its
|
/// This method is abstract in the parent ModuleProvider class. Its
|
||||||
/// implementation is identical to the ParseFunction method.
|
/// implementation is identical to the ParseFunction method.
|
||||||
/// @see ParseFunction
|
/// @see ParseFunction
|
||||||
/// @brief Make a specific function materialize.
|
/// @brief Make a specific function materialize.
|
||||||
virtual bool materializeFunction(Function *F, std::string *ErrInfo = 0) {
|
virtual bool materializeFunction(Function *F, std::string *ErrMsg = 0) {
|
||||||
LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.find(F);
|
LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.find(F);
|
||||||
if (Fi == LazyFunctionLoadMap.end()) return false;
|
if (Fi == LazyFunctionLoadMap.end())
|
||||||
try {
|
return false;
|
||||||
ParseFunction(F);
|
if (ParseFunction(F,ErrMsg))
|
||||||
} catch (std::string &ErrStr) {
|
|
||||||
if (ErrInfo) *ErrInfo = ErrStr;
|
|
||||||
return true;
|
return true;
|
||||||
} catch (...) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,15 +169,9 @@ public:
|
|||||||
/// implementation is identical to ParseAllFunctionBodies.
|
/// implementation is identical to ParseAllFunctionBodies.
|
||||||
/// @see ParseAllFunctionBodies
|
/// @see ParseAllFunctionBodies
|
||||||
/// @brief Make the whole module materialize
|
/// @brief Make the whole module materialize
|
||||||
virtual Module* materializeModule(std::string *ErrInfo = 0) {
|
virtual Module* materializeModule(std::string *ErrMsg = 0) {
|
||||||
try {
|
if (ParseAllFunctionBodies(ErrMsg))
|
||||||
ParseAllFunctionBodies();
|
|
||||||
} catch (std::string &ErrStr) {
|
|
||||||
if (ErrInfo) *ErrInfo = ErrStr;
|
|
||||||
return 0;
|
return 0;
|
||||||
} catch (...) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return TheModule;
|
return TheModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,12 +45,10 @@ using namespace llvm::sys;
|
|||||||
//=== independent code.
|
//=== independent code.
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
static bool did_initialize_ltdl = false;
|
|
||||||
|
|
||||||
static inline void check_ltdl_initialization() {
|
static inline void check_ltdl_initialization() {
|
||||||
|
static bool did_initialize_ltdl = false;
|
||||||
if (!did_initialize_ltdl) {
|
if (!did_initialize_ltdl) {
|
||||||
if (0 != lt_dlinit())
|
assert(0 == lt_dlinit() || "Can't init the ltdl library");
|
||||||
throw std::string(lt_dlerror());
|
|
||||||
did_initialize_ltdl = true;
|
did_initialize_ltdl = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,13 +60,13 @@ DynamicLibrary::DynamicLibrary() : handle(0) {
|
|||||||
|
|
||||||
lt_dlhandle a_handle = lt_dlopen(0);
|
lt_dlhandle a_handle = lt_dlopen(0);
|
||||||
|
|
||||||
if (a_handle == 0)
|
assert(a_handle == 0 || "Can't open program as dynamic library");
|
||||||
throw std::string("Can't open program as dynamic library");
|
|
||||||
|
|
||||||
handle = a_handle;
|
handle = a_handle;
|
||||||
OpenedHandles.push_back(a_handle);
|
OpenedHandles.push_back(a_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
DynamicLibrary::DynamicLibrary(const char*filename) : handle(0) {
|
DynamicLibrary::DynamicLibrary(const char*filename) : handle(0) {
|
||||||
check_ltdl_initialization();
|
check_ltdl_initialization();
|
||||||
|
|
||||||
@ -83,6 +81,7 @@ DynamicLibrary::DynamicLibrary(const char*filename) : handle(0) {
|
|||||||
handle = a_handle;
|
handle = a_handle;
|
||||||
OpenedHandles.push_back(a_handle);
|
OpenedHandles.push_back(a_handle);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
DynamicLibrary::~DynamicLibrary() {
|
DynamicLibrary::~DynamicLibrary() {
|
||||||
lt_dlhandle a_handle = (lt_dlhandle) handle;
|
lt_dlhandle a_handle = (lt_dlhandle) handle;
|
||||||
|
@ -25,8 +25,8 @@ impatient, here's a high level summary of the library's requirements.
|
|||||||
3. No exposed system-specific functions.
|
3. No exposed system-specific functions.
|
||||||
4. No exposed system-specific data.
|
4. No exposed system-specific data.
|
||||||
5. Data in lib/System classes must use only simple C++ intrinsic types.
|
5. Data in lib/System classes must use only simple C++ intrinsic types.
|
||||||
6. Errors are handled by throwing std::string *only*.
|
6. Errors are handled by returning "true" and setting an optional std::string
|
||||||
7. Library must not throw any exceptions except std::string.
|
7. Library must not throw any exceptions, period.
|
||||||
8. Interface functions must not have throw() specifications.
|
8. Interface functions must not have throw() specifications.
|
||||||
9. No duplicate function impementations are permitted within an operating
|
9. No duplicate function impementations are permitted within an operating
|
||||||
system class.
|
system class.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user