[llvm-commits] [llvm] r131629 - in /llvm/trunk: include/llvm/MC/MCStreamer.h include/llvm/MC/MCWin64EH.h lib/MC/MCStreamer.cpp
Charles Davis
cdavis at mines.edu
Wed May 18 21:04:13 PDT 2011
Author: cdavis
Date: Wed May 18 23:04:13 2011
New Revision: 131629
URL: http://llvm.org/viewvc/llvm-project?rev=131629&view=rev
Log:
Implement the StartChained and EndChained Win64 EH methods on MCStreamer.
Modified:
llvm/trunk/include/llvm/MC/MCStreamer.h
llvm/trunk/include/llvm/MC/MCWin64EH.h
llvm/trunk/lib/MC/MCStreamer.cpp
Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=131629&r1=131628&r2=131629&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Wed May 18 23:04:13 2011
@@ -59,7 +59,8 @@
void EnsureValidFrame();
std::vector<MCWin64EHUnwindInfo> W64UnwindInfos;
- MCWin64EHUnwindInfo *getCurrentW64UnwindInfo();
+ MCWin64EHUnwindInfo *CurrentW64UnwindInfo;
+ void setCurrentW64UnwindInfo(MCWin64EHUnwindInfo *Frame);
void EnsureValidW64UnwindInfo();
const MCSymbol* LastNonPrivate;
Modified: llvm/trunk/include/llvm/MC/MCWin64EH.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCWin64EH.h?rev=131629&r1=131628&r2=131629&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCWin64EH.h (original)
+++ llvm/trunk/include/llvm/MC/MCWin64EH.h Wed May 18 23:04:13 2011
@@ -64,7 +64,7 @@
struct MCWin64EHUnwindInfo {
MCWin64EHUnwindInfo() : Begin(0), End(0), ExceptionHandler(0), Lsda(0),
Function(0), UnwindOnly(false), LsdaSize(0),
- PrologSize(0), LastFrameInst(-1), Chained(false),
+ PrologSize(0), LastFrameInst(-1), ChainedParent(0),
Instructions() {}
MCSymbol *Begin;
MCSymbol *End;
@@ -75,7 +75,7 @@
unsigned LsdaSize;
unsigned PrologSize;
int LastFrameInst;
- bool Chained;
+ MCWin64EHUnwindInfo *ChainedParent;
std::vector<MCWin64EHInstruction> Instructions;
};
Modified: llvm/trunk/lib/MC/MCStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=131629&r1=131628&r2=131629&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCStreamer.cpp Wed May 18 23:04:13 2011
@@ -310,20 +310,19 @@
CurFrame->Instructions.push_back(Instruction);
}
-MCWin64EHUnwindInfo *MCStreamer::getCurrentW64UnwindInfo() {
- if (W64UnwindInfos.empty())
- return NULL;
- return &W64UnwindInfos.back();
+void MCStreamer::setCurrentW64UnwindInfo(MCWin64EHUnwindInfo *Frame) {
+ W64UnwindInfos.push_back(*Frame);
+ CurrentW64UnwindInfo = &W64UnwindInfos.back();
}
void MCStreamer::EnsureValidW64UnwindInfo() {
- MCWin64EHUnwindInfo *CurFrame = getCurrentW64UnwindInfo();
+ MCWin64EHUnwindInfo *CurFrame = CurrentW64UnwindInfo;
if (!CurFrame || CurFrame->End)
report_fatal_error("No open Win64 EH frame function!");
}
void MCStreamer::EmitWin64EHStartProc(MCSymbol *Symbol, MCSymbol *EHandler) {
- MCWin64EHUnwindInfo *CurFrame = getCurrentW64UnwindInfo();
+ MCWin64EHUnwindInfo *CurFrame = CurrentW64UnwindInfo;
if (CurFrame && !CurFrame->End)
report_fatal_error("Starting a function before ending the previous one!");
MCWin64EHUnwindInfo Frame;
@@ -331,13 +330,13 @@
Frame.Function = Symbol;
Frame.ExceptionHandler = EHandler;
EmitLabel(Frame.Begin);
- W64UnwindInfos.push_back(Frame);
+ setCurrentW64UnwindInfo(&Frame);
}
void MCStreamer::EmitWin64EHEndProc() {
EnsureValidW64UnwindInfo();
- MCWin64EHUnwindInfo *CurFrame = getCurrentW64UnwindInfo();
- if (CurFrame->Chained)
+ MCWin64EHUnwindInfo *CurFrame = CurrentW64UnwindInfo;
+ if (CurFrame->ChainedParent)
report_fatal_error("Not all chained regions terminated!");
CurFrame->End = getContext().CreateTempSymbol();
EmitLabel(CurFrame->End);
@@ -345,14 +344,25 @@
void MCStreamer::EmitWin64EHStartChained()
{
- errs() << "Not implemented yet\n";
- abort();
+ EnsureValidW64UnwindInfo();
+ MCWin64EHUnwindInfo Frame;
+ MCWin64EHUnwindInfo *CurFrame = CurrentW64UnwindInfo;
+ Frame.Begin = getContext().CreateTempSymbol();
+ Frame.Function = CurFrame->Function;
+ Frame.ChainedParent = CurFrame;
+ EmitLabel(Frame.Begin);
+ setCurrentW64UnwindInfo(&Frame);
}
void MCStreamer::EmitWin64EHEndChained()
{
- errs() << "Not implemented yet\n";
- abort();
+ EnsureValidW64UnwindInfo();
+ MCWin64EHUnwindInfo *CurFrame = CurrentW64UnwindInfo;
+ if (!CurFrame->ChainedParent)
+ report_fatal_error("End of a chained region outside a chained region!");
+ CurFrame->End = getContext().CreateTempSymbol();
+ EmitLabel(CurFrame->End);
+ CurrentW64UnwindInfo = CurFrame->ChainedParent;
}
void MCStreamer::EmitWin64EHUnwindOnly()
More information about the llvm-commits
mailing list