[PATCH] D107133: [AVR] emit `MCSA_Global` references to `__do_global_ctors` and `__do_global_dtors`
Matt Jacobson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 3 22:24:48 PDT 2021
mhjacobson marked an inline comment as done.
mhjacobson added a comment.
@MaskRay, do you have an opinion on whether I should move the other undefined-symbols definitions into `AVRAsmPrinter.cpp` to match?
Specifically, something like this:
diff --git a/llvm/lib/Target/AVR/AVRAsmPrinter.cpp b/llvm/lib/Target/AVR/AVRAsmPrinter.cpp
index f76034e7f115..7b7ede62a00f 100644
--- a/llvm/lib/Target/AVR/AVRAsmPrinter.cpp
+++ b/llvm/lib/Target/AVR/AVRAsmPrinter.cpp
@@ -59,6 +59,8 @@ public:
void emitXXStructor(const DataLayout &DL, const Constant *CV) override;
+ bool doFinalization(Module &M) override;
+
private:
const MCRegisterInfo &MRI;
bool EmittedStructorSymbolAttrs = false;
@@ -217,6 +219,23 @@ void AVRAsmPrinter::emitXXStructor(const DataLayout &DL, const Constant *CV) {
AsmPrinter::emitXXStructor(DL, CV);
}
+bool AVRAsmPrinter::doFinalization(Module &M) {
+ MCSymbol *DoCopyData = OutContext.getOrCreateSymbol("__do_copy_data");
+ MCSymbol *DoClearBss = OutContext.getOrCreateSymbol("__do_clear_bss");
+
+ // FIXME: We can disable __do_copy_data if there are no static RAM variables.
+
+ OutStreamer->emitRawComment(" Declaring this symbol tells the CRT that it should");
+ OutStreamer->emitRawComment("copy all variables from program memory to RAM on startup");
+ OutStreamer->emitSymbolAttribute(DoCopyData, MCSA_Global);
+
+ OutStreamer->emitRawComment(" Declaring this symbol tells the CRT that it should");
+ OutStreamer->emitRawComment("clear the zeroed data section on startup");
+ OutStreamer->emitSymbolAttribute(DoClearBss, MCSA_Global);
+
+ return AsmPrinter::doFinalization(M);
+}
+
} // end of namespace llvm
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAVRAsmPrinter() {
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.cpp
index eccd343d79ab..56e0e7810466 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.cpp
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.cpp
@@ -21,23 +21,4 @@ AVRTargetStreamer::AVRTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
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
-
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.h b/llvm/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.h
index 5c4d1a22f6c6..b8b1454a2b8d 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.h
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.h
@@ -18,8 +18,6 @@ class MCStreamer;
class AVRTargetStreamer : public MCTargetStreamer {
public:
explicit AVRTargetStreamer(MCStreamer &S);
-
- void finish() override;
};
/// A target streamer for textual AVR assembly code.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D107133/new/
https://reviews.llvm.org/D107133
More information about the llvm-commits
mailing list