aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/AsmParser/llvmAsmParser.y6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index d7c1723b69..440056de2d 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -383,6 +383,12 @@ static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
ThrowException("Redefinition of label " + ID.getName());
ID.destroy(); // Free strdup'd memory.
+
+ // Make sure to move the basic block to the correct location in the
+ // function, instead of leaving it inserted wherever it was first
+ // referenced.
+ CurFun.CurrentFunction->getBasicBlockList().remove(BB);
+ CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
return BB;
}