NO

Author Topic: Fatal Error #3001 "Register Pressure Too High" on Pellesc V 9.0  (Read 3761 times)

melsmith

  • Guest
Hi Pelle:

   We are trying to build our 32-bit 'Super C' compiler (the xHarbour compiler) using the new Pellesc V9 as the base.  Previously, we have been using Pelles C V8 with no problem.

   I had a crash during the compilation of one of our c proggies  (sha2.c).

   The crash Error Message was #3001 and stated:
   
      "Register Pressure Too High.  Try to re-arrange the code around line 513"

   We've never had a message like this before, and do not know how to proceed.

   Near the middle of the code below is about where line 513 is located.

   Can you give us some guidance how to resolve this please ?

   Our many hundreds of programs are mostly written in the Harbour language, but a significant number are/were written in C. And we are not C experts.

Thanks,

-Mel Smith
(Repository Manager --- whosaway.com)
(a newbie here on your Forum)

 

***** fragment of code wher error occurred ****
      PACK64( &sub_block[ 0 ], &w[ 0 ] ); PACK64( &sub_block[ 8 ], &w[ 1 ] );
      PACK64( &sub_block[ 16 ], &w[ 2 ] ); PACK64( &sub_block[ 24 ], &w[ 3 ] );
      PACK64( &sub_block[ 32 ], &w[ 4 ] ); PACK64( &sub_block[ 40 ], &w[ 5 ] );
      PACK64( &sub_block[ 48 ], &w[ 6 ] ); PACK64( &sub_block[ 56 ], &w[ 7 ] );
      PACK64( &sub_block[ 64 ], &w[ 8 ] ); PACK64( &sub_block[ 72 ], &w[ 9 ] );
      PACK64( &sub_block[ 80 ], &w[ 10 ] ); PACK64( &sub_block[ 88 ], &w[ 11 ] );
      PACK64( &sub_block[ 96 ], &w[ 12 ] ); PACK64( &sub_block[ 104 ], &w[ 13 ] );
      PACK64( &sub_block[ 112 ], &w[ 14 ] ); PACK64( &sub_block[ 120 ], &w[ 15 ] );
// err crash here 'Register Pressure too high. Try to re-arrange your code'
      SHA512_SCR( 16 ); SHA512_SCR( 17 ); SHA512_SCR( 18 ); SHA512_SCR( 19 );
      SHA512_SCR( 20 ); SHA512_SCR( 21 ); SHA512_SCR( 22 ); SHA512_SCR( 23 );
      SHA512_SCR( 24 ); SHA512_SCR( 25 ); SHA512_SCR( 26 ); SHA512_SCR( 27 );
      SHA512_SCR( 28 ); SHA512_SCR( 29 ); SHA512_SCR( 30 ); SHA512_SCR( 31 );
      SHA512_SCR( 32 ); SHA512_SCR( 33 ); SHA512_SCR( 34 ); SHA512_SCR( 35 );
      SHA512_SCR( 36 ); SHA512_SCR( 37 ); SHA512_SCR( 38 ); SHA512_SCR( 39 );
      SHA512_SCR( 40 ); SHA512_SCR( 41 ); SHA512_SCR( 42 ); SHA512_SCR( 43 );
      SHA512_SCR( 44 ); SHA512_SCR( 45 ); SHA512_SCR( 46 ); SHA512_SCR( 47 );
      SHA512_SCR( 48 ); SHA512_SCR( 49 ); SHA512_SCR( 50 ); SHA512_SCR( 51 );
      SHA512_SCR( 52 ); SHA512_SCR( 53 ); SHA512_SCR( 54 ); SHA512_SCR( 55 );
      SHA512_SCR( 56 ); SHA512_SCR( 57 ); SHA512_SCR( 58 ); SHA512_SCR( 59 );
      SHA512_SCR( 60 ); SHA512_SCR( 61 ); SHA512_SCR( 62 ); SHA512_SCR( 63 );
      SHA512_SCR( 64 ); SHA512_SCR( 65 ); SHA512_SCR( 66 ); SHA512_SCR( 67 );
      SHA512_SCR( 68 ); SHA512_SCR( 69 ); SHA512_SCR( 70 ); SHA512_SCR( 71 );
      SHA512_SCR( 72 ); SHA512_SCR( 73 ); SHA512_SCR( 74 ); SHA512_SCR( 75 );
      SHA512_SCR( 76 ); SHA512_SCR( 77 ); SHA512_SCR( 78 ); SHA512_SCR( 79 );
