[llvm-branch-commits] [llvm-branch] r314356 - Merging r312905:

Dylan McKay via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Sep 27 15:15:50 PDT 2017


Author: dylanmckay
Date: Wed Sep 27 15:15:50 2017
New Revision: 314356

URL: http://llvm.org/viewvc/llvm-project?rev=314356&view=rev
Log:
Merging r312905:
------------------------------------------------------------------------
r312905 | dylanmckay | 2017-09-11 22:32:51 +1200 (Mon, 11 Sep 2017) | 10 lines

[AVR] Enable the '__do_copy_data' function

Also enables '__do_clear_bss'.

These functions are automaticalled called by the CRT if they are
declared.

We need these to be called otherwise RAM will start completely
uninitialised, even though we need to copy RAM variables from progmem to
RAM.
------------------------------------------------------------------------

Added:
    llvm/branches/release_50/test/CodeGen/AVR/clear-bss.ll
    llvm/branches/release_50/test/CodeGen/AVR/copy-data-to-ram.ll
Modified:
    llvm/branches/release_50/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.cpp
    llvm/branches/release_50/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.h

Modified: llvm/branches/release_50/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_50/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.cpp?rev=314356&r1=314355&r2=314356&view=diff
==============================================================================
--- llvm/branches/release_50/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.cpp (original)
+++ llvm/branches/release_50/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.cpp Wed Sep 27 15:15:50 2017
@@ -13,6 +13,8 @@
 
 #include "AVRTargetStreamer.h"
 
+#include "llvm/MC/MCContext.h"
+
 namespace llvm {
 
 AVRTargetStreamer::AVRTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
@@ -20,5 +22,23 @@ AVRTargetStreamer::AVRTargetStreamer(MCS
 AVRTargetAsmStreamer::AVRTargetAsmStreamer(MCStreamer &S)
     : AVRTargetStreamer(S) {}
 
+void AVRTargetStreamer::finish() {
+  MCStreamer &OS = getStreamer();
+  MCContext &Context = OS.getContext();
+
+  MCSymbol *DoCopyData = Context.getOrCreateSymbol("__do_copy_data");
+  MCSymbol *DoClearBss = Context.getOrCreateSymbol("__do_clear_bss");
+
+  // FIXME: We can disable __do_copy_data if there are no static RAM variables.
+
+  OS.emitRawComment(" Declaring this symbol tells the CRT that it should");
+  OS.emitRawComment("copy all variables from program memory to RAM on startup");
+  OS.EmitSymbolAttribute(DoCopyData, MCSA_Global);
+
+  OS.emitRawComment(" Declaring this symbol tells the CRT that it should");
+  OS.emitRawComment("clear the zeroed data section on startup");
+  OS.EmitSymbolAttribute(DoClearBss, MCSA_Global);
+}
+
 } // end namespace llvm
 

Modified: llvm/branches/release_50/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_50/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.h?rev=314356&r1=314355&r2=314356&view=diff
==============================================================================
--- llvm/branches/release_50/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.h (original)
+++ llvm/branches/release_50/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.h Wed Sep 27 15:15:50 2017
@@ -19,6 +19,8 @@ class MCStreamer;
 class AVRTargetStreamer : public MCTargetStreamer {
 public:
   explicit AVRTargetStreamer(MCStreamer &S);
+
+  void finish() override;
 };
 
 /// A target streamer for textual AVR assembly code.

Added: llvm/branches/release_50/test/CodeGen/AVR/clear-bss.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_50/test/CodeGen/AVR/clear-bss.ll?rev=314356&view=auto
==============================================================================
--- llvm/branches/release_50/test/CodeGen/AVR/clear-bss.ll (added)
+++ llvm/branches/release_50/test/CodeGen/AVR/clear-bss.ll Wed Sep 27 15:15:50 2017
@@ -0,0 +1,5 @@
+; RUN: llc < %s -march=avr | FileCheck %s
+
+; CHECK: .globl __do_clear_bss
+ at zeroed = internal constant [3 x i8] zeroinitializer
+

Added: llvm/branches/release_50/test/CodeGen/AVR/copy-data-to-ram.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_50/test/CodeGen/AVR/copy-data-to-ram.ll?rev=314356&view=auto
==============================================================================
--- llvm/branches/release_50/test/CodeGen/AVR/copy-data-to-ram.ll (added)
+++ llvm/branches/release_50/test/CodeGen/AVR/copy-data-to-ram.ll Wed Sep 27 15:15:50 2017
@@ -0,0 +1,5 @@
+; RUN: llc < %s -march=avr | FileCheck %s
+
+; CHECK: .globl __do_copy_data
+ at str = internal global [3 x i8] c"foo"
+




More information about the llvm-branch-commits mailing list