[cfe-dev] Is there a nicer way to error than "llvm_unreachable" at CodeGen ?

Mehdi Amini via cfe-dev cfe-dev at lists.llvm.org
Wed Jan 4 14:06:06 PST 2017


Caution: `llvm_unreachable` is absolutely *not* intended to report error. It is only asserting when assertions are enabled, and compiled out to “nothing” in release build.

We have report_fatal_error(“…”) for ICE (internal compiler error) when we want a behavior that is “assertions in release mode”, but that’s also not intended to happen (IMO): ideally it should *not* be possible to trigger it with valid IR (yeah we’re not doing a good job at it…).

So yes, you can diagnose an error properly, using the LLVMContext. For example open llvm/lib/Target/AMDGPU/SIISelLowering.cpp and search for: DAG.getContext()->diagnose(NoGraphicsHSA);

— 
Mehdi


> On Jan 4, 2017, at 12:43 PM, Nat! via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> 
> I would like to error and abandon compilation during code generation
> (after syntax/semantics is through), but not crash.
> 
> Ciao
>  Nat!
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list