From bb19ffb5d21b50e9314c2a4a31d95489ee7a5af2 Mon Sep 17 00:00:00 2001
From: Simon Schuster <git@rationality.eu>
Date: Mon, 10 Apr 2017 21:05:46 +0200
Subject: [PATCH] Fix compilation of synthetic basic blocks

The handling of synthetic basic blocks such as "entry" blocks was
changed between llvm 3.4 and llvm 3.8, which resulted in internal
assertions being triggered.
Checking for invalid values obviously helps...
---
 lib/Target/ARM/ARMExport.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/Target/ARM/ARMExport.cpp b/lib/Target/ARM/ARMExport.cpp
index 15063d59cec..14fa1ec88c1 100644
--- a/lib/Target/ARM/ARMExport.cpp
+++ b/lib/Target/ARM/ARMExport.cpp
@@ -161,7 +161,9 @@ namespace llvm {
 				exportInstruction(MF, I, &(*Ins), IsBundled);
 
 				DebugLoc dl = Ins->getDebugLoc();
-				B->setSrcLocOnce(dl, dl.getScope());
+				if (dl) {
+					B->setSrcLocOnce(dl, dl.getScope());
+				}
 
 				IsBundled = true;
 			}
-- 
GitLab