<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - RISCV interrupt attribute doesn't preserve caller-saved registers when calling functions"
href="https://bugs.llvm.org/show_bug.cgi?id=42984">42984</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>RISCV interrupt attribute doesn't preserve caller-saved registers when calling functions
</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>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>chaos2007@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=22373" name="attach_22373" title="Sample test case of expected behavior">attachment 22373</a> <a href="attachment.cgi?id=22373&action=edit" title="Sample test case of expected behavior">[details]</a></span>
Sample test case of expected behavior
There seem to be 2 cases of the interrupt attribute being tested.
1. A minimal interrupt where only the registers being used are preserved.
2. An interrupt that preserves all registers since it is making a function
call.
However, there is also the case of:
3. An interrupt that contains some logic, as well as making function calls.
It needs to preserve caller-saved registers before making function calls.
I have attached a sample test case for what I expect would happen.
Below I have included a sample c file that illustrates the behavior:
extern int foo();
extern void otherfoo();
extern int c;
__attribute__((interrupt)) void foo_with_call_interrupt(void) {
int x = foo();
otherfoo();
c = x;
}
A quick explanation of the C file.
1. I make a call to a function that returns an integer, this will now be in reg
a0.
2. I then make a call to another function, this function could have trashed reg
a0.
3. I try and use the integer returned from the first function. Reg a0 was
never preserved, so we are running off of undefined behavior.</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>