summaryrefslogtreecommitdiff
path: root/lib/MC
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2013-02-15 22:54:16 +0000
committerChad Rosier <mcrosier@apple.com>2013-02-15 22:54:16 +0000
commitb54562b96d407d007e9e6da3ddef09ac83e9776f (patch)
treeadf2f8b75010b832a4ba689698241d9e8ff4e8b8 /lib/MC
parent67144e37ba5cd35ee917daac631e03963b05a674 (diff)
c[ms-inline asm] It's possible to have a SizeDirective rewrite and an
Input/Output rewrite to the same location. Make sure the SizeDirective rewrite is performed first. This also ensure the sort algorithm is stable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175317 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r--lib/MC/MCParser/AsmParser.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp
index bfe36127334..b7953c1a597 100644
--- a/lib/MC/MCParser/AsmParser.cpp
+++ b/lib/MC/MCParser/AsmParser.cpp
@@ -4041,7 +4041,21 @@ static int RewritesSort(const void *A, const void *B) {
return -1;
if (AsmRewriteB->Loc.getPointer() < AsmRewriteA->Loc.getPointer())
return 1;
- return 0;
+
+ // It's possible to have a SizeDirective rewrite and an Input/Output rewrite
+ // to the same location. Make sure the SizeDirective rewrite is performed
+ // first. This also ensure the sort algorithm is stable.
+ if (AsmRewriteA->Kind == AOK_SizeDirective) {
+ assert ((AsmRewriteB->Kind == AOK_Input || AsmRewriteB->Kind == AOK_Output) &&
+ "Expected an Input/Output rewrite!");
+ return -1;
+ }
+ if (AsmRewriteB->Kind == AOK_SizeDirective) {
+ assert ((AsmRewriteA->Kind == AOK_Input || AsmRewriteA->Kind == AOK_Output) &&
+ "Expected an Input/Output rewrite!");
+ return 1;
+ }
+ llvm_unreachable ("Unstable rewrite sort.");
}
bool
@@ -4174,6 +4188,7 @@ AsmParser::ParseMSInlineAsm(void *AsmLoc, std::string &AsmString,
E = AsmStrRewrites.end();
I != E; ++I) {
const char *Loc = (*I).Loc.getPointer();
+ assert(Loc >= Start && "Expected Loc to be after Start!");
unsigned AdditionalSkip = 0;
AsmRewriteKind Kind = (*I).Kind;