Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception handling support #59

Open
luismarques opened this issue May 17, 2018 · 4 comments
Open

Exception handling support #59

luismarques opened this issue May 17, 2018 · 4 comments

Comments

@luismarques
Copy link
Contributor

Currently the code generation seems to optimize away everything but the no-throw code path. What's needed for generating code for the rest of the IR code paths? (e.g. landingpad, etc.).

By working around the current backend limitations regarding atomics and TLS, I have the D language runtime working. Yet, many parts of the standard library will misbehave due to throw exceptions not being handled. This ends up impacting functionality that would normally work even without exceptions. Given that this is the only major issue that seems to remain for proper D RISC-V support, adding this functionality would be most appreciated.

@luismarques
Copy link
Contributor Author

I had some success by setting ExceptionsType = ExceptionHandling::DwarfCFI and changing the configuration in MCObjectFileInfo.cpp to use .ubyte4 instead of .uleb128. Regarding the backend, there are some problems with the optimization passes using a non-existent register when exceptions are used. Regarding D, the D frontend seems to affect the configuration somehow and still uses .uleb128. So I'm working on fixing those.

@luismarques
Copy link
Contributor Author

More details: I had to change EHStreamer.cpp to use EmitLabelDifference instead of EmitLabelDifferenceAsULEB128 in a few places. The generated table is now probably correct, as can be seen by the fact that the catch block is now actually executed (but eventually crashes in __cxa_end_catch with a misaligned instruction access). That only works for textual assembly output (which to be assembled one must currently replace two .uleb128 with .byte). For object file output the exception table doesn't have the relocations generated properly. I'll have to figure out why.

@luismarques
Copy link
Contributor Author

OK, the crashes were because there was no implementation of getExceptionPointerRegister and getExceptionSelectorRegister. I'm assuming those should return X10 and X11 (a0 and a1). Although it would be nice to have that confirmed. Now I think we only need to have the stack adjustment CFI directives for the textual assembly to be completely correct.

@luismarques
Copy link
Contributor Author

(it also fixed the error about using a non-existent register, when optimizations are enabled; the problem with missing relocations persists though)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant