Fix for bug 34002 - label generated before it block is finalized. Differential Revision: https://reviews.llvm.org/D52258

llvm-svn: 342615
This commit is contained in:
Maya Madhavan 2018-09-20 05:11:42 +00:00
parent 50da2c69d9
commit ac015cd2c1
4 changed files with 14 additions and 2 deletions

View File

@ -476,6 +476,9 @@ public:
return nullptr;
}
// For actions that have to be performed before a label is emitted
virtual void doBeforeLabelEmit(MCSymbol *Symbol) {}
virtual void onLabelParsed(MCSymbol *Symbol) {}
/// Ensure that all previously parsed instructions have been emitted to the

View File

@ -1808,6 +1808,8 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
Lex();
}
getTargetParser().doBeforeLabelEmit(Sym);
// Emit the label.
if (!getTargetParser().isParsingInlineAsm())
Out.EmitLabel(Sym, IDLoc);

View File

@ -631,6 +631,8 @@ public:
void ReportNearMisses(SmallVectorImpl<NearMissInfo> &NearMisses, SMLoc IDLoc,
OperandVector &Operands);
void doBeforeLabelEmit(MCSymbol *Symbol) override;
void onLabelParsed(MCSymbol *Symbol) override;
};
@ -9443,10 +9445,13 @@ bool ARMAsmParser::parseDirectiveARM(SMLoc L) {
return false;
}
void ARMAsmParser::onLabelParsed(MCSymbol *Symbol) {
void ARMAsmParser::doBeforeLabelEmit(MCSymbol *Symbol) {
// We need to flush the current implicit IT block on a label, because it is
// not legal to branch into an IT block.
flushPendingInstructions(getStreamer());
}
void ARMAsmParser::onLabelParsed(MCSymbol *Symbol) {
if (NextSymbolIsThumb) {
getParser().getStreamer().EmitThumbFunc(Symbol);
NextSymbolIsThumb = false;

View File

@ -73,12 +73,14 @@
addeq r0, #1
label:
addeq r0, #1
5:
five:
addeq r0, #1
@ CHECK: it eq
@ CHECK: addeq
@ CHECK: label
@ CHECK: it eq
@ CHECK: addeq
@ CHECK: five
@ CHECK: it eq
@ CHECK: addeq