From acb3cfba6d2775598b923e502c64c4b13b2ec9ce Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Tue, 30 Jun 2020 15:59:17 +0200 Subject: [PATCH] avr: work around codegen bug in LLVM 10 Commit fc4857e98c (runtime: avoid recursion in printuint64 function) caused a regression for AVR. I have tried locally with LLVM 11 (which contains a number of codegen bugs) and the issue is no longer present, so I'm assuming it's a codegen bug that is now fixed. However, LLVM 11 is not yet released so it seems best to me to work around this temporarily (for the next few months). This commit can easily be reverted when we start using LLVM 11. --- src/runtime/print.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/runtime/print.go b/src/runtime/print.go index e4d71517..706904fb 100644 --- a/src/runtime/print.go +++ b/src/runtime/print.go @@ -48,6 +48,16 @@ func printint16(n int16) { } func printuint32(n uint32) { + if TargetBits == 8 { + // AVR-specific workaround on LLVM 10. Should be removed when we switch + // to LLVM 11. + prevdigits := n / 10 + if prevdigits != 0 { + printuint32(prevdigits) + } + putchar(byte((n % 10) + '0')) + return + } printuint64(uint64(n)) }