From fffb7266fe9c5c95d859ff5b3aeb5386cbd0cd1e Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 27 Aug 2009 03:29:26 +0000 Subject: [PATCH] --- Reverse-merging r80147 into '.': A include/llvm/ADT/iterator.cmake U autoconf/configure.ac --- Reverse-merging r80161 into '.': U cmake/config-ix.cmake --- Reverse-merging r80171 into '.': U Makefile --- Reverse-merging r80173 into '.': U configure U include/llvm/Config/config.h.in --- Reverse-merging r80180 into '.': A include/llvm/ADT/iterator.h.in Despite common miscomceptions, iterator.h is alive and well. It broke the build bots for several hours. And yet no one bothered to look at them. Gabor and Doug, please review your changes and make sure that they actually build before resubmitting them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80197 91177308-0d34-0410-b5e6-96231b3b80d8 --- Makefile | 4 +- autoconf/configure.ac | 1 + cmake/config-ix.cmake | 5 + configure | 72 +++++---- include/llvm/ADT/iterator.cmake | 79 ++++++++++ include/llvm/ADT/iterator.h.in | 76 +++++++++ include/llvm/CodeGen/AsmPrinter.h | 2 + include/llvm/Config/config.h.in | 18 +-- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 180 ++++++++++++++++++++++ lib/CodeGen/AsmPrinter/DwarfException.cpp | 69 +++++---- 10 files changed, 436 insertions(+), 70 deletions(-) create mode 100644 include/llvm/ADT/iterator.cmake create mode 100644 include/llvm/ADT/iterator.h.in diff --git a/Makefile b/Makefile index 5d10f8e237f..700b02d02e8 100644 --- a/Makefile +++ b/Makefile @@ -117,6 +117,7 @@ debug-opt-prof: dist-hook:: $(Echo) Eliminating files constructed by configure $(Verb) $(RM) -f \ + $(TopDistDir)/include/llvm/ADT/iterator.h \ $(TopDistDir)/include/llvm/Config/config.h \ $(TopDistDir)/include/llvm/Support/DataTypes.h \ $(TopDistDir)/include/llvm/Support/ThreadSupport.h @@ -135,7 +136,8 @@ FilesToConfig := \ include/llvm/Config/config.h \ include/llvm/Config/Targets.def \ include/llvm/Config/AsmPrinters.def \ - include/llvm/Support/DataTypes.h + include/llvm/Support/DataTypes.h \ + include/llvm/ADT/iterator.h FilesToConfigPATH := $(addprefix $(LLVM_OBJ_ROOT)/,$(FilesToConfig)) all-local:: $(FilesToConfigPATH) diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 49ab0376ef3..173341a054c 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -1314,6 +1314,7 @@ AC_CONFIG_FILES([include/llvm/Config/Targets.def]) AC_CONFIG_FILES([include/llvm/Config/AsmPrinters.def]) AC_CONFIG_FILES([include/llvm/Config/AsmParsers.def]) AC_CONFIG_HEADERS([include/llvm/Support/DataTypes.h]) +AC_CONFIG_HEADERS([include/llvm/ADT/iterator.h]) dnl Configure the makefile's configuration data AC_CONFIG_FILES([Makefile.config]) diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 85f94708745..52025a9ee2c 100755 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -180,6 +180,11 @@ configure_file( ${LLVM_BINARY_DIR}/include/llvm/Config/config.h ) +configure_file( + ${LLVM_MAIN_INCLUDE_DIR}/llvm/ADT/iterator.cmake + ${LLVM_BINARY_DIR}/include/llvm/ADT/iterator.h + ) + configure_file( ${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/DataTypes.h.cmake ${LLVM_BINARY_DIR}/include/llvm/Support/DataTypes.h diff --git a/configure b/configure index bc46356bcfc..64566fbb1b7 100755 --- a/configure +++ b/configure @@ -834,6 +834,7 @@ CVSBUILD ENABLE_OPTIMIZED ENABLE_PROFILING DISABLE_ASSERTIONS +LLVM_COMPACT_SENTINELS ENABLE_EXPENSIVE_CHECKS EXPENSIVE_CHECKS DEBUG_RUNTIME @@ -4845,6 +4846,21 @@ else fi +if test ${ENABLE_OPTIMIZED},${DISABLE_ASSERTIONS} = "ENABLE_OPTIMIZED=1,DISABLE_ASSERTIONS=1" ; then + LLVM_COMPACT_SENTINELS=1 + +else + LLVM_COMPACT_SENTINELS=0 + +fi + + +cat >>confdefs.h <<_ACEOF +#define LLVM_COMPACT_SENTINELS $LLVM_COMPACT_SENTINELS +_ACEOF + + + # Check whether --enable-expensive-checks was given. if test "${enable_expensive_checks+set}" = set; then enableval=$enable_expensive_checks; @@ -10972,7 +10988,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext + echo '#line 13135 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -14834,11 +14850,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14837: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14853: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14841: \$? = $ac_status" >&5 + echo "$as_me:14857: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -15102,11 +15118,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15105: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15121: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15109: \$? = $ac_status" >&5 + echo "$as_me:15125: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -15206,11 +15222,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15209: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15225: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:15213: \$? = $ac_status" >&5 + echo "$as_me:15229: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17658,7 +17674,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:20145: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:20133: \$? = $ac_status" >&5 + echo "$as_me:20149: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -20230,11 +20246,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:20233: $lt_compile\"" >&5) + (eval echo "\"\$as_me:20249: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:20237: \$? = $ac_status" >&5 + echo "$as_me:20253: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -21800,11 +21816,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21803: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21819: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:21807: \$? = $ac_status" >&5 + echo "$as_me:21823: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -21904,11 +21920,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21907: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21923: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:21911: \$? = $ac_status" >&5 + echo "$as_me:21927: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -24139,11 +24155,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24142: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24158: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:24146: \$? = $ac_status" >&5 + echo "$as_me:24162: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24407,11 +24423,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24410: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24426: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:24414: \$? = $ac_status" >&5 + echo "$as_me:24430: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24511,11 +24527,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24514: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24530: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:24518: \$? = $ac_status" >&5 + echo "$as_me:24534: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -35300,6 +35316,8 @@ ac_config_files="$ac_config_files include/llvm/Config/AsmParsers.def" ac_config_headers="$ac_config_headers include/llvm/Support/DataTypes.h" +ac_config_headers="$ac_config_headers include/llvm/ADT/iterator.h" + ac_config_files="$ac_config_files Makefile.config" @@ -35926,6 +35944,7 @@ do "include/llvm/Config/AsmPrinters.def") CONFIG_FILES="$CONFIG_FILES include/llvm/Config/AsmPrinters.def" ;; "include/llvm/Config/AsmParsers.def") CONFIG_FILES="$CONFIG_FILES include/llvm/Config/AsmParsers.def" ;; "include/llvm/Support/DataTypes.h") CONFIG_HEADERS="$CONFIG_HEADERS include/llvm/Support/DataTypes.h" ;; + "include/llvm/ADT/iterator.h") CONFIG_HEADERS="$CONFIG_HEADERS include/llvm/ADT/iterator.h" ;; "Makefile.config") CONFIG_FILES="$CONFIG_FILES Makefile.config" ;; "llvm.spec") CONFIG_FILES="$CONFIG_FILES llvm.spec" ;; "docs/doxygen.cfg") CONFIG_FILES="$CONFIG_FILES docs/doxygen.cfg" ;; @@ -36085,6 +36104,7 @@ CVSBUILD!$CVSBUILD$ac_delim ENABLE_OPTIMIZED!$ENABLE_OPTIMIZED$ac_delim ENABLE_PROFILING!$ENABLE_PROFILING$ac_delim DISABLE_ASSERTIONS!$DISABLE_ASSERTIONS$ac_delim +LLVM_COMPACT_SENTINELS!$LLVM_COMPACT_SENTINELS$ac_delim ENABLE_EXPENSIVE_CHECKS!$ENABLE_EXPENSIVE_CHECKS$ac_delim EXPENSIVE_CHECKS!$EXPENSIVE_CHECKS$ac_delim DEBUG_RUNTIME!$DEBUG_RUNTIME$ac_delim @@ -36103,7 +36123,6 @@ BINUTILS_INCDIR!$BINUTILS_INCDIR$ac_delim ENABLE_LLVMC_DYNAMIC!$ENABLE_LLVMC_DYNAMIC$ac_delim ENABLE_LLVMC_DYNAMIC_PLUGINS!$ENABLE_LLVMC_DYNAMIC_PLUGINS$ac_delim CXX!$CXX$ac_delim -CXXFLAGS!$CXXFLAGS$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then @@ -36145,6 +36164,7 @@ _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF +CXXFLAGS!$CXXFLAGS$ac_delim ac_ct_CXX!$ac_ct_CXX$ac_delim NM!$NM$ac_delim ifGNUmake!$ifGNUmake$ac_delim @@ -36238,7 +36258,7 @@ LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 91; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 92; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 diff --git a/include/llvm/ADT/iterator.cmake b/include/llvm/ADT/iterator.cmake new file mode 100644 index 00000000000..55df8ce2643 --- /dev/null +++ b/include/llvm/ADT/iterator.cmake @@ -0,0 +1,79 @@ +//===-- llvm/ADT/iterator - Portable wrapper around --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file provides a wrapper around the mysterious header file. +// In GCC 2.95.3, the file defines a bidirectional_iterator class (and other +// friends), instead of the standard iterator class. In GCC 3.1, the +// bidirectional_iterator class got moved out and the new, standards compliant, +// iterator<> class was added. Because there is nothing that we can do to get +// correct behavior on both compilers, we have this header with #ifdef's. Gross +// huh? +// +// By #includ'ing this file, you get the contents of plus the +// following classes in the global namespace: +// +// 1. bidirectional_iterator +// 2. forward_iterator +// +// The #if directives' expressions are filled in by Autoconf. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ADT_ITERATOR +#define LLVM_ADT_ITERATOR + +#include + +#undef HAVE_BI_ITERATOR +#undef HAVE_STD_ITERATOR +#undef HAVE_FWD_ITERATOR + +// defined by Kevin +#define HAVE_STD_ITERATOR 1 + +#ifdef _MSC_VER +# define HAVE_BI_ITERATOR 0 +# define HAVE_STD_ITERATOR 1 +# define HAVE_FWD_ITERATOR 0 +#endif + +#if !HAVE_BI_ITERATOR +# if HAVE_STD_ITERATOR +/// If the bidirectional iterator is not defined, we attempt to define it in +/// terms of the C++ standard iterator. Otherwise, we import it with a "using" +/// statement. +/// +template +struct bidirectional_iterator + : public std::iterator { +}; +# else +# error "Need to have standard iterator to define bidirectional iterator!" +# endif +#else +using std::bidirectional_iterator; +#endif + +#if !HAVE_FWD_ITERATOR +# if HAVE_STD_ITERATOR +/// If the forward iterator is not defined, attempt to define it in terms of +/// the C++ standard iterator. Otherwise, we import it with a "using" statement. +/// +template +struct forward_iterator + : public std::iterator { +}; +# else +# error "Need to have standard iterator to define forward iterator!" +# endif +#else +using std::forward_iterator; +#endif + +#endif diff --git a/include/llvm/ADT/iterator.h.in b/include/llvm/ADT/iterator.h.in new file mode 100644 index 00000000000..dce74625118 --- /dev/null +++ b/include/llvm/ADT/iterator.h.in @@ -0,0 +1,76 @@ +//==-- llvm/ADT/iterator.h - Portable wrapper around --*- C++ -*-==// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file provides a wrapper around the mysterious header file. +// In GCC 2.95.3, the file defines a bidirectional_iterator class (and other +// friends), instead of the standard iterator class. In GCC 3.1, the +// bidirectional_iterator class got moved out and the new, standards compliant, +// iterator<> class was added. Because there is nothing that we can do to get +// correct behavior on both compilers, we have this header with #ifdef's. Gross +// huh? +// +// By #includ'ing this file, you get the contents of plus the +// following classes in the global namespace: +// +// 1. bidirectional_iterator +// 2. forward_iterator +// +// The #if directives' expressions are filled in by Autoconf. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ADT_ITERATOR_H +#define LLVM_ADT_ITERATOR_H + +#include + +#undef HAVE_BI_ITERATOR +#undef HAVE_STD_ITERATOR +#undef HAVE_FWD_ITERATOR + +#ifdef _MSC_VER +# define HAVE_BI_ITERATOR 0 +# define HAVE_STD_ITERATOR 1 +# define HAVE_FWD_ITERATOR 0 +#endif + +#if !HAVE_BI_ITERATOR +# if HAVE_STD_ITERATOR +/// If the bidirectional iterator is not defined, we attempt to define it in +/// terms of the C++ standard iterator. Otherwise, we import it with a "using" +/// statement. +/// +template +struct bidirectional_iterator + : public std::iterator { +}; +# else +# error "Need to have standard iterator to define bidirectional iterator!" +# endif +#else +using std::bidirectional_iterator; +#endif + +#if !HAVE_FWD_ITERATOR +# if HAVE_STD_ITERATOR +/// If the forward iterator is not defined, attempt to define it in terms of +/// the C++ standard iterator. Otherwise, we import it with a "using" statement. +/// +template +struct forward_iterator + : public std::iterator { +}; +# else +# error "Need to have standard iterator to define forward iterator!" +# endif +#else +using std::forward_iterator; +#endif + +#endif // LLVM_ADT_ITERATOR_H diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h index 55fc3b0da86..6832d01399f 100644 --- a/include/llvm/CodeGen/AsmPrinter.h +++ b/include/llvm/CodeGen/AsmPrinter.h @@ -268,6 +268,8 @@ namespace llvm { void EOL() const; void EOL(const std::string &Comment) const; void EOL(const char* Comment) const; + void EOL(const std::string &Comment, unsigned DatFormat) const; + void EOL(const char* Comment, unsigned DataFormat) const; /// EmitULEB128Bytes - Emit an assembler byte data directive to compose an /// unsigned leb128 value. diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in index f32f4038ffa..6a28326cdff 100644 --- a/include/llvm/Config/config.h.in +++ b/include/llvm/Config/config.h.in @@ -3,14 +3,6 @@ /* Define if dlopen(0) will open the symbols of the program */ #undef CAN_DLOPEN_SELF -/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP - systems. This function is required for `alloca.c' support on those systems. - */ -#undef CRAY_STACKSEG_END - -/* Define to 1 if using `alloca.c'. */ -#undef C_ALLOCA - /* Define if CBE is enabled for printf %a output */ #undef ENABLE_CBE_PRINTF_A @@ -20,13 +12,6 @@ /* Define if threads enabled */ #undef ENABLE_THREADS -/* Define to 1 if you have `alloca', as a function or macro. */ -#undef HAVE_ALLOCA - -/* Define to 1 if you have and it should be used (not on Ultrix). - */ -#undef HAVE_ALLOCA_H - /* Define to 1 if you have the `argz_append' function. */ #undef HAVE_ARGZ_APPEND @@ -461,6 +446,9 @@ /* Installation directory for binary executables */ #undef LLVM_BINDIR +/* Define to 1 for ilist sentinel compaction */ +#undef LLVM_COMPACT_SENTINELS + /* Time at which LLVM was configured */ #undef LLVM_CONFIGTIME diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index c8099c8b188..6b773c2e020 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -604,6 +604,186 @@ void AsmPrinter::EOL(const char* Comment) const { O << '\n'; } +static const char *GetDataFormatName(unsigned DataFormat) { +#ifndef HAVE_DESIGNATED_INITIALIZERS +#define HAVE_DESIGNATED_INITIALIZERS \ + ((!defined(__cplusplus) && (GCC_VERSION >= 2007)) \ + || (__STDC_VERSION__ >= 199901L)) +#endif + +#if HAVE_DESIGNATED_INITIALIZERS +#define S(p, v) [p] = v, +#else +#define S(p, v) case p: return v; +#endif + +#if HAVE_DESIGNATED_INITIALIZERS + __extension__ static const char * const FormatNames[256] = { +#else + switch (DataFormat) { +#endif + + S(dwarf::DW_EH_PE_absptr, "absolute") + S(dwarf::DW_EH_PE_omit, "omit") + S(dwarf::DW_EH_PE_aligned, "aligned absolute") + + S(dwarf::DW_EH_PE_uleb128, "uleb128") + S(dwarf::DW_EH_PE_udata2, "udata2") + S(dwarf::DW_EH_PE_udata4, "udata4") + S(dwarf::DW_EH_PE_udata8, "udata8") + S(dwarf::DW_EH_PE_sleb128, "sleb128") + S(dwarf::DW_EH_PE_sdata2, "sdata2") + S(dwarf::DW_EH_PE_sdata4, "sdata4") + S(dwarf::DW_EH_PE_sdata8, "sdata8") + + S(dwarf::DW_EH_PE_absptr | dwarf::DW_EH_PE_pcrel, "pcrel") + S(dwarf::DW_EH_PE_uleb128 | dwarf::DW_EH_PE_pcrel, "pcrel uleb128") + S(dwarf::DW_EH_PE_udata2 | dwarf::DW_EH_PE_pcrel, "pcrel udata2") + S(dwarf::DW_EH_PE_udata4 | dwarf::DW_EH_PE_pcrel, "pcrel udata4") + S(dwarf::DW_EH_PE_udata8 | dwarf::DW_EH_PE_pcrel, "pcrel udata8") + S(dwarf::DW_EH_PE_sleb128 | dwarf::DW_EH_PE_pcrel, "pcrel sleb128") + S(dwarf::DW_EH_PE_sdata2 | dwarf::DW_EH_PE_pcrel, "pcrel sdata2") + S(dwarf::DW_EH_PE_sdata4 | dwarf::DW_EH_PE_pcrel, "pcrel sdata4") + S(dwarf::DW_EH_PE_sdata8 | dwarf::DW_EH_PE_pcrel, "pcrel sdata8") + + S(dwarf::DW_EH_PE_absptr | dwarf::DW_EH_PE_textrel, "textrel") + S(dwarf::DW_EH_PE_uleb128 | dwarf::DW_EH_PE_textrel, "textrel uleb128") + S(dwarf::DW_EH_PE_udata2 | dwarf::DW_EH_PE_textrel, "textrel udata2") + S(dwarf::DW_EH_PE_udata4 | dwarf::DW_EH_PE_textrel, "textrel udata4") + S(dwarf::DW_EH_PE_udata8 | dwarf::DW_EH_PE_textrel, "textrel udata8") + S(dwarf::DW_EH_PE_sleb128 | dwarf::DW_EH_PE_textrel, "textrel sleb128") + S(dwarf::DW_EH_PE_sdata2 | dwarf::DW_EH_PE_textrel, "textrel sdata2") + S(dwarf::DW_EH_PE_sdata4 | dwarf::DW_EH_PE_textrel, "textrel sdata4") + S(dwarf::DW_EH_PE_sdata8 | dwarf::DW_EH_PE_textrel, "textrel sdata8") + + S(dwarf::DW_EH_PE_absptr | dwarf::DW_EH_PE_datarel, "datarel") + S(dwarf::DW_EH_PE_uleb128 | dwarf::DW_EH_PE_datarel, "datarel uleb128") + S(dwarf::DW_EH_PE_udata2 | dwarf::DW_EH_PE_datarel, "datarel udata2") + S(dwarf::DW_EH_PE_udata4 | dwarf::DW_EH_PE_datarel, "datarel udata4") + S(dwarf::DW_EH_PE_udata8 | dwarf::DW_EH_PE_datarel, "datarel udata8") + S(dwarf::DW_EH_PE_sleb128 | dwarf::DW_EH_PE_datarel, "datarel sleb128") + S(dwarf::DW_EH_PE_sdata2 | dwarf::DW_EH_PE_datarel, "datarel sdata2") + S(dwarf::DW_EH_PE_sdata4 | dwarf::DW_EH_PE_datarel, "datarel sdata4") + S(dwarf::DW_EH_PE_sdata8 | dwarf::DW_EH_PE_datarel, "datarel sdata8") + + S(dwarf::DW_EH_PE_absptr | dwarf::DW_EH_PE_funcrel, "funcrel") + S(dwarf::DW_EH_PE_uleb128 | dwarf::DW_EH_PE_funcrel, "funcrel uleb128") + S(dwarf::DW_EH_PE_udata2 | dwarf::DW_EH_PE_funcrel, "funcrel udata2") + S(dwarf::DW_EH_PE_udata4 | dwarf::DW_EH_PE_funcrel, "funcrel udata4") + S(dwarf::DW_EH_PE_udata8 | dwarf::DW_EH_PE_funcrel, "funcrel udata8") + S(dwarf::DW_EH_PE_sleb128 | dwarf::DW_EH_PE_funcrel, "funcrel sleb128") + S(dwarf::DW_EH_PE_sdata2 | dwarf::DW_EH_PE_funcrel, "funcrel sdata2") + S(dwarf::DW_EH_PE_sdata4 | dwarf::DW_EH_PE_funcrel, "funcrel sdata4") + S(dwarf::DW_EH_PE_sdata8 | dwarf::DW_EH_PE_funcrel, "funcrel sdata8") + + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_absptr |dwarf::DW_EH_PE_pcrel, + "indirect pcrel") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_uleb128 |dwarf::DW_EH_PE_pcrel, + "indirect pcrel uleb128") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_udata2 |dwarf::DW_EH_PE_pcrel, + "indirect pcrel udata2") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_udata4 |dwarf::DW_EH_PE_pcrel, + "indirect pcrel udata4") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_udata8 |dwarf::DW_EH_PE_pcrel, + "indirect pcrel udata8") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_sleb128 |dwarf::DW_EH_PE_pcrel, + "indirect pcrel sleb128") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_sdata2 |dwarf::DW_EH_PE_pcrel, + "indirect pcrel sdata2") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_sdata4 |dwarf::DW_EH_PE_pcrel, + "indirect pcrel sdata4") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_sdata8 |dwarf::DW_EH_PE_pcrel, + "indirect pcrel sdata8") + + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_absptr |dwarf::DW_EH_PE_textrel, + "indirect textrel") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_uleb128 |dwarf::DW_EH_PE_textrel, + "indirect textrel uleb128") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_udata2 |dwarf::DW_EH_PE_textrel, + "indirect textrel udata2") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_udata4 |dwarf::DW_EH_PE_textrel, + "indirect textrel udata4") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_udata8 |dwarf::DW_EH_PE_textrel, + "indirect textrel udata8") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_sleb128 |dwarf::DW_EH_PE_textrel, + "indirect textrel sleb128") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_sdata2 |dwarf::DW_EH_PE_textrel, + "indirect textrel sdata2") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_sdata4 |dwarf::DW_EH_PE_textrel, + "indirect textrel sdata4") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_sdata8 |dwarf::DW_EH_PE_textrel, + "indirect textrel sdata8") + + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_absptr |dwarf::DW_EH_PE_datarel, + "indirect datarel") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_uleb128 |dwarf::DW_EH_PE_datarel, + "indirect datarel uleb128") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_udata2 |dwarf::DW_EH_PE_datarel, + "indirect datarel udata2") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_udata4 |dwarf::DW_EH_PE_datarel, + "indirect datarel udata4") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_udata8 |dwarf::DW_EH_PE_datarel, + "indirect datarel udata8") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_sleb128 |dwarf::DW_EH_PE_datarel, + "indirect datarel sleb128") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_sdata2 |dwarf::DW_EH_PE_datarel, + "indirect datarel sdata2") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_sdata4 |dwarf::DW_EH_PE_datarel, + "indirect datarel sdata4") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_sdata8 |dwarf::DW_EH_PE_datarel, + "indirect datarel sdata8") + + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_absptr |dwarf::DW_EH_PE_funcrel, + "indirect funcrel") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_uleb128 |dwarf::DW_EH_PE_funcrel, + "indirect funcrel uleb128") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_udata2 |dwarf::DW_EH_PE_funcrel, + "indirect funcrel udata2") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_udata4 |dwarf::DW_EH_PE_funcrel, + "indirect funcrel udata4") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_udata8 |dwarf::DW_EH_PE_funcrel, + "indirect funcrel udata8") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_sleb128 |dwarf::DW_EH_PE_funcrel, + "indirect funcrel sleb128") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_sdata2 |dwarf::DW_EH_PE_funcrel, + "indirect funcrel sdata2") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_sdata4 |dwarf::DW_EH_PE_funcrel, + "indirect funcrel sdata4") + S(dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_sdata8 |dwarf::DW_EH_PE_funcrel, + "indirect funcrel sdata8") + +#if HAVE_DESIGNATED_INITIALIZERS + }; + + assert(DataFormat >= 0 && DataFormat < 0x100 && FormatNames[DataFormat] && + "Invalid DWARF data format!"); + return FormatNames[DataFormat]; +#else + } + llvm_unreachable("Invalid DWARF data format!"); + return 0; +#endif +#undef HAVE_DESIGNATED_INITIALIZERS +} + +void AsmPrinter::EOL(const std::string &Comment, unsigned DataFormat) const { + if (VerboseAsm && !Comment.empty()) { + O.PadToColumn(MAI->getCommentColumn()); + O << MAI->getCommentString() + << ' ' << Comment << " (" << GetDataFormatName(DataFormat) << ')'; + } + O << '\n'; +} + +void AsmPrinter::EOL(const char* Comment, unsigned DataFormat) const { + if (VerboseAsm && *Comment) { + O.PadToColumn(MAI->getCommentColumn()); + O << MAI->getCommentString() + << ' ' << Comment << " (" << GetDataFormatName(DataFormat) << ')'; + } + O << '\n'; +} + /// EmitULEB128Bytes - Emit an assembler byte data directive to compose an /// unsigned leb128 value. void AsmPrinter::EmitULEB128Bytes(unsigned Value) const { diff --git a/lib/CodeGen/AsmPrinter/DwarfException.cpp b/lib/CodeGen/AsmPrinter/DwarfException.cpp index 170ca241b6a..761686a4dd3 100644 --- a/lib/CodeGen/AsmPrinter/DwarfException.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfException.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file contains support for writing dwarf exception info into asm files. +// This file contains support for writing DWARF exception info into asm files. // //===----------------------------------------------------------------------===// @@ -98,16 +98,19 @@ void DwarfException::EmitCIE(const Function *Personality, unsigned Index) { // If there is a personality, we need to indicate the function's location. if (Personality) { + unsigned Encoding = 0; Asm->EmitULEB128Bytes(7); Asm->EOL("Augmentation Size"); if (MAI->getNeedsIndirectEncoding()) { - Asm->EmitInt8(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 | - dwarf::DW_EH_PE_indirect); - Asm->EOL("Personality (pcrel sdata4 indirect)"); + Encoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 | + dwarf::DW_EH_PE_indirect; + Asm->EmitInt8(Encoding); + Asm->EOL("Personality", Encoding); } else { - Asm->EmitInt8(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4); - Asm->EOL("Personality (pcrel sdata4)"); + Encoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; + Asm->EmitInt8(Encoding); + Asm->EOL("Personality", Encoding); } PrintRelDirective(true); @@ -118,17 +121,20 @@ void DwarfException::EmitCIE(const Function *Personality, unsigned Index) { O << "-" << MAI->getPCSymbol(); Asm->EOL("Personality"); - Asm->EmitInt8(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4); - Asm->EOL("LSDA Encoding (pcrel sdata4)"); + Encoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; + Asm->EmitInt8(Encoding); + Asm->EOL("LSDA Encoding", Encoding); - Asm->EmitInt8(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4); - Asm->EOL("FDE Encoding (pcrel sdata4)"); + Encoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; + Asm->EmitInt8(Encoding); + Asm->EOL("FDE Encoding", Encoding); } else { Asm->EmitULEB128Bytes(1); Asm->EOL("Augmentation Size"); - Asm->EmitInt8(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4); - Asm->EOL("FDE Encoding (pcrel sdata4)"); + unsigned Encoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; + Asm->EmitInt8(Encoding); + Asm->EOL("FDE Encoding", Encoding); } // Indicate locations of general callee saved registers in frame. @@ -598,15 +604,17 @@ void DwarfException::EmitExceptionTable() { } // Emit the header. - Asm->EmitInt8(dwarf::DW_EH_PE_omit); - Asm->EOL("@LPStart format (DW_EH_PE_omit)"); + unsigned Encoding = dwarf::DW_EH_PE_omit; + Asm->EmitInt8(Encoding); + Asm->EOL("@LPStart format", Encoding); #if 0 if (TypeInfos.empty() && FilterIds.empty()) { // If there are no typeinfos or filters, there is nothing to emit, optimize // by specifying the "omit" encoding. - Asm->EmitInt8(dwarf::DW_EH_PE_omit); - Asm->EOL("@TType format (DW_EH_PE_omit)"); + Encoding = dwarf::DW_EH_PE_omit; + Asm->EmitInt8(Encoding); + Asm->EOL("@TType format", Encoding); } else { // Okay, we have actual filters or typeinfos to emit. As such, we need to // pick a type encoding for them. We're about to emit a list of pointers to @@ -634,12 +642,13 @@ void DwarfException::EmitExceptionTable() { // if (LSDASection->isWritable() || Asm->TM.getRelocationModel() == Reloc::Static) { - Asm->EmitInt8(DW_EH_PE_absptr); - Asm->EOL("TType format (DW_EH_PE_absptr)"); + Encoding = DW_EH_PE_absptr; + Asm->EmitInt8(Encoding); + Asm->EOL("TType format", Encoding); } else { + Encoding = DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4; Asm->EmitInt8(DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4); - Asm->EOL("TType format (DW_EH_PE_pcrel | DW_EH_PE_indirect" - " | DW_EH_PE_sdata4)"); + Asm->EOL("TType format", Encoding); } Asm->EmitULEB128Bytes(TypeOffset); Asm->EOL("TType base offset"); @@ -649,11 +658,13 @@ void DwarfException::EmitExceptionTable() { // say that we're omitting that bit. // FIXME: does this apply to Dwarf also? The above #if 0 implies yes? if (!HaveTTData) { - Asm->EmitInt8(dwarf::DW_EH_PE_omit); - Asm->EOL("@TType format (DW_EH_PE_omit)"); + Encoding = dwarf::DW_EH_PE_omit; + Asm->EmitInt8(Encoding); + Asm->EOL("@TType format", Encoding); } else { - Asm->EmitInt8(dwarf::DW_EH_PE_absptr); - Asm->EOL("@TType format (DW_EH_PE_absptr)"); + Encoding = dwarf::DW_EH_PE_absptr; + Asm->EmitInt8(Encoding); + Asm->EOL("@TType format", Encoding); Asm->EmitULEB128Bytes(TypeOffset); Asm->EOL("@TType base offset"); } @@ -661,8 +672,9 @@ void DwarfException::EmitExceptionTable() { // SjLj Exception handilng if (MAI->getExceptionHandlingType() == ExceptionHandling::SjLj) { - Asm->EmitInt8(dwarf::DW_EH_PE_udata4); - Asm->EOL("Call site format (DW_EH_PE_udata4)"); + Encoding = dwarf::DW_EH_PE_udata4; + Asm->EmitInt8(Encoding); + Asm->EOL("Call site format", Encoding); Asm->EmitULEB128Bytes(SizeSites); Asm->EOL("Call site table length"); @@ -714,8 +726,9 @@ void DwarfException::EmitExceptionTable() { // will call `terminate()'. // Emit the landing pad call site table. - Asm->EmitInt8(dwarf::DW_EH_PE_udata4); - Asm->EOL("Call site format (DW_EH_PE_udata4)"); + Encoding = dwarf::DW_EH_PE_udata4; + Asm->EmitInt8(Encoding); + Asm->EOL("Call site format", Encoding); Asm->EmitULEB128Bytes(SizeSites); Asm->EOL("Call site table size"); -- 2.34.1