This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Support __builtin_frame_address
ClosedPublic

Authored by sunfish on Feb 16 2016, 3:22 PM.

Details

Summary

This adds support for __builtin_frame_address. Nothing fancy; just the basics.

Diff Detail

Repository
rL LLVM

Event Timeline

sunfish updated this revision to Diff 48116.Feb 16 2016, 3:22 PM
sunfish retitled this revision from to [WebAssembly] Support __builtin_frame_address.
sunfish updated this object.
sunfish added a reviewer: dschuff.
sunfish set the repository for this revision to rL LLVM.
jfb added a comment.Feb 16 2016, 3:29 PM

Awesome! Just one comment update, then lgtm.

lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
586 ↗(On Diff #48116)

This just returns zero, right? That seems like valid behavior so I'd say so in the comment above:

On some machines it may be impossible to determine the frame address of any function other than the current one; in such cases, or when the top of the stack has been reached, this function returns 0 if the first frame pointer is properly initialized by the startup code.

Calling this function with a nonzero argument can have unpredictable effects, including crashing the calling program. As a result, calls that are considered unsafe are diagnosed when the -Wframe-address option is in effect. Such calls should only be made in debugging situations.
dschuff added inline comments.Feb 16 2016, 3:30 PM
lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
586 ↗(On Diff #48116)

Just returning SDValue() here will cause an isel failure, which is fatal with an obscure error. We should probably fail() gracefully with a diagnostic here instead.

dschuff edited edge metadata.Feb 16 2016, 3:31 PM

Otherwise LGTM too

lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
586 ↗(On Diff #48116)

Or returning 0 would be fine too. Maybe even better if that's what GCC. does.

dschuff accepted this revision.Feb 16 2016, 3:31 PM
dschuff edited edge metadata.
This revision is now accepted and ready to land.Feb 16 2016, 3:31 PM
dschuff added inline comments.Feb 16 2016, 3:33 PM
lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
586 ↗(On Diff #48116)

Sorry, this returns an empty SDValue and not the original one. Ignore my previous comment.

This revision was automatically updated to reflect the committed changes.