https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66393

            Bug ID: 66393
           Summary: register asm input for inline asm not respected when
                    using a template
           Product: gcc
           Version: 4.8.5
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: krebbel at gcc dot gnu.org
  Target Milestone: ---

In the following example r1 is being used as input to the inline asm although
the register asm definition forces it into r2:

typedef unsigned long long int uint64_t;

template < typename T > static inline void
bar (T c)
{
  int a;
  register uint64_t b __asm__ ("r2") = (uint64_t)&a;
  __asm__ volatile (".long 0"::"d" (b):);
}

void
foo (uint64_t c)
{
  bar (c);
}

cc1plus -O1

_Z3fooy:
.LFB1:
        stg     %r15,120(%r15)
.LCFI0:
        aghi    %r15,-168
.LCFI1:
        lgr     %r1,%r15
        aghi    %r1,164    <------
#APP
# 8 "t.cc" 1
        .long 0
# 0 "" 2
#NO_APP
        lg      %r15,288(%r15)
.LCFI2:
        br      %r14


234r.ira:

  Loop 0 (parent -1, header bb2, depth 0)
    bbs: 2
    all: 0r62
    modified regnos: 62
    border:
    Pressure: GENERAL_REGS=2                    <------
    Hard reg set forest:
      0:( 0-14 16-31)@0
        1:( 0-13)@8000
      Allocno a0r62 of GENERAL_REGS(15) has 14 avail. regs  0-13, node:  0-13
(confl regs =  14-52)
      Pushing a0(r62,l0)(cost 0)
      Popping a0(r62,l0)  -- assign reg 1       <-------




The example can be made working just by removing the type template:

typedef unsigned long long int uint64_t;

static inline void
bar (uint64_t c)
{
  int a;
  register uint64_t b __asm__ ("r2") = (uint64_t)&a;
  __asm__ volatile (".long 0"::"d" (b):);
}

void
foo (uint64_t c)
{
  bar (c);
}



_Z3fooy:
.LFB1:
        stg     %r15,120(%r15)
.LCFI0:
        aghi    %r15,-168
.LCFI1:
        lgr     %r2,%r15
        aghi    %r2,164
#APP
# 8 "t.cc" 1
        .long 0
# 0 "" 2
#NO_APP
        lg      %r15,288(%r15)
.LCFI2:
        br      %r14

Reply via email to