[llvm-branch-commits] [llvm-branch] r347023 - Merging r344516:

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Nov 15 20:22:24 PST 2018


Author: tstellar
Date: Thu Nov 15 20:22:24 2018
New Revision: 347023

URL: http://llvm.org/viewvc/llvm-project?rev=347023&view=rev
Log:
Merging r344516:

------------------------------------------------------------------------
r344516 | abeserminji | 2018-10-15 07:39:12 -0700 (Mon, 15 Oct 2018) | 12 lines

[mips][micromips] Fix overlaping FDEs error

When compiling static executable for micromips, CFI symbols
are incorrectly labeled as MICROMIPS, which cause
".eh_frame_hdr refers to overlapping FDEs." error.

This patch does not label CFI symbols as MICROMIPS, and FDEs do not
overlap anymore. This patch also exposes another bug, which is fixed
here: https://reviews.llvm.org/D52985

Differential Revision: https://reviews.llvm.org/D52987

------------------------------------------------------------------------

Added:
    llvm/branches/release_70/test/DebugInfo/Mips/eh_frame.ll
Modified:
    llvm/branches/release_70/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp
    llvm/branches/release_70/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h

Modified: llvm/branches/release_70/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_70/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp?rev=347023&r1=347022&r2=347023&view=diff
==============================================================================
--- llvm/branches/release_70/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp (original)
+++ llvm/branches/release_70/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp Thu Nov 15 20:22:24 2018
@@ -15,6 +15,7 @@
 #include "llvm/MC/MCAssembler.h"
 #include "llvm/MC/MCCodeEmitter.h"
 #include "llvm/MC/MCContext.h"
+#include "llvm/MC/MCDwarf.h"
 #include "llvm/MC/MCInst.h"
 #include "llvm/MC/MCObjectWriter.h"
 #include "llvm/MC/MCSymbolELF.h"
@@ -53,6 +54,22 @@ void MipsELFStreamer::EmitInstruction(co
   createPendingLabelRelocs();
 }
 
+void MipsELFStreamer::EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) {
+  Frame.Begin = getContext().createTempSymbol();
+  MCELFStreamer::EmitLabel(Frame.Begin);
+}
+
+MCSymbol *MipsELFStreamer::EmitCFILabel() {
+  MCSymbol *Label = getContext().createTempSymbol("cfi", true);
+  MCELFStreamer::EmitLabel(Label);
+  return Label;
+}
+
+void MipsELFStreamer::EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) {
+  Frame.End = getContext().createTempSymbol();
+  MCELFStreamer::EmitLabel(Frame.End);
+}
+
 void MipsELFStreamer::createPendingLabelRelocs() {
   MipsTargetELFStreamer *ELFTargetStreamer =
       static_cast<MipsTargetELFStreamer *>(getTargetStreamer());

Modified: llvm/branches/release_70/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_70/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h?rev=347023&r1=347022&r2=347023&view=diff
==============================================================================
--- llvm/branches/release_70/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h (original)
+++ llvm/branches/release_70/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h Thu Nov 15 20:22:24 2018
@@ -26,6 +26,7 @@ class MCAsmBackend;
 class MCCodeEmitter;
 class MCContext;
 class MCSubtargetInfo;
+struct MCDwarfFrameInfo;
 
 class MipsELFStreamer : public MCELFStreamer {
   SmallVector<std::unique_ptr<MipsOptionRecord>, 8> MipsOptionRecords;
@@ -60,6 +61,12 @@ public:
   void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override;
   void EmitIntValue(uint64_t Value, unsigned Size) override;
 
+  // Overriding these functions allows us to avoid recording of these labels
+  // in EmitLabel and later marking them as microMIPS.
+  void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override;
+  void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override;
+  MCSymbol *EmitCFILabel() override;
+
   /// Emits all the option records stored up until the point it's called.
   void EmitMipsOptionRecords();
 

Added: llvm/branches/release_70/test/DebugInfo/Mips/eh_frame.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_70/test/DebugInfo/Mips/eh_frame.ll?rev=347023&view=auto
==============================================================================
--- llvm/branches/release_70/test/DebugInfo/Mips/eh_frame.ll (added)
+++ llvm/branches/release_70/test/DebugInfo/Mips/eh_frame.ll Thu Nov 15 20:22:24 2018
@@ -0,0 +1,38 @@
+; RUN: llc -mtriple mips-unknown-linux-gnu -mattr=+micromips -O3 -filetype=obj -o - %s | llvm-readelf -r | FileCheck %s
+
+; CHECK: .rel.eh_frame
+; CHECK: DW.ref.__gxx_personality_v0
+; CHECK-NEXT: .text
+; CHECK-NEXT: .gcc_except_table
+
+ at _ZTIi = external constant i8*
+
+define dso_local i32 @main() local_unnamed_addr personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+entry:
+  %exception.i = tail call i8* @__cxa_allocate_exception(i32 4) nounwind
+  %0 = bitcast i8* %exception.i to i32*
+  store i32 5, i32* %0, align 16
+  invoke void @__cxa_throw(i8* %exception.i, i8* bitcast (i8** @_ZTIi to i8*), i8* null) noreturn
+          to label %.noexc unwind label %return
+
+.noexc:
+  unreachable
+
+return:
+  %1 = landingpad { i8*, i32 }
+          catch i8* null
+  %2 = extractvalue { i8*, i32 } %1, 0
+  %3 = tail call i8* @__cxa_begin_catch(i8* %2) nounwind
+  tail call void @__cxa_end_catch()
+  ret i32 0
+}
+
+declare i32 @__gxx_personality_v0(...)
+
+declare i8* @__cxa_begin_catch(i8*) local_unnamed_addr
+
+declare void @__cxa_end_catch() local_unnamed_addr
+
+declare i8* @__cxa_allocate_exception(i32) local_unnamed_addr
+
+declare void @__cxa_throw(i8*, i8*, i8*) local_unnamed_addr




More information about the llvm-branch-commits mailing list