// this is about line 513 noted in my message above.
      wv[ 0 ]  = ctx->h[ 0 ]; wv[ 1 ] = ctx->h[ 1 ];
      wv[ 2 ]  = ctx->h[ 2 ]; wv[ 3 ] = ctx->h[ 3 ];
      wv[ 4 ]  = ctx->h[ 4 ]; wv[ 5 ] = ctx->h[ 5 ];
      wv[ 6 ]  = ctx->h[ 6 ]; wv[ 7 ] = ctx->h[ 7 ];

      j        = 0;

      do
      {
         SHA512_EXP( 0, 1, 2, 3, 4, 5, 6, 7, j ); j++;
         SHA512_EXP( 7, 0, 1, 2, 3, 4, 5, 6, j ); j++;
         SHA512_EXP( 6, 7, 0, 1, 2, 3, 4, 5, j ); j++;
         SHA512_EXP( 5, 6, 7, 0, 1, 2, 3, 4, j ); j++;
         SHA512_EXP( 4, 5, 6, 7, 0, 1, 2, 3, j ); j++;
         SHA512_EXP( 3, 4, 5, 6, 7, 0, 1, 2, j ); j++;
         SHA512_EXP( 2, 3, 4, 5, 6, 7, 0, 1, j ); j++;
         SHA512_EXP( 1, 2, 3, 4, 5, 6, 7, 0, j ); j++;
      }
      while( j < 80 );

      ctx->h[ 0 ] += wv[ 0 ]; ctx->h[ 1 ] += wv[ 1 ];
      ctx->h[ 2 ] += wv[ 2 ]; ctx->h[ 3 ] += wv[ 3 ];
      ctx->h[ 4 ] += wv[ 4 ]; ctx->h[ 5 ] += wv[ 5 ];
      ctx->h[ 6 ] += wv[ 6 ]; ctx->h[ 7 ] += wv[ 7 ];
#endif /* !UNROLL_LOOPS */
 *********

Jokaste

  • Guest
Re: Fatal Error #3001 "Register Pressure Too High" on Pellesc V 9.0
« Reply #1 on: June 23, 2018, 06:39:22 PM »
Did you try to replace wv[xx] by a pointer
example:
register (or not) int wv[xx] ;
PtrWv = wv ;
ctx->h[6] += *(PtrWv + 6) ;

or try this:

register int j ;

SHA512_EXP( 0, 1, 2, 3, 4, 5, 6, 7, j++ );
         SHA512_EXP( 7, 0, 1, 2, 3, 4, 5, 6, j++ );
         SHA512_EXP( 6, 7, 0, 1, 2, 3, 4, 5, j++ );
         SHA512_EXP( 5, 6, 7, 0, 1, 2, 3, 4, j++ );
         SHA512_EXP( 4, 5, 6, 7, 0, 1, 2, 3, j++ );
         SHA512_EXP( 3, 4, 5, 6, 7, 0, 1, 2, j++ );
         SHA512_EXP( 2, 3, 4, 5, 6, 7, 0, 1, j++ );
         SHA512_EXP( 1, 2, 3, 4, 5, 6, 7, 0, j++ );

I don't know this message too. I am curious to get its meaning.

melsmith

  • Guest
Re: Fatal Error #3001 "Register Pressure Too High" on Pellesc V 9.0
« Reply #2 on: June 23, 2018, 07:32:19 PM »
Hi Jokaste:

   I will 'attempt' to make changes as you suggested but am a near beginner in C programming, but very experienced in my Harbour language (which uses a C language base). My compatriot (Enrico Maria Giordano) in Rome is also 'looking over my shoulder' and will help me.

   I am including below the full error message I received on my console during the early stages of the compile for a new 'build' of my Extended Harbour compiler (xHarbour).

   I should say that during  the early stages, about 313 .obj files were created before we had the 'crash' in the file sha2.c.

   We are accustomed over these past few years to have dozens of warnings, but usually we can carry on and produce a final executable under Version 8 of the PellesC compiler. And, If we did have an error, one of our C gurus could fix the problem. Now, most of our gurus have lost intense interest and only 'drop-in' every few months or so.

   So, we're lost as to what to do. Thus, I joined this forum, and request some elementary help.

