summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-03-09 06:16:28 +0000
committerChris Lattner <sabre@nondot.org>2006-03-09 06:16:28 +0000
commitdaac729f4d7d13b64e64492f01287145f2c14b53 (patch)
treec8e5354e0045b9286211b0479994e0fbbc708c9d /runtime
parent04f96748574d447ea7bc6344a56f7e652d14f4f9 (diff)
downloadllvm-daac729f4d7d13b64e64492f01287145f2c14b53.tar.gz
llvm-daac729f4d7d13b64e64492f01287145f2c14b53.tar.bz2
llvm-daac729f4d7d13b64e64492f01287145f2c14b53.tar.xz
Make the new and old front-ends more similar: now neither uses __main.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26629 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtime')
-rw-r--r--runtime/GCCLibraries/crtend/Makefile4
-rw-r--r--runtime/GCCLibraries/crtend/README.txt2
-rw-r--r--runtime/GCCLibraries/crtend/crtend.c59
-rw-r--r--runtime/GCCLibraries/crtend/listend.ll23
4 files changed, 5 insertions, 83 deletions
diff --git a/runtime/GCCLibraries/crtend/Makefile b/runtime/GCCLibraries/crtend/Makefile
index 285f4be6d5..04e414fad6 100644
--- a/runtime/GCCLibraries/crtend/Makefile
+++ b/runtime/GCCLibraries/crtend/Makefile
@@ -20,7 +20,7 @@ DONT_BUILD_RELINKED = 1
LIBRARYNAME = crtend
BYTECODE_DESTINATION = $(CFERuntimeLibDir)
-MainSrc := crtend.c listend.ll
+MainSrc := crtend.c
GenericEHSrc := Exception.cpp
SJLJEHSrc := SJLJ-Exception.cpp
@@ -29,7 +29,7 @@ EXTRA_DIST := $(MainSrc) $(GenericEHSrc) $(SJLJEHSrc) \
include $(LEVEL)/Makefile.common
-MainObj := $(ObjDir)/crtend.bc $(ObjDir)/listend.bc
+MainObj := $(ObjDir)/crtend.bc
GenericEHObj := $(ObjDir)/Exception.bc
SJLJEHObj := $(ObjDir)/SJLJ-Exception.bc
diff --git a/runtime/GCCLibraries/crtend/README.txt b/runtime/GCCLibraries/crtend/README.txt
index ff070c442c..a763cb26dd 100644
--- a/runtime/GCCLibraries/crtend/README.txt
+++ b/runtime/GCCLibraries/crtend/README.txt
@@ -1,7 +1,7 @@
This directory contains the C and C++ runtime libraries for the LLVM GCC
front-ends. It is composed of four distinct pieces:
-1. __main and static ctor/dtor support. This is used by both C and C++ codes.
+1. __main: now dead, but provided for compatibility.
2. Generic EH support routines. This is used by C/C++ programs that use
setjmp/longjmp, and by C++ programs that make use of exceptions.
diff --git a/runtime/GCCLibraries/crtend/crtend.c b/runtime/GCCLibraries/crtend/crtend.c
index 74e7831dee..561b6fd241 100644
--- a/runtime/GCCLibraries/crtend/crtend.c
+++ b/runtime/GCCLibraries/crtend/crtend.c
@@ -7,65 +7,10 @@
*
*===----------------------------------------------------------------------===*
*
- * This file defines the __main function, which is used to run static
- * constructors and destructors in C++ programs, or with C programs that use GCC
- * extensions to accomplish the same effect.
- *
- * The main data structures used to implement this functionality is the
- * llvm.global_ctors and llvm.global_dtors lists, which are null terminated
- * lists of TorRec (defined below) structures.
+ * This file defines the __main function, which we preserve for backwards
+ * compatibility.
*
\*===----------------------------------------------------------------------===*/
-#include <stdlib.h>
-
-/* TorRec - The record type for each element of the ctor/dtor list */
-typedef struct TorRec {
- int Priority;
- void (*FP)(void);
-} TorRec;
-
-/* __llvm_getGlobalCtors, __llvm_getGlobalDtors - Interface to the LLVM
- * listend.ll file to get access to the start of the ctor and dtor lists...
- */
-TorRec *__llvm_getGlobalCtors(void);
-TorRec *__llvm_getGlobalDtors(void);
-
-static void run_destructors(void);
-
-/* __main - A call to this function is automatically inserted into the top of
- * the "main" function in the program compiled. This function is responsible
- * for calling static constructors before the program starts executing.
- */
void __main(void) {
- /* Loop over all of the constructor records, calling each function pointer. */
- TorRec *R = __llvm_getGlobalCtors();
-
- /* Recursively calling main is not legal C, but lots of people do it for
- * testing stuff. We might as well work for them.
- */
- static _Bool Initialized = 0;
- if (Initialized) return;
- Initialized = 1;
-
- /* Only register the global dtor handler if there is at least one global
- * dtor!
- */
- if (__llvm_getGlobalDtors()[0].FP)
- if (atexit(run_destructors))
- abort(); /* Should be able to install ONE atexit handler! */
-
- /* FIXME: This should sort the list by priority! */
- if (R->FP)
- for (; R->FP; ++R)
- R->FP();
-}
-
-static void run_destructors(void) {
- /* Loop over all of the destructor records, calling each function pointer. */
- TorRec *R = __llvm_getGlobalDtors();
-
- /* FIXME: This should sort the list by priority! */
- for (; R->FP; ++R)
- R->FP();
}
diff --git a/runtime/GCCLibraries/crtend/listend.ll b/runtime/GCCLibraries/crtend/listend.ll
deleted file mode 100644
index a8cee070c9..0000000000
--- a/runtime/GCCLibraries/crtend/listend.ll
+++ /dev/null
@@ -1,23 +0,0 @@
-; global_ctors/global_dtors terminator: this is used to add a terminating null
-; value to the initialization list.
-
-%struct..TorRec = type { int, void ()* }
-
-%llvm.global_ctors = appending global [1 x %struct..TorRec] [
- %struct..TorRec { int 2147483647, void ()* null }
- ]
-
-%llvm.global_dtors = appending global [1 x %struct..TorRec] [
- %struct..TorRec { int 2147483647, void ()* null }
- ]
-
-implementation
-
-%struct..TorRec* %__llvm_getGlobalCtors() {
- ret %struct..TorRec* getelementptr ([1 x %struct..TorRec]* %llvm.global_ctors,
- long 0, long 0)
-}
-%struct..TorRec* %__llvm_getGlobalDtors() {
- ret %struct..TorRec* getelementptr ([1 x %struct..TorRec]* %llvm.global_dtors,
- long 0, long 0)
-}