public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Wohlferd <dw@LimeGreenSocks.com>
To: Bernd Edlinger <bernd.edlinger@hotmail.de>,
	Sandra Loosemore <sandra@codesourcery.com>,
	Bernd Schmidt <bschmidt@redhat.com>,
	"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	Richard Henderson <rth@redhat.com>,
	"jason@redhat.com" <jason@redhat.com>
Cc: "segher@kernel.crashing.org" <segher@kernel.crashing.org>,
	"Paul_Koning@Dell.com" <Paul_Koning@Dell.com>,
	Jeff Law <law@redhat.com>, Andrew Haley <aph@redhat.com>,
	"hubicka@ucw.cz" <hubicka@ucw.cz>,
	David Wohlferd <dw@LimeGreenSocks.com>
Subject: Re: Wonly-top-basic-asm
Date: Sun, 21 Feb 2016 10:28:00 -0000	[thread overview]
Message-ID: <56C99113.7090602@LimeGreenSocks.com> (raw)
In-Reply-To: <HE1PR07MB0905FC1A625C57C8A0C56C72E4A10@HE1PR07MB0905.eurprd07.prod.outlook.com>

On 2/20/2016 4:08 AM, Bernd Edlinger wrote:
> Sorry, but I don't like this example at all.
>
> First the new example is essentially academic and useless,

When used within a function, basic asm:

- causes difficulties for optimizers
- produces incompatibilities with other compilers
- has semantics that are the opposite of what users expect
- may soon produce incompatibilities with other versions of gcc

Given all this, why would we want our sample to show using basic asm 
within a function (as you are suggesting) instead of working to 
discourage it?

Contrawise, even people who are advocating for the deprecation/removal 
of basic asm (like me) acknowledge that it is needed for top level.  
That is why I use it for the sample.  I suppose I could grab some actual 
top level code from the linux source (like ".symver 
__netf2_compat,__netf2@GCC_3.0").  But while it's real-world instead of 
"academic," it's also not as clear as I'd like for a sample.

Obviously this testme code isn't going to be placed verbatim in 
someone's project.  However, if someone wants to use asm macros (a 
plausible if uncommon case), this sample shows them how, using a simple, 
easy-to-understand (if not particularly useful) method.

In contrast, the "int $3" you seem to favor doesn't really show anything 
(even how to do multiple lines).  And worse, Jeff's plan is to change 
basic asm statements so they clobber ALL registers plus memory.  Even a 
trivial example shows how this results in gcc generating completely 
different code around an "int $3."  Which makes it rather problematical 
for debugging (can you say heisenbug?), which is the primary use for int 3.

> while the previous example could well be used
> in real world code, except we could note here
> that we also have a __builtin_trap () now.

After reading the documentation for __builtin_trap, I still have 
absolutely no idea what it does.  Worse, after NOT saying precisely what 
it does on any given platform, the docs make it clear that whatever it 
does isn't fixed and can change at any time.

I'm a big believer in using builtins instead of inline asm.  But based 
on these docs, I can't ever see using __builtin_trap myself.

> Second if you don't mention that "cc" is already implicitly
> clobbered by default, and if it is written here it is ignored
> on i386 targets, then everybody will hurry to modify their
> asm code when there is no real reason for that.

The meaning of the "cc" clobber is defined under extended asm.  The 
usage in this sample is consistent with that definition.  In the 
(unlikely) event that "everybody" decides to change their code, they 
will all have (slightly) better documented code which is written in 
accordance with the docs.  And which behaves precisely the same as what 
they have now.

So now what?  I have one Bernd who likes the sample, and one who 
doesn't.  Obviously I think what I'm proposing is better than what's 
there now and I've done my best to say why.  But me believing it to be 
better doesn't get anything checked in.

What will?

dw

  reply	other threads:[~2016-02-21 10:28 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-24 22:24 Wonly-top-basic-asm David Wohlferd
2016-01-25 12:25 ` Wonly-top-basic-asm Bernd Schmidt
2016-01-28  7:21   ` Wonly-top-basic-asm David Wohlferd
2016-02-08  3:46     ` Wonly-top-basic-asm David Wohlferd
2016-02-08  6:45       ` AW: Wonly-top-basic-asm Bernd Edlinger
2016-02-08 20:15         ` David Wohlferd
2016-02-10 23:50         ` David Wohlferd
2016-02-11  6:51           ` AW: " Bernd Edlinger
2016-02-12  7:01             ` David Wohlferd
2016-02-11 15:40           ` Bernd Schmidt
2016-02-11 16:03             ` Sandra Loosemore
2016-02-12  7:08               ` David Wohlferd
2016-02-12  7:05             ` David Wohlferd
2016-02-12 12:51               ` Bernd Schmidt
2016-02-13  1:03                 ` Sandra Loosemore
2016-02-14  4:00                   ` David Wohlferd
2016-02-20  1:03                     ` David Wohlferd
2016-02-20 12:08                       ` Wonly-top-basic-asm Bernd Edlinger
2016-02-21 10:28                         ` David Wohlferd [this message]
2016-02-26 15:10                           ` Wonly-top-basic-asm Bernd Schmidt
2016-02-29  7:02                             ` Wonly-top-basic-asm David Wohlferd
2016-03-11  0:56                               ` Wonly-top-basic-asm David Wohlferd
2016-03-14 15:29                                 ` Wonly-top-basic-asm Bernd Schmidt
2016-03-17  5:24                                   ` Wonly-top-basic-asm David Wohlferd
2016-03-18 13:32                                     ` Wonly-top-basic-asm Bernd Schmidt
2016-03-18 15:01                                       ` Wonly-top-basic-asm Richard Biener
2016-03-18 19:14                                     ` Wonly-top-basic-asm Bernd Schmidt
2016-02-14  3:57                 ` AW: Wonly-top-basic-asm David Wohlferd
2016-01-26  0:32 ` Wonly-top-basic-asm Segher Boessenkool
2016-01-26 12:11   ` Wonly-top-basic-asm Bernd Schmidt
2016-01-26 16:12     ` Wonly-top-basic-asm Segher Boessenkool
2016-01-26 23:38       ` Wonly-top-basic-asm David Wohlferd
2016-02-16 14:03 ` Wonly-top-basic-asm Jan Hubicka
2016-02-16 20:02   ` Wonly-top-basic-asm Bernd Edlinger

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=56C99113.7090602@LimeGreenSocks.com \
    --to=dw@limegreensocks.com \
    --cc=Paul_Koning@Dell.com \
    --cc=aph@redhat.com \
    --cc=bernd.edlinger@hotmail.de \
    --cc=bschmidt@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=jason@redhat.com \
    --cc=law@redhat.com \
    --cc=rth@redhat.com \
    --cc=sandra@codesourcery.com \
    --cc=segher@kernel.crashing.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).