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

This sets up the conversion from AST to GCC #14

Merged
merged 1 commit into from
May 2, 2020

Conversation

philberty
Copy link
Member

@philberty philberty commented May 2, 2020

It will crash when compiling but its the code setup i want to get in sooner
than later.

Addresses #15

It will crash when compiling but its the code setup i want to get in sooner
than later.

Addresses #15
@philberty philberty merged commit 3ee1720 into master May 2, 2020
philberty pushed a commit that referenced this pull request Mar 3, 2021
…-calls

If the target is configured such that -mlong-call is passed
by default, the function calls these tests are trying to detect
by scanning the assembly file are performed using long calls,
like so:

    | foo:
    |     @ memset-inline-2.c:12:   memset (a, -1, 14);
    |         mov     r2, #14 @,
    |         mvn     r1, #0  @,
    |         ldr     r0, .L2 @,
    |         ldr     r3, .L2+4       @ tmp112,
    |         bx      r3              @ tmp112

Looking at .L2 (and in particular at .L2+4):

    | .L2:
    |         .word   a
    |         .word   memset   <<<---

This change adds -mno-long-calls to the list of compiler options
to make sure we generate short call code, allowing the assembly
matching to pass.

This is added unconditionally to the dg-options (as opposed to using
dg-additional-options) because this test is already specific to ARM
targets, and -mno-long-calls is available on all ARM targets.


for  gcc/testsuite/ChangeLog

	* gcc.target/arm/memset-inline-2.c: Add -mno-long-calls to
	the test's dg-options.
	* gcc.target/arm/pr78255-2.c: Likewise.
CohenArthur pushed a commit that referenced this pull request Apr 23, 2024
Consider

  constexpr int VAL = 1;
  struct foo {
      template <int B>
      void bar(typename std::conditional<B==VAL, int, float>::type arg) { }
  };
  template void foo::bar<1>(int arg);

where we since r11-291 fail to emit the code for the explicit
instantiation.  That's because cp_walk_subtrees/TYPENAME_TYPE now
walks TYPE_CONTEXT ('conditional' here) as well, and in a template
finds the B==VAL template argument.  VAL is constexpr, which implies const,
which in the global scope implies static.  constrain_visibility_for_template
then makes "struct conditional<(B == VAL), int, float>" non-TREE_PUBLIC.
Then symtab_node::needed_p checks TREE_PUBLIC, sees it's 0, and we don't
emit any code.

I thought the fix would be some ODR-esque check to not consider
constexpr variables/fns that are used just for their value.  But
it turned out to be tricky.  For instance, we can't skip
determine_visibility in a template; we can't even skip it for value-dep
expressions.  For example, no-linkage-expr1.C has

  using P = struct {}*;
  template <int N>
  void f(int(*)[((P)0, N)]) {}

where ((P)0, N) is value-dep, but N is not relevant here: we have to
ferret out the anonymous type.  When instantiating, it's already gone.

This patch uses decl_constant_var_p.  This is to implement (an
approximation) [basic.def.odr]#14.5.1 and [basic.def.odr]#5.2.

	PR c++/110323

gcc/cp/ChangeLog:

	* decl2.cc (min_vis_expr_r) <case VAR_DECL>: Do nothing for
	decl_constant_var_p VAR_DECLs.

gcc/testsuite/ChangeLog:

	* g++.dg/template/explicit-instantiation6.C: New test.
	* g++.dg/template/explicit-instantiation7.C: New test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant