https://llvm.org/bugs/show_bug.cgi?id=23491

            Bug ID: 23491
           Summary: clang doesn't follow the SysV i386 ABI for global
                    functions returning structures.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: libclang
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

Created attachment 14314
  --> https://llvm.org/bugs/attachment.cgi?id=14314&action=edit
main file which calls foo1().

According to SysV i386 ABI document "SYSTEM V APPLICATION BINARY INTERFACE,
Intel386 Architecture Processor Supplement, Fourth Edition":

A function returning structure sets %eax to the value of the original address
of the structure while returning so that when the caller receives control
again, the address of the returned object resides in register %eax and can be
used to access the object.

Compiling sup.c (contents given below) using clang 3.7.0, the generated
assembly does not update %eax with the address of the structure while returning
from the function foo1() 

File sup.c contains a function foo1() that accepts a structure as an argument
and returns the same structure. The contents of the file are:

struct baar{
  int a;
  int b;
};

struct baar foo1(struct baar x)
{
  return x ;
}

Compilation command used:
clang -g -O0 -m32 -c sup.c -o sup.o

Attached here is main.c file from which a call to foo1() is made. 
main.o and sup.o files were linked to generate executable.

Platform: Ubuntu 14.04, x86_64 GNU/Linux

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to