All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Edward Liaw <edliaw@google.com>
Cc: kernel-team@android.com, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1] syscalls/signal06: add volatile to loop variable
Date: Tue, 19 Jul 2022 12:20:37 +0200	[thread overview]
Message-ID: <YtaFddMFjVPMTpme@rei> (raw)
In-Reply-To: <20220712173921.2623135-1-edliaw@google.com>

Hi!
> On Android compiled with clang, the loop variable will be optimized out
> unless it is tagged with volatile.

Looking at the code it looks strange that it's optimized out since we
use the value for the loop as:

	loop = 0;

	D = VALUE;
	while (D == VALUE && loop < LOOPS) {
		asm(...);
		loop++;
	}

And the D variable is properly marked as volatile so it's not like the
loop can be expected to iterate preciselly LOOPS iterations.

It looks to me like the compiler actually forgets about the volatility
of D for some reason and then assumes that the loop does LOOPS
iterations.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2022-07-19 10:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-12 17:39 [LTP] [PATCH v1] syscalls/signal06: add volatile to loop variable Edward Liaw via ltp
2022-07-13 12:48 ` Petr Vorel
2022-07-19 10:20 ` Cyril Hrubis [this message]
2022-07-27 21:37   ` Edward Liaw via ltp
2022-08-11 15:24     ` Edward Liaw via ltp
2022-08-11 15:33       ` Cyril Hrubis
2022-08-16 12:43         ` Petr Vorel
2022-08-16 23:00           ` Edward Liaw via ltp
2022-08-17  9:12             ` Petr Vorel
2022-08-17 15:04               ` Edward Liaw via ltp
2022-08-18 21:18                 ` Edward Liaw via ltp
2022-08-19  8:12                   ` Petr Vorel
2022-08-19  8:41                     ` Cyril Hrubis
2022-08-19  9:02                       ` Cyril Hrubis
2022-08-19  9:14                       ` Joerg Vehlow
2022-08-19  9:21                         ` Cyril Hrubis
2022-08-19 10:40                       ` Petr Vorel
2022-08-19 18:13                         ` Edward Liaw via ltp

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=YtaFddMFjVPMTpme@rei \
    --to=chrubis@suse.cz \
    --cc=edliaw@google.com \
    --cc=kernel-team@android.com \
    --cc=ltp@lists.linux.it \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.