Thanks for your response. I'll look at your suggestions, and try not to screw things up in my testing.

-Mel Smith

***** console error file below ****
Creating System Files (ST) ...

Microsoft (R) Program Maintenance Utility Version 14.10.25019.0
Copyright (C) Microsoft Corporation.  All rights reserved.

source\common\hbstr.c(1462): warning #1039: [ISO] No newline at end of file.
obj\pc\hbver.c(404): warning #2241: The function 'GetVersionExA' is marked as deprecated.
obj\pc\hbver.c(589): warning #2241: The function 'GetVersionExA' is marked as deprecated.
C:\xhbpc64\include\hbexprb.c(1800): warning #2229: Local 'pArg' is potentially used without being initialized.
source\common\hbstr.c(1462): warning #1039: [ISO] No newline at end of file.
source\common\hbver.c(404): warning #2241: The function 'GetVersionExA' is marked as deprecated.
source\common\hbver.c(589): warning #2241: The function 'GetVersionExA' is marked as deprecated.
C:\xhbpc64\source\vm\hvm.c(6816): warning #2030: '=' used in a conditional expression.
C:\xhbpc64\source\vm\classes.c(412): warning #2030: '=' used in a conditional expression.
C:\xhbpc64\source\vm\classes.c(524): warning #2030: '=' used in a conditional expression.
C:\xhbpc64\source\vm\classes.c(1969): warning #2030: '=' used in a conditional expression.
C:\xhbpc64\source\vm\classes.c(2143): warning #2030: '=' used in a conditional expression.
C:\xhbpc64\source\vm\classes.c(2523): warning #2030: '=' used in a conditional expression.
C:\xhbpc64\source\vm\classes.c(2552): warning #2030: '=' used in a conditional expression.
C:\xhbpc64\source\vm\classes.c(2622): warning #2030: '=' used in a conditional expression.
C:\xhbpc64\source\vm\classes.c(2854): warning #2030: '=' used in a conditional expression.
C:\xhbpc64\source\vm\classes.c(3240): warning #2030: '=' used in a conditional expression.
C:\xhbpc64\source\vm\classes.c(3275): warning #2030: '=' used in a conditional expression.
C:\xhbpc64\source\vm\classes.c(3531): warning #2030: '=' used in a conditional expression.
C:\xhbpc64\source\vm\classes.c(3611): warning #2030: '=' used in a conditional expression.
C:\xhbpc64\source\vm\classes.c(4171): warning #2030: '=' used in a conditional expression.
C:\xhbpc64\source\vm\classes.c(4201): warning #2030: '=' used in a conditional expression.
C:\xhbpc64\source\vm\classes.c(4247): warning #2030: '=' used in a conditional expression.
C:\xhbpc64\source\vm\classes.c(4286): warning #2030: '=' used in a conditional expression.
source\rtl\bkgtsks.c(303): warning #2030: '=' used in a conditional expression.
source\rtl\at.c(321): warning #1039: [ISO] No newline at end of file.
source\rtl\dateshb.c(769): warning #1039: [ISO] No newline at end of file.
source\rtl\filesys.c(3968): warning #2071: Overflow or truncation in constant expression.
source\rtl\fstemp.c(311): warning #2030: '=' used in a conditional expression.
source\rtl\hbsyslog.c(72): warning #2241: The function 'GetVersionExA' is marked as deprecated.
source\rtl\hbxml.c(2222): warning #2117: Old-style function definition for 'mxml_sgs_new'.
source\rtl\readline.c(147): warning #2071: Overflow or truncation in constant expression.
source\rtl\tprinter.c(154): warning #2241: The function 'GetVersionExA' is marked as deprecated.
source\rtl\tprinter.c(274): warning #2241: The function 'GetVersionExA' is marked as deprecated.
warning #2024: [ISO] Empty input file.
source\\rtl\\win32prn.prg(1147): warning #2241: The function 'GetVersionExA' is marked as deprecated.
source\\rtl\\winos.prg(148): warning #2241: The function 'GetVersionExA' is marked as deprecated.
source\rtl\sha2.c(513): fatal error #3001: Register pressure too high; try to rearrange the code (around line 513).
NMAKE : fatal error U1077: 'C:\PELLESC64\BIN\POCC.EXE' : return code '0x1'
Stop.
********

melsmith

  • Guest
Re: Fatal Error #3001 "Register Pressure Too High" on Pellesc V 9.0
« Reply #3 on: June 23, 2018, 07:39:21 PM »
Hi Jokaste:

   Below is the complete section of code within which the error occurred:

-Mel


****** code section in which error occurred ***
/* SHA-512 functions */

static void sha512_transf( sha512_ctx * ctx, const unsigned char * message,
                           unsigned int block_nb )
{
   uint64                  w[ 80 ];
   uint64                  wv[ 8 ];
   uint64                  t1, t2;
   const unsigned char *   sub_block;
   int                     i, j;

   for( i = 0; i < ( int ) block_nb; i++ )
   {
      sub_block = message + ( i << 7 );

#ifndef UNROLL_LOOPS
      for( j = 0; j < 16; j++ )
      {
         PACK64( &sub_block[ j << 3 ], &w[ j ] );
      }

      for( j = 16; j < 80; j++ )
      {
         SHA512_SCR( j );
      }

      for( j = 0; j < 8; j++ )
      {
         wv[ j ] = ctx->h[ j ];
      }

      for( j = 0; j < 80; j++ )
      {
         t1       = wv[ 7 ] + SHA512_F2( wv[ 4 ] ) + CH( wv[ 4 ], wv[ 5 ], wv[ 6 ] )
                    + sha512_k[ j ] + w[ j ];
         t2       = SHA512_F1( wv[ 0 ] ) + MAJ( wv[ 0 ], wv[ 1 ], wv[ 2 ] );
         wv[ 7 ]  = wv[ 6 ];
         wv[ 6 ]  = wv[ 5 ];
         wv[ 5 ]  = wv[ 4 ];
         wv[ 4 ]  = wv[ 3 ] + t1;
         wv[ 3 ]  = wv[ 2 ];
         wv[ 2 ]  = wv[ 1 ];
         wv[ 1 ]  = wv[ 0 ];
         wv[ 0 ]  = t1 + t2;
      }

      for( j = 0; j < 8; j++ )
      {
         ctx->h[ j ] += wv[ j ];
      }
#else
      PACK64( &sub_block[ 0 ], &w[ 0 ] ); PACK64( &sub_block[ 8 ], &w[ 1 ] );
      PACK64( &sub_block[ 16 ], &w[ 2 ] ); PACK64( &sub_block[ 24 ], &w[ 3 ] );
      PACK64( &sub_block[ 32 ], &w[ 4 ] ); PACK64( &sub_block[ 40 ], &w[ 5 ] );
      PACK64( &sub_block[ 48 ], &w[ 6 ] ); PACK64( &sub_block[ 56 ], &w[ 7 ] );
      PACK64( &sub_block[ 64 ], &w[ 8 ] ); PACK64( &sub_block[ 72 ], &w[ 9 ] );
      PACK64( &sub_block[ 80 ], &w[ 10 ] ); PACK64( &sub_block[ 88 ], &w[ 11 ] );
      PACK64( &sub_block[ 96 ], &w[ 12 ] ); PACK64( &sub_block[ 104 ], &w[ 13 ] );
      PACK64( &sub_block[ 112 ], &w[ 14 ] ); PACK64( &sub_block[ 120 ], &w[ 15 ] );
// next line is line 513 in which error occurred.
      SHA512_SCR( 16 ); SHA512_SCR( 17 ); SHA512_SCR( 18 ); SHA512_SCR( 19 );
      SHA512_SCR( 20 ); SHA512_SCR( 21 ); SHA512_SCR( 22 ); SHA512_SCR( 23 );
      SHA512_SCR( 24 ); SHA512_SCR( 25 ); SHA512_SCR( 26 ); SHA512_SCR( 27 );
      SHA512_SCR( 28 ); SHA512_SCR( 29 ); SHA512_SCR( 30 ); SHA512_SCR( 31 );
      SHA512_SCR( 32 ); SHA512_SCR( 33 ); SHA512_SCR( 34 ); SHA512_SCR( 35 );
      SHA512_SCR( 36 ); SHA512_SCR( 37 ); SHA512_SCR( 38 ); SHA512_SCR( 39 );
      SHA512_SCR( 40 ); SHA512_SCR( 41 ); SHA512_SCR( 42 ); SHA512_SCR( 43 );
      SHA512_SCR( 44 ); SHA512_SCR( 45 ); SHA512_SCR( 46 ); SHA512_SCR( 47 );
      SHA512_SCR( 48 ); SHA512_SCR( 49 ); SHA512_SCR( 50 ); SHA512_SCR( 51 );
      SHA512_SCR( 52 ); SHA512_SCR( 53 ); SHA512_SCR( 54 ); SHA512_SCR( 55 );
      SHA512_SCR( 56 ); SHA512_SCR( 57 ); SHA512_SCR( 58 ); SHA512_SCR( 59 );
      SHA512_SCR( 60 ); SHA512_SCR( 61 ); SHA512_SCR( 62 ); SHA512_SCR( 63 );
      SHA512_SCR( 64 ); SHA512_SCR( 65 ); SHA512_SCR( 66 ); SHA512_SCR( 67 );
      SHA512_SCR( 68 ); SHA512_SCR( 69 ); SHA512_SCR( 70 ); SHA512_SCR( 71 );
      SHA512_SCR( 72 ); SHA512_SCR( 73 ); SHA512_SCR( 74 ); SHA512_SCR( 75 );
      SHA512_SCR( 76 ); SHA512_SCR( 77 ); SHA512_SCR( 78 ); SHA512_SCR( 79 );

      wv[ 0 ]  = ctx->h[ 0 ]; wv[ 1 ] = ctx->h[ 1 ];
      wv[ 2 ]  = ctx->h[ 2 ]; wv[ 3 ] = ctx->h[ 3 ];
      wv[ 4 ]  = ctx->h[ 4 ]; wv[ 5 ] = ctx->h[ 5 ];
      wv[ 6 ]  = ctx->h[ 6 ]; wv[ 7 ] = ctx->h[ 7 ];

      j        = 0;

      do
      {
         SHA512_EXP( 0, 1, 2, 3, 4, 5, 6, 7, j ); j++;
         SHA512_EXP( 7, 0, 1, 2, 3, 4, 5, 6, j ); j++;
         SHA512_EXP( 6, 7, 0, 1, 2, 3, 4, 5, j ); j++;
         SHA512_EXP( 5, 6, 7, 0, 1, 2, 3, 4, j ); j++;
         SHA512_EXP( 4, 5, 6, 7, 0, 1, 2, 3, j ); j++;
         SHA512_EXP( 3, 4, 5, 6, 7, 0, 1, 2, j ); j++;
         SHA512_EXP( 2, 3, 4, 5, 6, 7, 0, 1, j ); j++;
         SHA512_EXP( 1, 2, 3, 4, 5, 6, 7, 0, j ); j++;
      }
      while( j < 80 );

      ctx->h[ 0 ] += wv[ 0 ]; ctx->h[ 1 ] += wv[ 1 ];
      ctx->h[ 2 ] += wv[ 2 ]; ctx->h[ 3 ] += wv[ 3 ];
      ctx->h[ 4 ] += wv[ 4 ]; ctx->h[ 5 ] += wv[ 5 ];
      ctx->h[ 6 ] += wv[ 6 ]; ctx->h[ 7 ] += wv[ 7 ];
#endif /* !UNROLL_LOOPS */
   }
}


Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Fatal Error #3001 "Register Pressure Too High" on Pellesc V 9.0
« Reply #4 on: June 23, 2018, 09:25:11 PM »
So that problem is with 32-bit only.
And x64 without UNROLL_LOOPS.
« Last Edit: June 24, 2018, 07:57:22 AM by TimoVJL »
May the source be with you

