unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Leo Famulari <leo@famulari.name>
Cc: 24703@debbugs.gnu.org
Subject: bug#24703: Store references in 8-byte chunks in compiled code
Date: Sat, 05 Nov 2016 00:15:25 +0100	[thread overview]
Message-ID: <87a8de7s6q.fsf@inria.fr> (raw)
In-Reply-To: <87mvi5lzqu.fsf@netris.org>

I’ve fiddled a bit with GCC and read some code.  No success yet, but
here’s a status update.

AIUI, ‘strcpy’ declarations are immediately (in the front-end)
recognized as “built-ins” as they are read (IOW, there’s no explicit
conversion from function call to built-in call.)

‘__builtin_strcpy’ calls are then converted to ‘__builtin_memcpy’ calls
(‘handle_builtin_strcpy’ in tree-ssa-strlen.c), which in turn leads to
code that uses the ‘movabs’ instruction that’s causing us problems on
x86:

--8<---------------cut here---------------start------------->8---
$ echo 'extern char *strcpy(char*,const char*);void foo(char*x){ strcpy(x, "foo"); }'> t.c
$ gcc -c -fdump-tree-optimized t.c
$ cat t.c.211t.optimized 

;; Function foo (foo, funcdef_no=0, decl_uid=1759, cgraph_uid=0, symbol_order=0)

foo (char * x)
{
  <bb 2>:
  __builtin_memcpy (x_2(D), "foo", 4);
  return;

}

--8<---------------cut here---------------end--------------->8---

(Strangely, when using ‘memcpy’ in the source, the ‘movabs’ optimization
does not take place at -O0, unlike for ‘strcpy’.)

So it seems there’s no place on the front-end side where we could do
what I tried to do in my initial patch, which is to test the contents of
the literal string passed to strcpy/memcpy and turn off the
‘movabs’-producing optimization.

Instead, the knobs we have are (1) global flag to enable/disable each
built-in function (like -fno-builtin-… does), and (2) an x86-specific
knob to determine whether to use ‘movabs’ or not (‘-mmemcpy-strategy’
supposedly controls that, but ‘-mmemcpy-strategy=libcall:-1:noalign’
doesn’t seem to have any effect for instance.)

These knobs are not great because that would lead us to disable the
optimization wholesale, which is not desirable.

Other than that, I’ve also looked at all the movabs-related things in
gcc/config/i386/*.md, but to no avail.

To be continued…

Ludo’.

  reply	other threads:[~2016-11-04 23:16 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-16  3:49 bug#24703: fontconfig keeps obfuscated reference to itself, not grafted Mark H Weaver
2016-10-16  4:26 ` Mark H Weaver
2016-10-16  5:00   ` Mark H Weaver
2016-10-16  6:24     ` bug#24703: Store references in 8-byte chunks in compiled code Mark H Weaver
2016-10-16  9:03       ` Mark H Weaver
2016-10-16  9:25       ` Mark H Weaver
2016-10-16 10:15         ` Mark H Weaver
2016-10-16 19:04         ` Ludovic Courtès
2016-10-17  7:46           ` bug#24703: " Török Edwin
2016-10-17  9:42             ` Mark H Weaver
2016-10-17 12:09             ` Ludovic Courtès
2016-10-18  3:36               ` Mark H Weaver
2016-10-18  8:59                 ` Ludovic Courtès
2016-10-31  6:35                   ` Mark H Weaver
2016-10-31 11:37                     ` Ludovic Courtès
2016-10-24 19:40                 ` Leo Famulari
2016-10-24 20:18                   ` Ludovic Courtès
2016-11-04 23:15                     ` Ludovic Courtès [this message]
2016-11-05 18:36                       ` Leo Famulari
2016-11-06 20:58                         ` Ludovic Courtès
2016-11-09 20:40                       ` Ludovic Courtès
2016-11-09 23:16                         ` Leo Famulari
2016-11-10  8:01                           ` Ludovic Courtès
2017-04-02 22:19                             ` Ludovic Courtès
2016-11-11 10:39                         ` Ludovic Courtès
2016-10-19 21:25               ` Török Edwin
2016-10-20 12:25                 ` Ludovic Courtès
2016-10-16 14:42 ` bug#24703: fontconfig keeps obfuscated reference to itself, not grafted Ludovic Courtès
2016-10-16 15:06   ` Ludovic Courtès

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

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a8de7s6q.fsf@inria.fr \
    --to=ludo@gnu.org \
    --cc=24703@debbugs.gnu.org \
    --cc=leo@famulari.name \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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).