[LLVMbugs] [Bug 23491] New: clang doesn't follow the SysV i386 ABI for global functions returning structures.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue May 12 03:01:25 PDT 2015


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: unassignedclangbugs at nondot.org
          Reporter: abhiinnitald at gmail.com
                CC: klimek at google.com, llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150512/feee0740/attachment.html>


More information about the llvm-bugs mailing list