[LLVMdev] LLVM asserts
Kenneth Uildriks
kennethuil at gmail.com
Thu Aug 20 06:50:34 PDT 2009
> To be fully clear, I'm not a big fan of the current llvm_report_error
> approach (though it is definitely better than what we had before!).
> In my ideal little world, when the backend invokes llvm_report_error,
> it should *guarantee* that it can continue on and return back. For
> example, in an inline asm error, I think the code generator should
> report the error with llvm_report_error and then discard the invalid
> inline asm and continue code generation.
On one hand, the same thing could occur with any malformed
construct... a type mismatch in the values fed to CreateCall, for
instance, wouldn't corrupt memory; the error could be reported and the
CallInst discarded. On the other hand, of course, if the client is
expected to check for that stuff, it would slow things down to check
for it again on each CreateXXX call, so I certainly see the logic in
keeping that the way it is.
I think it would be a big improvement for the asserts in those cases
to print out what values it expected and what values it got, say by
dumping the offending Value or Type objects to the console along with
the line in Instructions.cpp where the assert happens. Would y'all
look kindly on a patch for that after the release? I think it would
speed up every client development project. I know as I develop my
compiler, I would love to have a way to print out that information if,
and only if, something is wrong with the values I'm trying to feed
CreateXXX.
>
> This approach gives clients flexibility over how to handle the
> problem: if they want to immediately abort they can (and this should
> be the default behavior). However, if the code generator is embedded
> into a larger app, the app should be able to install a handler, do
> code generation and when it completes, it could check for an error and
> report it however desired. Right now the only reasonable
> implementation of an error handler ends in exit(1) which is not optimal.
>
> -Chris
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
More information about the llvm-dev
mailing list