[gcc] Replace rsp/rbp mov source with esp/ebp

The problem is that with POINTERS_EXTEND_UNSIGNED > 0 gcc considers high part of rsp and rbp to be zero, which is not true. This seems to be backend design flaw.

Fixing this by changing POINTERS_EXTEND_UNSIGNED to -1 and defining ptr_extend solves the problem but is likely to hit the performance of pointer arithmetics that does not involve rsp and rbp.

This fix fights the particular and most common case when rsp or rbp are sources of the mov instruction, by forcing this instructions to operate on low parts of the registers only. This is not the complete solution, and more changes will follow.

Test (-O1) must return 0 but returns high part of rsp without the fix:

struct StringRef {
  const char *Data;
  unsigned Length;
};

// Prevent inlining with 'weak' attribute
int print_size(struct StringRef Data) __attribute__((weak));

int print_size(struct StringRef Data) {
  return Data.Length;
}

int main() {
  char str[6]; // NEEDED!

  struct StringRef s;
  s.Data = str; // NEEDED!
  s.Length = 0;

  return print_size(s);
}

BUG=http://code.google.com/p/nativeclient/issues/detail?id=1304
TEST=see above

Review URL: http://codereview.chromium.org/6304009
1 file changed
tree: 5432e92ad33005129806df3696a000ebf7318aaa
  1. binutils/
  2. gcc/
  3. gdb/
  4. newlib/
  5. codereview.settings