DSC Compiler internal error and inline fucntions (an hint and possible solution)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DSC Compiler internal error and inline fucntions (an hint and possible solution)

670 Views
Lorenzo_Mch_IT
Contributor IV

Hi, this is not a question, but an information that I think can be useful to others.


I encountered a weird bug in the DSC compiler: compiling with a lot of optimizations enabled (especially automatic mapping to DSC register of C source variables)
when in your source you call an inline function containign assembly code, sometimes the compiler throws a quite enigmatic "internal error" and Codewarrior for MCU error line tagging usually marks the last line in the calling code's source file.

If you look at the log messages you will notice that the actual error message references a line inside a function that calls one or more inline assembly functions.

This usually happens when inside the called inline function you directly reference some DSC registers mixed with register variables.

It seems that sometimes compiler's automatic register allocation fails to find a mapping for all registers in a chunk of inlined assembly code and instead of throwing an error about register allocation it goes bonkers with a generic "internal compiler error" message because it just can't find a valid DSC registers mapping and can't find how to spill at least some of them to stack. 

TL;DR: if you get weird "internal compiler error" messages, look in the source that fails to compile for inline assembly or calls to inline functions containing inline assembly, the actual error source is likely there.
Usually directly referencing less DSC registers or splitting the assembly code in separate __asm{ ... } blocks fixes the issue (because in the latter case the compiler can more easily spill "between block" C    register variables to/from stack and reuse more DSC registers).

P.S. I can't provide source code examples that replicate the issue, I'd have to publish a big chunk of proprietary code and I'm not authorized to do that. But knowing the general direction this type of "internal compiler error" comes from, will let you track the exact source very quickly if it happens to you.

0 Kudos
0 Replies