[llvm-commits] [llvm] r132084 - in /llvm/trunk: include/llvm/MC/MCStreamer.h lib/MC/MCAsmStreamer.cpp lib/MC/MCParser/COFFAsmParser.cpp test/MC/AsmParser/directive_seh.s
Charles Davis
cdavis at mines.edu
Wed May 25 14:43:45 PDT 2011
Author: cdavis
Date: Wed May 25 16:43:45 2011
New Revision: 132084
URL: http://llvm.org/viewvc/llvm-project?rev=132084&view=rev
Log:
Add tests for .seh_setframe and .seh_handlerdata parsing. Fix issues with
them.
I had to add a special SwitchSectionNoChange method to MCStreamer just for
.seh_handlerdata. If this isn't OK, please let me know, and I'll find some
other way to fix .seh_handlerdata streaming.
Modified:
llvm/trunk/include/llvm/MC/MCStreamer.h
llvm/trunk/lib/MC/MCAsmStreamer.cpp
llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp
llvm/trunk/test/MC/AsmParser/directive_seh.s
Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=132084&r1=132083&r2=132084&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Wed May 25 16:43:45 2011
@@ -195,6 +195,17 @@
}
}
+ /// SwitchSectionNoChange - Set the current section where code is being
+ /// emitted to @p Section. This is required to update CurSection. This
+ /// version does not call ChangeSection.
+ void SwitchSectionNoChange(const MCSection *Section) {
+ assert(Section && "Cannot switch to a null section!");
+ const MCSection *curSection = SectionStack.back().first;
+ SectionStack.back().second = curSection;
+ if (Section != curSection)
+ SectionStack.back().first = Section;
+ }
+
/// InitSections - Create the default sections and set the initial one.
virtual void InitSections() = 0;
Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=132084&r1=132083&r2=132084&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Wed May 25 16:43:45 2011
@@ -973,6 +973,15 @@
void MCAsmStreamer::EmitWin64EHHandlerData() {
MCStreamer::EmitWin64EHHandlerData();
+ // Switch sections. Don't call SwitchSection directly, because that will
+ // cause the section switch to be visible in the emitted assembly.
+ // We only do this so the section switch that terminates the handler
+ // data block is visible.
+ const MCSection *xdataSect =
+ getContext().getTargetAsmInfo().getWin64EHTableSection();
+ if (xdataSect)
+ SwitchSectionNoChange(xdataSect);
+
OS << "\t.seh_handlerdata";
EmitEOL();
}
Modified: llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp?rev=132084&r1=132083&r2=132084&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp Wed May 25 16:43:45 2011
@@ -266,6 +266,10 @@
int64_t Off;
if (ParseSEHRegisterNumber(Reg))
return true;
+ if (getLexer().isNot(AsmToken::Comma))
+ return TokError("you must specify a stack pointer offset");
+
+ Lex();
SMLoc startLoc = getLexer().getLoc();
if (getParser().ParseAbsoluteExpression(Off))
return true;
@@ -304,7 +308,7 @@
if (ParseSEHRegisterNumber(Reg))
return true;
if (getLexer().isNot(AsmToken::Comma))
- return TokError("expected comma");
+ return TokError("you must specify an offset on the stack");
Lex();
SMLoc startLoc = getLexer().getLoc();
@@ -331,7 +335,7 @@
if (ParseSEHRegisterNumber(Reg))
return true;
if (getLexer().isNot(AsmToken::Comma))
- return TokError("expected comma");
+ return TokError("you must specify an offset on the stack");
Lex();
SMLoc startLoc = getLexer().getLoc();
Modified: llvm/trunk/test/MC/AsmParser/directive_seh.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_seh.s?rev=132084&r1=132083&r2=132084&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_seh.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_seh.s Wed May 25 16:43:45 2011
@@ -5,8 +5,13 @@
# CHECK: .seh_stackalloc 24
# CHECK: .seh_savereg 6, 16
# CHECK: .seh_savexmm 8, 0
+# CHECK: .seh_pushreg 3
+# CHECK: .seh_setframe 3, 0
# CHECK: .seh_endprologue
# CHECK: .seh_handler __C_specific_handler, @except
+# CHECK-NOT: .section{{.*}}.xdata
+# CHECK: .seh_handlerdata
+# CHECK: .text
# CHECK: .seh_endproc
.text
@@ -21,8 +26,17 @@
.seh_savereg %rsi, 16
movups %xmm8, (%rsp)
.seh_savexmm %xmm8, 0
+ pushq %rbx
+ .seh_pushreg 3
+ mov %rsp, %rbx
+ .seh_setframe 3, 0
.seh_endprologue
.seh_handler __C_specific_handler, @except
+ .seh_handlerdata
+ .long 0
+ .text
+ lea (%rbx), %rsp
+ pop %rbx
addq $24, %rsp
ret
.seh_endproc
More information about the llvm-commits
mailing list