public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
	enh <enh@google.com>, Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org, Stafford Horne <shorne@gmail.com>
Subject: Re: [PATCH 3/6] linux: Implement mremap in C
Date: Fri, 07 Jun 2024 17:06:34 +0800	[thread overview]
Message-ID: <f85ce12abbab6a361e4c51fef3df9ef0e194887e.camel@xry111.site> (raw)
In-Reply-To: <177225da-682e-4f57-9cde-5ff8f366266a@linaro.org>

On Thu, 2024-06-06 at 17:26 -0300, Adhemerval Zanella Netto wrote:
> I don't really recall to be honest.  And I don't have a strong opinion, 
> the main issue is I would like to eventually get rid of the assembly
> hooks for the syscall auto-generation so we only have have it to support
> for generate it through C.  Besides the code simplification it has the
> side effect of playing better the LTO (which we still do not fully support,
> but maybe in the future).
> 
> I had a prototype for this, which also is slight faster since it generates
> the files in a bulk.

But GCC is generating some really stupid code for va_list.  I made
https://sourceware.org/pipermail/libc-alpha/2023-March/146624.html to
"work it around" but the patch was NAK'ed for some good reason (not to
invoke UB).

With a simple example:

#include <stdarg.h>

int func(int flag, int arg, ... /*int optional*/)
{
	if (!flag)
		return arg | 42;
	else {
		va_list ap;
		va_start(ap, arg);
		arg |= va_arg(ap, int);
		va_end(ap);
	}

	return arg;
}

int func_ub(int flag, int arg, int optional)
{
	if (!flag)
		return arg | 42;
	else
		return arg | optional;
}

we can demonstrate how the code generation for func is much worse than
func_ub.  Clang produces even more stupid code.

I hope someone can work on improving the compilers if we must use
va_list more and more...

> Besides the code simplification it has the side effect of playing
> better the LTO (which we still do not fully support, but maybe in the
> future).

Note that with LTO invoking UB deliberately won't be an option at all
(it is an option w/o LTO but already a really bad option).  So we need
some support from the compiler or we'll have to eat the stupid code from
va_list.

BTW has someone built Glibc with LTO?  I tried it and it never worked.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

  parent reply	other threads:[~2024-06-07  9:06 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-22 18:54 [PATCH 0/6] linux: Some syscall refactors Adhemerval Zanella
2021-11-22 18:54 ` [PATCH 1/6] linux: Add fanotify_mark C implementation Adhemerval Zanella
2021-11-24 21:45   ` Stafford Horne
2021-11-25 12:55     ` Adhemerval Zanella
2021-11-22 18:54 ` [PATCH 2/6] linux: Add prlimit64 " Adhemerval Zanella
2021-11-25 23:39   ` Stafford Horne
2021-11-30 11:51     ` Adhemerval Zanella
2021-11-22 18:54 ` [PATCH 3/6] linux: Implement mremap in C Adhemerval Zanella
2021-11-26  0:26   ` Stafford Horne
2021-11-30 11:55     ` Adhemerval Zanella
2024-06-06 15:15   ` Florian Weimer
2024-06-06 16:01     ` enh
2024-06-06 19:38       ` enh
2024-06-06 20:26         ` Adhemerval Zanella Netto
2024-06-07  8:40           ` Sam James
2024-06-07  8:51             ` Sam James
2024-06-07  9:06           ` Xi Ruoyao [this message]
2021-11-22 18:54 ` [PATCH 4/6] linux: Implement pipe in terms of __NR_pipe2 Adhemerval Zanella
2021-11-26 23:03   ` Stafford Horne
2021-11-30 14:53     ` Adhemerval Zanella
2021-11-22 18:54 ` [PATCH 5/6] linux: Add generic syscall implementation Adhemerval Zanella
2021-11-22 18:54 ` [PATCH 6/6] linux: Add generic ioctl implementation Adhemerval Zanella
2021-12-04  7:50   ` Stafford Horne

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=f85ce12abbab6a361e4c51fef3df9ef0e194887e.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=adhemerval.zanella@linaro.org \
    --cc=enh@google.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=shorne@gmail.com \
    /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).