]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
More aggressively prevent a buffer from being optimized out
authorShu-Chun Weng <scw@google.com>
Mon, 3 May 2021 23:12:44 +0000 (16:12 -0700)
committerFangrui Song <i@maskray.me>
Sat, 28 Aug 2021 00:26:06 +0000 (17:26 -0700)
The volatile global variable was first introduced in e86f9654c. I have
noticed the compiler still optimizing the buffer out on AArch64
presumably because the assignment is after all other observable
behaviors so it's still valid to eliminate it.

string/tst-xbzero-opt.c

index e9c411b2ef5d1c90b461125eb031f27ad2e0a072..4f16c4d67841bca2c9a6433abfce8933de1ec3f4 100644 (file)
@@ -119,17 +119,17 @@ static void
 setup_no_clear (void)
 {
   unsigned char buf[TEST_BUFFER_SIZE];
-  prepare_test_buffer (buf);
   vol_glob = buf;
+  prepare_test_buffer (buf);
 }
 
 static void
 setup_ordinary_clear (void)
 {
   unsigned char buf[TEST_BUFFER_SIZE];
+  vol_glob = buf;
   prepare_test_buffer (buf);
   memset (buf, 0, TEST_BUFFER_SIZE);
-  vol_glob = buf;
 }
 
 static void