From: Alexander Turenko <alexander.turenko@tarantool.org>
To: Georgy Kirichenko <georgy@tarantool.org>
Cc: AKhatskevich <avkhatskevich@tarantool.org>,
tarantool-patches@freelists.org
Subject: [tarantool-patches] [PATCH v2 1/3] test: prevent guard-breaker optimization with LTO
Date: Mon, 15 Oct 2018 02:17:29 +0300 [thread overview]
Message-ID: <bc4228963e2269959196e91bb575bc4e8bb2f55a.1539556251.git.alexander.turenko@tarantool.org> (raw)
In-Reply-To: <cover.1539556251.git.alexander.turenko@tarantool.org>
From: AKhatskevich <avkhatskevich@tarantool.org>
In case of very aggressive optimizations the compiler can
optimize guard-breaker function away and the `unit/guard`
test would fail.
---
test/unit/guard.cc | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/test/unit/guard.cc b/test/unit/guard.cc
index 231b44c7d..3d42fee31 100644
--- a/test/unit/guard.cc
+++ b/test/unit/guard.cc
@@ -13,7 +13,11 @@ static int __attribute__((noinline))
stack_break_f(char *ptr)
{
char block[2048];
- char sum = 0;
+ /*
+ * Make sum volatile to prevent a compiler from
+ * optimizing away call to this function.
+ */
+ volatile char sum = 0;
memset(block, 0xff, 2048);
sum += block[block[4]];
ptrdiff_t stack_diff = ptr > block ? ptr - block : block - ptr;
--
2.19.1
next prev parent reply other threads:[~2018-10-14 23:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-14 23:17 [tarantool-patches] [PATCH v2 0/3] Add LTO support Alexander Turenko
2018-10-14 23:17 ` Alexander Turenko [this message]
2018-10-14 23:17 ` [tarantool-patches] [PATCH v2 2/3] " Alexander Turenko
2018-10-16 18:09 ` [tarantool-patches] " Konstantin Osipov
2018-10-17 7:13 ` Alexander Turenko
2018-10-25 11:17 ` Georgy Kirichenko
2018-10-14 23:17 ` [tarantool-patches] [PATCH v2 3/3] test: add LTO targets into CI Alexander Turenko
2018-10-25 11:16 ` [tarantool-patches] " Georgy Kirichenko
2018-10-25 12:18 ` [tarantool-patches] Re: [PATCH v2 0/3] Add LTO support Kirill Yukhin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bc4228963e2269959196e91bb575bc4e8bb2f55a.1539556251.git.alexander.turenko@tarantool.org \
--to=alexander.turenko@tarantool.org \
--cc=avkhatskevich@tarantool.org \
--cc=georgy@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [tarantool-patches] [PATCH v2 1/3] test: prevent guard-breaker optimization with LTO' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox