<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - clang doesn't follow the SysV i386 ABI for global functions returning structures."
href="https://llvm.org/bugs/show_bug.cgi?id=23491">23491</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang doesn't follow the SysV i386 ABI for global functions returning structures.
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>libclang
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>abhiinnitald@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>klimek@google.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=14314" name="attach_14314" title="main file which calls foo1().">attachment 14314</a> <a href="attachment.cgi?id=14314&action=edit" title="main file which calls foo1().">[details]</a></span>
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</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>