mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-28 06:00:28 +00:00
[ARM] Fix several state persistence bugs
Summary: This fixes three bugs, in all of which state is not or incorrecly reset between objects (i.e. when reusing the same pass manager to create multiple object files): 1) AttributeSection needs to be reset to nullptr, because otherwise the backend will try to emit into the old object file's attribute section causing a segmentation fault. 2) MappingSymbolCounter needs to be reset, otherwise the second object file will start where the first one left off. 3) The MCStreamer base class resets the Streamer's e_flags settings. Since EF_ARM_EABI_VER5 is set on streamer creation, we need to set it again after the MCStreamer was rest. Also rename Reset (uppser case) to EHReset to avoid confusion with reset (lower case). Reviewers: rengolin Differential Revision: http://reviews.llvm.org/D15950 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257473 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a20f3c90ff
commit
7125c9519f
@ -131,6 +131,10 @@ public:
|
||||
|
||||
void finish() override;
|
||||
|
||||
/// Reset any state between object emissions, i.e. the equivalent of
|
||||
/// MCStreamer's reset method.
|
||||
virtual void reset();
|
||||
|
||||
/// Callback used to implement the ldr= pseudo.
|
||||
/// Add a new entry to the constant pool for the current section and return an
|
||||
/// MCExpr that can be used to refer to the constant pool location.
|
||||
|
@ -388,6 +388,9 @@ private:
|
||||
|
||||
size_t calculateContentSize() const;
|
||||
|
||||
// Reset state between object emissions
|
||||
void reset() override;
|
||||
|
||||
public:
|
||||
ARMTargetELFStreamer(MCStreamer &S)
|
||||
: ARMTargetStreamer(S), CurrentVendor("aeabi"), FPU(ARM::FK_INVALID),
|
||||
@ -415,7 +418,7 @@ public:
|
||||
MCCodeEmitter *Emitter, bool IsThumb)
|
||||
: MCELFStreamer(Context, TAB, OS, Emitter), IsThumb(IsThumb),
|
||||
MappingSymbolCounter(0), LastEMS(EMS_None) {
|
||||
Reset();
|
||||
EHReset();
|
||||
}
|
||||
|
||||
~ARMELFStreamer() {}
|
||||
@ -579,7 +582,10 @@ private:
|
||||
}
|
||||
|
||||
// Helper functions for ARM exception handling directives
|
||||
void Reset();
|
||||
void EHReset();
|
||||
|
||||
// Reset state between object emissions
|
||||
void reset() override;
|
||||
|
||||
void EmitPersonalityFixup(StringRef Name);
|
||||
void FlushPendingOffset();
|
||||
@ -1040,6 +1046,8 @@ void ARMTargetELFStreamer::emitInst(uint32_t Inst, char Suffix) {
|
||||
getStreamer().emitInst(Inst, Suffix);
|
||||
}
|
||||
|
||||
void ARMTargetELFStreamer::reset() { AttributeSection = nullptr; }
|
||||
|
||||
void ARMELFStreamer::FinishImpl() {
|
||||
MCTargetStreamer &TS = *getTargetStreamer();
|
||||
ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
|
||||
@ -1048,6 +1056,18 @@ void ARMELFStreamer::FinishImpl() {
|
||||
MCELFStreamer::FinishImpl();
|
||||
}
|
||||
|
||||
void ARMELFStreamer::reset() {
|
||||
MCTargetStreamer &TS = *getTargetStreamer();
|
||||
ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
|
||||
ATS.reset();
|
||||
MappingSymbolCounter = 0;
|
||||
MCELFStreamer::reset();
|
||||
// MCELFStreamer clear's the assembler's e_flags. However, for
|
||||
// arm we manually set the ABI version on streamer creation, so
|
||||
// do the same here
|
||||
getAssembler().setELFHeaderEFlags(ELF::EF_ARM_EABI_VER5);
|
||||
}
|
||||
|
||||
inline void ARMELFStreamer::SwitchToEHSection(const char *Prefix,
|
||||
unsigned Type,
|
||||
unsigned Flags,
|
||||
@ -1094,7 +1114,7 @@ void ARMELFStreamer::EmitFixup(const MCExpr *Expr, MCFixupKind Kind) {
|
||||
Kind));
|
||||
}
|
||||
|
||||
void ARMELFStreamer::Reset() {
|
||||
void ARMELFStreamer::EHReset() {
|
||||
ExTab = nullptr;
|
||||
FnStart = nullptr;
|
||||
Personality = nullptr;
|
||||
@ -1164,7 +1184,7 @@ void ARMELFStreamer::emitFnEnd() {
|
||||
SwitchSection(&FnStart->getSection());
|
||||
|
||||
// Clean exception handling frame information
|
||||
Reset();
|
||||
EHReset();
|
||||
}
|
||||
|
||||
void ARMELFStreamer::emitCantUnwind() { CantUnwind = true; }
|
||||
|
@ -38,6 +38,9 @@ void ARMTargetStreamer::emitCurrentConstantPool() {
|
||||
// finish() - write out any non-empty assembler constant pools.
|
||||
void ARMTargetStreamer::finish() { ConstantPools->emitAll(Streamer); }
|
||||
|
||||
// reset() - Reset any state
|
||||
void ARMTargetStreamer::reset() {}
|
||||
|
||||
// The remaining callbacks should be handled separately by each
|
||||
// streamer.
|
||||
void ARMTargetStreamer::emitFnStart() {}
|
||||
|
9
test/MC/ARM/twice.ll
Normal file
9
test/MC/ARM/twice.ll
Normal file
@ -0,0 +1,9 @@
|
||||
; Check for state persistence bugs in the ARM 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 %s -o -
|
||||
|
||||
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
|
||||
target triple = "armv4t-unknown-linux-gnueabi"
|
Loading…
Reference in New Issue
Block a user