From ca93138e11f404a19553049a569f1fa6ad491b67 Mon Sep 17 00:00:00 2001 From: Charles Davis Date: Thu, 26 May 2011 02:45:47 +0000 Subject: [PATCH] Test .seh_startchained and .seh_endchained parsing. Rework how the MCWin64EHUnwindInfo instances are stored. Fix issues with chained unwind areas exposed by the test that were related to this. The ChainedParent field had the wrong address, because when the chained unwind info was added, the addresses shifted around. Now we store the pointers to the structures, which are now allocated from the MC heap. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132106 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCStreamer.h | 4 ++-- lib/MC/MCStreamer.cpp | 26 +++++++++++++------------- test/MC/AsmParser/directive_seh.s | 3 +++ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 9dd8d4b5335..c05a9251dc7 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -58,7 +58,7 @@ namespace llvm { MCDwarfFrameInfo *getCurrentFrameInfo(); void EnsureValidFrame(); - std::vector W64UnwindInfos; + std::vector W64UnwindInfos; MCWin64EHUnwindInfo *CurrentW64UnwindInfo; void setCurrentW64UnwindInfo(MCWin64EHUnwindInfo *Frame); void EnsureValidW64UnwindInfo(); @@ -101,7 +101,7 @@ namespace llvm { } MCWin64EHUnwindInfo &getW64UnwindInfo(unsigned i) { - return W64UnwindInfos[i]; + return *W64UnwindInfos[i]; } /// @name Assembly File Formatting. diff --git a/lib/MC/MCStreamer.cpp b/lib/MC/MCStreamer.cpp index 19aeaafc722..9957a76ba38 100644 --- a/lib/MC/MCStreamer.cpp +++ b/lib/MC/MCStreamer.cpp @@ -307,8 +307,8 @@ void MCStreamer::EmitCFISameValue(int64_t Register) { } void MCStreamer::setCurrentW64UnwindInfo(MCWin64EHUnwindInfo *Frame) { - W64UnwindInfos.push_back(*Frame); - CurrentW64UnwindInfo = &W64UnwindInfos.back(); + W64UnwindInfos.push_back(Frame); + CurrentW64UnwindInfo = W64UnwindInfos.back(); } void MCStreamer::EnsureValidW64UnwindInfo() { @@ -321,11 +321,11 @@ void MCStreamer::EmitWin64EHStartProc(const MCSymbol *Symbol) { MCWin64EHUnwindInfo *CurFrame = CurrentW64UnwindInfo; if (CurFrame && !CurFrame->End) report_fatal_error("Starting a function before ending the previous one!"); - MCWin64EHUnwindInfo Frame; - Frame.Begin = getContext().CreateTempSymbol(); - Frame.Function = Symbol; - EmitLabel(Frame.Begin); - setCurrentW64UnwindInfo(&Frame); + MCWin64EHUnwindInfo *Frame = new (getContext()) MCWin64EHUnwindInfo; + Frame->Begin = getContext().CreateTempSymbol(); + Frame->Function = Symbol; + EmitLabel(Frame->Begin); + setCurrentW64UnwindInfo(Frame); } void MCStreamer::EmitWin64EHEndProc() { @@ -339,13 +339,13 @@ void MCStreamer::EmitWin64EHEndProc() { void MCStreamer::EmitWin64EHStartChained() { EnsureValidW64UnwindInfo(); - MCWin64EHUnwindInfo Frame; + MCWin64EHUnwindInfo *Frame = new (getContext()) MCWin64EHUnwindInfo; MCWin64EHUnwindInfo *CurFrame = CurrentW64UnwindInfo; - Frame.Begin = getContext().CreateTempSymbol(); - Frame.Function = CurFrame->Function; - Frame.ChainedParent = CurFrame; - EmitLabel(Frame.Begin); - setCurrentW64UnwindInfo(&Frame); + Frame->Begin = getContext().CreateTempSymbol(); + Frame->Function = CurFrame->Function; + Frame->ChainedParent = CurFrame; + EmitLabel(Frame->Begin); + setCurrentW64UnwindInfo(Frame); } void MCStreamer::EmitWin64EHEndChained() { diff --git a/test/MC/AsmParser/directive_seh.s b/test/MC/AsmParser/directive_seh.s index d4f7625e885..b4384daf481 100644 --- a/test/MC/AsmParser/directive_seh.s +++ b/test/MC/AsmParser/directive_seh.s @@ -35,6 +35,9 @@ func: .seh_handlerdata .long 0 .text + .seh_startchained + .seh_endprologue + .seh_endchained lea (%rbx), %rsp pop %rbx addq $24, %rsp -- 2.34.1