[LLVMbugs] [Bug 8540] New: "llvm-gcc -m96bit-long-double" addresses memory incorrectly

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Nov 3 07:40:38 PDT 2010


http://llvm.org/bugs/show_bug.cgi?id=8540

           Summary: "llvm-gcc -m96bit-long-double" addresses memory
                    incorrectly
           Product: new-bugs
           Version: 2.8
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: jdenny at etinternational.com
                CC: llvmbugs at cs.uiuc.edu


My platform is x86-64, so llvm-gcc normally folds sizeof(long double) into 16. 
The problem is that "llvm-gcc -m96bit-long-double" folds sizeof(long double)
into 12, but getelementptr still assumes 16.

This problem can be demonstrated as follows:

% cat > test.c
#include <stdio.h>
#include <stdlib.h>
#define SIZE 5
int
main(void)
{
  long double *a = malloc(sizeof(long double) * SIZE);
  for (int i = 0; i < SIZE; ++i)
    a[i] = i+1;
  for (int i = 0; i < SIZE; ++i)
    printf ("a[%d] = %Lf\n", i, a[i]);
  free (a);
  return 0;
}
% llvm-gcc -std=c99 -m96bit-long-double -emit-llvm -S -o test.ll test.c
% llvmc test.ll
% valgrind ./a.out |& grep Invalid
==3882== Invalid write of size 4
==3882== Invalid write of size 2
==3882== Invalid read of size 4
==3882== Invalid read of size 2

Looking inside test.ll, I see f80:128:128, but I also see sizeof(long 
double)*5 folded into 60.  Changing f80:128:128 to f80:96:96 does not fix 
the errors reported by valgrind.  If I instead fix the folded constant, 
the errors go away, of course.

Further discussion appears in this thread:

  http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-November/035936.html

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list