Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libgccjit: Clear pending_assemble_externals_processed #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

antoyo
Copy link
Owner

@antoyo antoyo commented Oct 16, 2024

ML link: https://gcc.gnu.org/pipermail/jit/2024q1/001821.html

Without this patch, code using exception handling will fail the following assert in the function assemble_external_libcall in varasm.cc:

gcc_assert (!pending_assemble_externals_processed)

gcc/ChangeLog:
PR jit/113842
* toplev.cc (toplev::finalize): Call varasm_cc_finalize.
* varasm.cc (varasm_cc_finalize): New function to clear pending_assemble_externals_processed.
* varasm.h (varasm_cc_finalize): New function.

Without this patch, code using exception handling will fail the
following assert in the function assemble_external_libcall in varasm.cc:

    gcc_assert (!pending_assemble_externals_processed)

gcc/ChangeLog:
	PR jit/113842
	* toplev.cc (toplev::finalize): Call varasm_cc_finalize.
	* varasm.cc (varasm_cc_finalize): New function to clear
	pending_assemble_externals_processed.
	* varasm.h (varasm_cc_finalize): New function.
@davidmalcolm
Copy link
Collaborator

Sorry for delay in reviewing. Looks like I might have superceded this patch with
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=779c0390e3b57d1eebd41bbfe43d1f329c91de6c
and
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=7f41203f08b9948c1c636dc9d66571121c6c7793
which resets pending_assemble_externals_processed and a lot more besides.

@antoyo
Copy link
Owner Author

antoyo commented Nov 1, 2024

Thanks. I'll do a rebase and confirm the tests from rustc_codegen_gcc still pass.

antoyo pushed a commit that referenced this pull request Nov 20, 2024
This patch folds svindex with constant arguments into a vector series.
We implemented this in svindex_impl::fold using the function build_vec_series.
For example,
svuint64_t f1 ()
{
  return svindex_u642 (10, 3);
}
compiled with -O2 -march=armv8.2-a+sve, is folded to {10, 13, 16, ...}
in the gimple pass lower.
This optimization benefits cases where svindex is used in combination with
other gimple-level optimizations.
For example,
svuint64_t f2 ()
{
    return svmul_x (svptrue_b64 (), svindex_u64 (10, 3), 5);
}
has previously been compiled to
f2:
        index   z0.d, #10, #3
        mul     z0.d, z0.d, #5
        ret
Now, it is compiled to
f2:
        mov     x0, 50
        index   z0.d, x0, #15
        ret

We added test cases checking
- the application of the transform during gimple for constant arguments,
- the interaction with another gimple-level optimization.

The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
OK for mainline?

Signed-off-by: Jennifer Schmitz <[email protected]>

gcc/
	* config/aarch64/aarch64-sve-builtins-base.cc
	(svindex_impl::fold): Add constant folding.

gcc/testsuite/
	* gcc.target/aarch64/sve/index_const_fold.c: New test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants