[PATCH] D125905: [RISCV] Fix state persistence bugs (PR55548)
Kito Cheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 26 01:09:09 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
kito-cheng marked an inline comment as done.
Closed by commit rGe45087fd53d5: [RISCV] Fix state persistence bugs (PR55548) (authored by kito-cheng).
Changed prior to commit:
https://reviews.llvm.org/D125905?vs=430874&id=432209#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125905/new/
https://reviews.llvm.org/D125905
Files:
llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.h
llvm/test/MC/RISCV/twice.ll
Index: llvm/test/MC/RISCV/twice.ll
===================================================================
--- /dev/null
+++ llvm/test/MC/RISCV/twice.ll
@@ -0,0 +1,17 @@
+; Check for state persistence bugs in the RISC-V MC backend
+; This should neither fail (in the comparison that the second object
+; is bit-identical to the first) nor crash. Either failure would most
+; likely indicate some state that is not properly reset in the
+; appropriate ::reset method.
+; RUN: llc -compile-twice -filetype=obj -mtriple=riscv64 %s -o - \
+; RUN: | llvm-objdump --section-headers - \
+; RUN: | FileCheck %s
+
+; CHECK: Sections:
+; CHECK-NEXT: Idx Name Size VMA Type
+; CHECK-NEXT: 0
+; CHECK-NEXT: 1 .strtab
+; CHECK-NEXT: 2 .text
+; CHECK-NEXT: 3 .note.GNU-stack
+; CHECK-NEXT: 4 .riscv.attributes
+; CHECK-NEXT: 5 .symtab
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.h
===================================================================
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.h
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.h
@@ -23,6 +23,7 @@
public:
RISCVTargetStreamer(MCStreamer &S);
void finish() override;
+ virtual void reset();
virtual void emitDirectiveOptionPush();
virtual void emitDirectiveOptionPop();
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
===================================================================
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
@@ -22,6 +22,7 @@
RISCVTargetStreamer::RISCVTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
void RISCVTargetStreamer::finish() { finishAttributeSection(); }
+void RISCVTargetStreamer::reset() {}
void RISCVTargetStreamer::emitDirectiveOptionPush() {}
void RISCVTargetStreamer::emitDirectiveOptionPop() {}
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
===================================================================
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
@@ -92,6 +92,8 @@
void finishAttributeSection() override;
size_t calculateContentSize() const;
+ void reset() override;
+
public:
MCELFStreamer &getStreamer();
RISCVTargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI);
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
===================================================================
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
@@ -180,6 +180,11 @@
MCA.setELFHeaderEFlags(EFlags);
}
+void RISCVTargetELFStreamer::reset() {
+ AttributeSection = nullptr;
+ Contents.clear();
+}
+
namespace {
class RISCVELFStreamer : public MCELFStreamer {
static std::pair<unsigned, unsigned> getRelocPairForSize(unsigned Size) {
@@ -226,6 +231,13 @@
: !B.getName().empty());
}
+ void reset() override {
+ MCTargetStreamer &TS = *getTargetStreamer();
+ RISCVTargetStreamer &RTS = static_cast<RISCVTargetStreamer &>(TS);
+ RTS.reset();
+ MCELFStreamer::reset();
+ }
+
public:
RISCVELFStreamer(MCContext &C, std::unique_ptr<MCAsmBackend> MAB,
std::unique_ptr<MCObjectWriter> MOW,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125905.432209.patch
Type: text/x-patch
Size: 3360 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220526/d016dcf7/attachment.bin>
More information about the llvm-commits
mailing list