Skip to content

Commit acb3cfb

Browse files
aykevldeadprogram
authored andcommitted
avr: work around codegen bug in LLVM 10
Commit fc4857e (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.
1 parent 8cfc400 commit acb3cfb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/runtime/print.go

+10
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ func printint16(n int16) {
4848
}
4949

5050
func printuint32(n uint32) {
51+
if TargetBits == 8 {
52+
// AVR-specific workaround on LLVM 10. Should be removed when we switch
53+
// to LLVM 11.
54+
prevdigits := n / 10
55+
if prevdigits != 0 {
56+
printuint32(prevdigits)
57+
}
58+
putchar(byte((n % 10) + '0'))
59+
return
60+
}
5161
printuint64(uint64(n))
5262
}
5363

0 commit comments

Comments
 (0)