[LLVMbugs] [Bug 12395] New: Memory Alighnment Issue with the VLDR Instruction.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Mar 29 04:47:14 PDT 2012


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

             Bug #: 12395
           Summary: Memory Alighnment Issue with the VLDR Instruction.
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: narendra.974 at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


While i am trying to execute the below program 

struct inner {
 double d;
 int i;
};
struct outer {
  struct inner in;
} __attribute__ ((packed));
double temp_double = 4.0;
int temp_int = 444444;

struct outer temp_outer;
void
check_outer (struct outer *p)
{
  if (p->in.d != temp_double{}
  if (p->in.i != temp_int){}
}
int main()
{
   check_outer (&temp_outer);
}
The program Crashed.


on analyzing the issue i found an issue with VLDR Instruction generated.

In the Test example above.
Assembly code for the check_outer function in the Test Case. (SIGILL is
received while executing this function.)

00008450 <check_outer>:
    8450:       e24dd008        sub     sp, sp, #8
    8454:       e58d0004        str     r0, [sp, #4]
    8458:       edd00b00        vldr    d16, [r0]
    845c:       e30016a8        movw    r1, #1704       ; 0x6a8
    8460:       e3401001        movt    r1, #1
    8464:       edd11b00        vldr    d17, [r1]
    8468:       eef40be1        vcmpe.f64       d16, d17

The Code it represents is 

void
check_outer (struct outer *p)
{

  if (p->in.d != temp_double)
    {
   }

The value p->in.d is stored in d16 register and temp_double is stored in d17
register and both will be compared.

When the memory address passed to the VLDR instruction is byte aligned, 
program is executing fine.
If the memory address is not 8 byte aligned it is giving SIGILL instruction.

If the argument passed to the check_outer is global,  it is not byte aligned. 
Then the VLDR instruction is giving SIGILL error.

even when the variable passed is global and if it byte aligned program is
executing fine.
That is declaring the global variable like this :  struct outer temp_outer
__attribute__ ((aligned (8)));

if the argument passed to the check_outer is a stack variable, Then the memory
address is byte aligned and the program runs fine.

-- 
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