<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi I’m having a problem with my back end.<div class=""><br class=""></div><div class="">This LLVM IR…</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class="">; ModuleID = 'main_clean.ll'</div><div class="">source_filename = "main.ll"</div><div class="">target datalayout = "e-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8"</div><div class="">target triple = "avr-atmel-linux-gnueabihf"</div><div class=""><br class=""></div><div class="">%Ts5UInt8V = type <{ i8 }></div><div class="">%Ts6UInt16V = type <{ i16 }></div><div class=""><br class=""></div><div class="">@"$s4main3rads5UInt8Vvp" = hidden local_unnamed_addr global %Ts5UInt8V zeroinitializer, align 1</div><div class="">@"$s4main3angs6UInt16Vvp" = hidden local_unnamed_addr global %Ts6UInt16V zeroinitializer, align 2</div><div class="">@__swift_reflection_version = linkonce_odr hidden constant i16 3</div><div class="">@_swift1_autolink_entries = private constant [6 x i8] c"-lavr\00", section ".swift1_autolink_entries", align 2</div><div class="">@llvm.used = appending global [2 x i8*] [i8* bitcast (i16* @__swift_reflection_version to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @_swift1_autolink_entries, i32 0, i32 0)], section "llvm.metadata"</div><div class=""><br class=""></div><div class="">; Function Attrs: noreturn</div><div class="">define protected i16 @main(i16, i8** nocapture readnone) local_unnamed_addr #0 {</div><div class="">entry:</div><div class=""> %2 = tail call swiftcc i16 @"$s3AVR14slowAnalogRead3pins6UInt16Vs5UInt8V_tF"(i8 2)</div><div class=""> tail call swiftcc void @"$s3AVR7srandom4seedys6UInt16V_tF"(i16 %2)</div><div class=""> tail call swiftcc void @"$s3AVR11SetupSerial8baudRateys6UInt16V_tF"(i16 9600)</div><div class=""> %3 = tail call swiftcc i16 @"$s3AVR6randoms5Int16VyF"()</div><div class=""> store i8 0, i8* getelementptr inbounds (%Ts5UInt8V, %Ts5UInt8V* @"$s4main3rads5UInt8Vvp", i16 0, i32 0), align 1</div><div class=""> store i16 0, i16* getelementptr inbounds (%Ts6UInt16V, %Ts6UInt16V* @"$s4main3angs6UInt16Vvp", i16 0, i32 0), align 2</div><div class=""> tail call swiftcc void @"$s3AVR5print11unsignedInt10addNewlineys6UInt16V_SbtF"(i16 0, i1 true)</div><div class=""> tail call swiftcc void @"$s3AVR5print11unsignedInt10addNewlineys6UInt16V_SbtF"(i16 0, i1 true)</div><div class=""> br label %4</div><div class=""><br class=""></div><div class="">; <label>:4: ; preds = %4, %entry</div><div class=""> tail call swiftcc void @"$s3AVR4wait2msys6UInt16V_tF"(i16 100)</div><div class=""> %5 = tail call swiftcc { i16, i16 } @"$s3AVR11longRandom4s5UInt8V5byte1_AD5byte2AD5byte3AD5byte4tyF"()</div><div class=""> %6 = extractvalue { i16, i16 } %5, 1</div><div class=""> %temp-coercion.coerced.sroa.5.2.extract.trunc = trunc i16 %6 to i8</div><div class=""> tail call swiftcc void @"$s3AVR5print15unsignedTinyInt10addNewlineys5UInt8V_SbtF"(i8 %temp-coercion.coerced.sroa.5.2.extract.trunc, i1 true)</div><div class=""> br label %4</div><div class="">}</div><div class=""><br class=""></div><div class="">declare swiftcc i16 @"$s3AVR14slowAnalogRead3pins6UInt16Vs5UInt8V_tF"(i8) local_unnamed_addr #1</div><div class=""><br class=""></div><div class="">declare swiftcc void @"$s3AVR7srandom4seedys6UInt16V_tF"(i16) local_unnamed_addr #1</div><div class=""><br class=""></div><div class="">declare swiftcc void @"$s3AVR11SetupSerial8baudRateys6UInt16V_tF"(i16) local_unnamed_addr #1</div><div class=""><br class=""></div><div class="">declare swiftcc i16 @"$s3AVR6randoms5Int16VyF"() local_unnamed_addr #1</div><div class=""><br class=""></div><div class="">declare swiftcc void @"$s3AVR5print11unsignedInt10addNewlineys6UInt16V_SbtF"(i16, i1) local_unnamed_addr #1</div><div class=""><br class=""></div><div class="">declare swiftcc void @"$s3AVR4wait2msys6UInt16V_tF"(i16) local_unnamed_addr #1</div><div class=""><br class=""></div><div class="">declare swiftcc { i16, i16 } @"$s3AVR11longRandom4s5UInt8V5byte1_AD5byte2AD5byte3AD5byte4tyF"() local_unnamed_addr #1</div><div class=""><br class=""></div><div class="">declare swiftcc void @"$s3AVR5print15unsignedTinyInt10addNewlineys5UInt8V_SbtF"(i8, i1) local_unnamed_addr #1</div><div class=""><br class=""></div><div class="">; Function Attrs: norecurse nounwind readnone</div><div class="">define hidden swiftcc i16 @"$s4main13setServoAngle5angles6UInt16Vs6UInt32V_tF"(i32) local_unnamed_addr #2 {</div><div class="">entry:</div><div class=""> ret i16 0</div><div class="">}</div><div class=""><br class=""></div><div class="">attributes #0 = { noreturn "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" }</div><div class="">attributes #1 = { "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" }</div><div class="">attributes #2 = { norecurse nounwind readnone "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" }</div><div class=""><br class=""></div><div class="">!swift.module.flags = !{!0}</div><div class=""><br class=""></div><div class="">!0 = !{!"standard-library", i1 false}</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">…produces this assembly when compiled with llc with the AVR back end…</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.text</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.file<span class="Apple-tab-span" style="white-space:pre"> </span>"main.ll"</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.protected<span class="Apple-tab-span" style="white-space:pre"> </span>main ; -- Begin function main</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.globl<span class="Apple-tab-span" style="white-space:pre"> </span>main</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.p2align<span class="Apple-tab-span" style="white-space:pre"> </span>1</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.type<span class="Apple-tab-span" style="white-space:pre"> </span>main,@function</div><div class="">main: ; @main</div><div class="">; %bb.0: ; %entry</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>push<span class="Apple-tab-span" style="white-space:pre"> </span>r16</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>push<span class="Apple-tab-span" style="white-space:pre"> </span>r17</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ldi<span class="Apple-tab-span" style="white-space:pre"> </span>r24, 2</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>call<span class="Apple-tab-span" style="white-space:pre"> </span>($s3AVR14slowAnalogRead3pins6UInt16Vs5UInt8V_tF)</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>call<span class="Apple-tab-span" style="white-space:pre"> </span>($s3AVR7srandom4seedys6UInt16V_tF)</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ldi<span class="Apple-tab-span" style="white-space:pre"> </span>r24, 128</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ldi<span class="Apple-tab-span" style="white-space:pre"> </span>r25, 37</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>call<span class="Apple-tab-span" style="white-space:pre"> </span>($s3AVR11SetupSerial8baudRateys6UInt16V_tF)</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>call<span class="Apple-tab-span" style="white-space:pre"> </span>($s3AVR6randoms5Int16VyF)</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ldi<span class="Apple-tab-span" style="white-space:pre"> </span>r24, 0</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>sts<span class="Apple-tab-span" style="white-space:pre"> </span>($s4main3rads5UInt8Vvp), r24</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ldi<span class="Apple-tab-span" style="white-space:pre"> </span>r16, 0</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ldi<span class="Apple-tab-span" style="white-space:pre"> </span>r17, 0</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>sts<span class="Apple-tab-span" style="white-space:pre"> </span>($s4main3angs6UInt16Vvp)+1, r17</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>sts<span class="Apple-tab-span" style="white-space:pre"> </span>($s4main3angs6UInt16Vvp), r16</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>movw<span class="Apple-tab-span" style="white-space:pre"> </span>r24, r16</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ldi<span class="Apple-tab-span" style="white-space:pre"> </span>r22, 1</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>call<span class="Apple-tab-span" style="white-space:pre"> </span>($s3AVR5print11unsignedInt10addNewlineys6UInt16V_SbtF)</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>movw<span class="Apple-tab-span" style="white-space:pre"> </span>r24, r16</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ldi<span class="Apple-tab-span" style="white-space:pre"> </span>r22, 1</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>call<span class="Apple-tab-span" style="white-space:pre"> </span>($s3AVR5print11unsignedInt10addNewlineys6UInt16V_SbtF)</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ldi<span class="Apple-tab-span" style="white-space:pre"> </span>r16, 100</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ldi<span class="Apple-tab-span" style="white-space:pre"> </span>r17, 0</div><div class="">LBB0_1: ; =>This Inner Loop Header: Depth=1</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>movw<span class="Apple-tab-span" style="white-space:pre"> </span>r24, r16</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>call<span class="Apple-tab-span" style="white-space:pre"> </span>($s3AVR4wait2msys6UInt16V_tF)</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>call<span class="Apple-tab-span" style="white-space:pre"> </span>($s3AVR11longRandom4s5UInt8V5byte1_AD5byte2AD5byte3AD5byte4tyF)</div><div class=""> ; kill: def $r24 killed $r24 killed $r25r24</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ldi<span class="Apple-tab-span" style="white-space:pre"> </span>r22, 1</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>call<span class="Apple-tab-span" style="white-space:pre"> </span>($s3AVR5print15unsignedTinyInt10addNewlineys5UInt8V_SbtF)</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>rjmp<span class="Apple-tab-span" style="white-space:pre"> </span>LBB0_1</div><div class="">.Lfunc_end0:</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.size<span class="Apple-tab-span" style="white-space:pre"> </span>main, .Lfunc_end0-main</div><div class=""> ; -- End function</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.hidden<span class="Apple-tab-span" style="white-space:pre"> </span>$s4main13setServoAngle5angles6UInt16Vs6UInt32V_tF ; -- Begin function $s4main13setServoAngle5angles6UInt16Vs6UInt32V_tF</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.globl<span class="Apple-tab-span" style="white-space:pre"> </span>$s4main13setServoAngle5angles6UInt16Vs6UInt32V_tF</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.p2align<span class="Apple-tab-span" style="white-space:pre"> </span>1</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.type<span class="Apple-tab-span" style="white-space:pre"> </span>$s4main13setServoAngle5angles6UInt16Vs6UInt32V_tF,@function</div><div class="">$s4main13setServoAngle5angles6UInt16Vs6UInt32V_tF: ; @"$s4main13setServoAngle5angles6UInt16Vs6UInt32V_tF"</div><div class="">; %bb.0: ; %entry</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ldi<span class="Apple-tab-span" style="white-space:pre"> </span>r24, 0</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ldi<span class="Apple-tab-span" style="white-space:pre"> </span>r25, 0</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ret</div><div class="">.Lfunc_end1:</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.size<span class="Apple-tab-span" style="white-space:pre"> </span>$s4main13setServoAngle5angles6UInt16Vs6UInt32V_tF, .Lfunc_end1-($s4main13setServoAngle5angles6UInt16Vs6UInt32V_tF)</div><div class=""> ; -- End function</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.hidden<span class="Apple-tab-span" style="white-space:pre"> </span>$s4main3rads5UInt8Vvp ; @"$s4main3rads5UInt8Vvp"</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.type<span class="Apple-tab-span" style="white-space:pre"> </span>$s4main3rads5UInt8Vvp,@object</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.section<span class="Apple-tab-span" style="white-space:pre"> </span>.bss,"aw",@nobits</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.globl<span class="Apple-tab-span" style="white-space:pre"> </span>$s4main3rads5UInt8Vvp</div><div class="">$s4main3rads5UInt8Vvp:</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.zero<span class="Apple-tab-span" style="white-space:pre"> </span>1</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.size<span class="Apple-tab-span" style="white-space:pre"> </span>$s4main3rads5UInt8Vvp, 1</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.hidden<span class="Apple-tab-span" style="white-space:pre"> </span>$s4main3angs6UInt16Vvp ; @"$s4main3angs6UInt16Vvp"</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.type<span class="Apple-tab-span" style="white-space:pre"> </span>$s4main3angs6UInt16Vvp,@object</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.globl<span class="Apple-tab-span" style="white-space:pre"> </span>$s4main3angs6UInt16Vvp</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.p2align<span class="Apple-tab-span" style="white-space:pre"> </span>1</div><div class="">$s4main3angs6UInt16Vvp:</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.zero<span class="Apple-tab-span" style="white-space:pre"> </span>2</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.size<span class="Apple-tab-span" style="white-space:pre"> </span>$s4main3angs6UInt16Vvp, 2</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.hidden<span class="Apple-tab-span" style="white-space:pre"> </span>__swift_reflection_version ; @__swift_reflection_version</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.type<span class="Apple-tab-span" style="white-space:pre"> </span>__swift_reflection_version,@object</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.section<span class="Apple-tab-span" style="white-space:pre"> </span>.rodata,"a",@progbits</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.weak<span class="Apple-tab-span" style="white-space:pre"> </span>__swift_reflection_version</div><div class="">__swift_reflection_version:</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.short<span class="Apple-tab-span" style="white-space:pre"> </span>3 ; 0x3</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.size<span class="Apple-tab-span" style="white-space:pre"> </span>__swift_reflection_version, 2</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.type<span class="Apple-tab-span" style="white-space:pre"> </span>_swift1_autolink_entries,@object ; @_swift1_autolink_entries</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.section<span class="Apple-tab-span" style="white-space:pre"> </span>.swift1_autolink_entries,"a",@progbits</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.p2align<span class="Apple-tab-span" style="white-space:pre"> </span>1</div><div class="">_swift1_autolink_entries:</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.asciz<span class="Apple-tab-span" style="white-space:pre"> </span>"-lavr"</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.size<span class="Apple-tab-span" style="white-space:pre"> </span>_swift1_autolink_entries, 6</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>; Declaring this symbol tells the CRT that it should</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>;copy all variables from program memory to RAM on startup</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.globl<span class="Apple-tab-span" style="white-space:pre"> </span>__do_copy_data</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>; Declaring this symbol tells the CRT that it should</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>;clear the zeroed data section on startup</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.globl<span class="Apple-tab-span" style="white-space:pre"> </span>__do_clear_bss</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">…which gcc 7.3.0 cannot compile, giving errors like…</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">main.s: Assembler messages:</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">main.s:12: Error: missing ')'</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">main.s:12: Error: missing operand</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">main.s:12: Error: unknown opcode `s3avr14slo'</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">main.s:13: Error: missing ')'</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">main.s:13: Error: missing operand</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">main.s:13: Error: unknown opcode `s3avr7sran'</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">main.s:16: Error: missing ')'</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">main.s:16: Error: missing operand</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">main.s:16: Error: unknown opcode `s3avr11set'</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">I think the identifiers in the LLVM IR are getting garbled? </span></div><div class=""><br class=""></div><div class="">I was expecting assembly code like…</div><div class=""><br class=""></div><div class="">call<span class="Apple-tab-span" style="white-space: pre;"> </span>"$s3AVR4wait2msys6UInt16V_tF"</div><div class=""><br class=""></div><div class="">and</div><div class=""><br class=""></div><div class=""><div class="">"$s4main3rads5UInt8Vvp":</div><div class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>.zero<span class="Apple-tab-span" style="white-space: pre;"> </span>1</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Is this a bug in the AVR back end or is LLVM llc supposed to do this?</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Thanks for any advice/help you guys can give.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Carl</div></body></html>