Jokaste

  • Guest
Re: Fatal Error #3001 "Register Pressure Too High" on Pellesc V 9.0
« Reply #5 on: June 23, 2018, 09:54:53 PM »
Code: [Select]
SHA512_SCR( 16 );I think you would look inside this macro.
If Pelle could give you more help on this compiler error, his help would be welcome.
« Last Edit: June 24, 2018, 03:56:18 AM by Jokaste »

melsmith

  • Guest
Re: Fatal Error #3001 "Register Pressure Too High" on Pellesc V 9.0
« Reply #6 on: June 24, 2018, 01:19:21 AM »
Hi Jokaste and TimoVJL
 
   I wrote a whole bunch her a little while ago, and suddenly it disappeared :(  Now I've got to write it again.

   Today one of our C gurus (Luiz Culik from Brazil) dropped into our newsgroup (comp.lang.xharbour) and posted some changes that cured the problem.

   I don't understand what he did but, the 'Register Pressure' error disappeared.

   So, thanks for your help, and I apologize for wasting your time on this.  If I come to understand what Luiz did, I'll post that here.

Thanks again,

-Mel Smith
www.whosaway.com



**** today''s changes ****
2018-06-23 17:20 UTC-0300  Luiz Rafael Culik <luiz@xharbour.com.br>
  * make_pc.bat
  * winmake\makefile.pc
    ! some fix to build dll and contribs
   ! for proper build set __make__=nmake ( using msvc nmake to build full pelles c 64 bits binaries )

2018-06-23 12:50 UTC-0300  Luiz Rafael Culik <luiz@xharbour.com.br>
  * include\hbapi.h
  * source\common\hbarch.c
    ! added missing cast to hb_get_rev_double and hb_get_std_double to make pellesc 64 bits compiler happy
  * source\common\hbstr.c
    source\rtl\at.c
   source\rtl\dateshb.c
    ! added new line to end of file
  * source\rtl\filesys.c
    ! added an missing USHORT cast on hb_fsIsDrv function
  * source\rtl\hbxml.c
    ! fixed old style declaration to mxml_sgs_new()
  * source\rtl\zlib\crc32.c
    ! fixed old style declaration to get_crc_table
  * source\rtl\zlib\zutil.c
    ! fixed old style declaration to zlibVersion and zlibCompileFlags
********* end of changes ****

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Fatal Error #3001 "Register Pressure Too High" on Pellesc V 9.0
« Reply #7 on: June 24, 2018, 03:33:53 PM »
melsmith: if I understand this confused thread correctly, you were compiling in X86 (32-bit) mode and are now compiling in X64 (64-bit) mode?

This code is 64-bit heavy (operating mostly on uint64).

In X86 mode there are six 32-bit register, in X64 mode there are fourteen 32/64-bit registers.
In X86 mode there can be a maximum of three 64-bit values loaded simultaneously in registers (each value needs two 32-bit registers). Not much!
In X64 mode there can be fourteen values loaded simultaneously in registers (each value needs one 64-bit registers).  Much!

The problem in X86 mode is with all these 64-bit shifts xor:ed together; 64-bit shifts on X86 were previously library calls, but from this version they are inlined (increasing register pressure).

The fix is to introduce more temporaries (that can be spilled), which I will do for the next release candidate. To fix it right this moment, add them yourself:

Change code in macros like SHA512_F1(), SHA512_F2(), SHA512_F3(), SHA512_F4() from:
ROTR(1) ^ ROTR(2) ^ ROTR(3)
to something like:
uint64 t1, t2, t3;
t1 = ROTR(1);
t2 = ROTR(2);
t3 = ROTR(3);
result = t1 ^ t2 ^ t3
(needs a bit of rewrite)
/Pelle

melsmith

  • Guest
Re: Fatal Error #3001 "Register Pressure Too High" on Pellesc V 9.0
« Reply #8 on: June 24, 2018, 10:22:38 PM »
Hi Pelle:

   Thanks for the response !

   Over the last 8 hours,I have determined that the 64-bit build of my xharbour app is (almost) perfect. The imperfection is being looked at by both gurus Luiz Culik and Enrico Giordano.

   (it involves the statement:  Harbour.exe /build > buildlog.txt -- which crashes with the error message
      "CRT: unhandled exception (main) terminating"

      However, the statement harbour.exe /build sends the build info to the console correctly)

   OTOH, I determined the the 32-bit build *still* has "Register Pressure", and I will look at your suggested fix, and await your next release candidate.

Thanks again for tolerating my surely confused complaint.

-Mel Smith