[runtime]
authorVladimir Kargov <vkargov@users.noreply.github.com>
Thu, 12 Feb 2015 14:45:34 +0000 (17:45 +0300)
committerVladimir Kargov <vkargov@users.noreply.github.com>
Thu, 12 Feb 2015 14:45:34 +0000 (17:45 +0300)
Mark TLS variables as explicitly used to avoid their unwarranted deletion
by the compiler overlooking their usage in inline assembly sections.

mono/metadata/sgen-alloc.c
mono/utils/mono-compiler.h

index 12beef893f16a8f871527fcba4d24a51c3346752..aa475bc0d3153a22c91704db91938368c671c661 100644 (file)
@@ -93,7 +93,7 @@ static __thread char *tlab_next;
 static __thread char *tlab_temp_end;
 static __thread char *tlab_real_end;
 /* Used by the managed allocator/wbarrier */
-static __thread char **tlab_next_addr;
+static __thread char **tlab_next_addr MONO_ATTR_USED;
 #endif
 
 #ifdef HAVE_KW_THREAD
index 6cb60f2c387585a4c4f58a91df0dc044a5215631..a910e917d7f2d253b03ba665b517210ce9c7b6e6 100644 (file)
@@ -7,13 +7,19 @@
  */
 #include <config.h>
 
+#ifdef __GNUC__
+#define MONO_ATTR_USED __attribute__ ((used))
+#else
+#define MONO_ATTR_USED
+#endif
+
 #ifdef HAVE_KW_THREAD
 
 #define MONO_HAVE_FAST_TLS
 #define MONO_FAST_TLS_SET(x,y) x = y
 #define MONO_FAST_TLS_GET(x) x
 #define MONO_FAST_TLS_INIT(x)
-#define MONO_FAST_TLS_DECLARE(x) static __thread gpointer x MONO_TLS_FAST;
+#define MONO_FAST_TLS_DECLARE(x) static __thread gpointer x MONO_TLS_FAST MONO_ATTR_USED;
 
 #if HAVE_TLS_MODEL_ATTR