Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

r6/r7 are not saved/restored when modified only by landing pad entry #27101

Closed Quuxplusone closed 8 years ago

Quuxplusone commented 8 years ago
Bugzilla Link PR27102
Status RESOLVED FIXED
Importance P normal
Reported by Marcin Kościelnicki (koriakin@0x04.net)
Reported on 2016-03-28 18:12:51 -0700
Last modified on 2016-06-28 14:58:57 -0700
Version trunk
Hardware Other Linux
CC kit.barton@gmail.com, llvm-bugs@lists.llvm.org, uweigand@de.ibm.com
Fixed by commit(s)
Attachments 0001-SystemZ-Save-restore-r6-and-r7-if-function-contains-.patch (1860 bytes, text/plain)
Blocks
Blocked by
See also
Created attachment 16106
Proposed patch.

$ cat x.cc
void f();

void g() {
        try {
                f();
        } catch (...) {
        }
}
$ clang --target=s390x-unknown-linux-gnu x.cc -S
$ cat x.s
[...]
stmg    %r11, %r15, 88(%r15)
[...]

Only r11-r15 are saved and restored, despite r6 and r7 being modified by
landing pad entry.  This can result in the function clobbering r6 and r7,
violating the ABI.

Proposed patch attached, but I'm not sure if it's the right place - some
generic code could be a better option, but I couldn't find an easy way to plumb
the register information from TargetLowering.  What do you think?

Found while porting ASan to s390 (breaks throw_catch.cc test).
Quuxplusone commented 8 years ago

Attached 0001-SystemZ-Save-restore-r6-and-r7-if-function-contains-.patch (1860 bytes, text/plain): Proposed patch.

Quuxplusone commented 8 years ago

I have submitted it as http://reviews.llvm.org/D18541