gollvm: sync with LLVM trunk at f36703ada3dc

Update to handle changes in various APIs, notably rename of sys::fs
flags.

Change-Id: Ibf45de6650715a4e36f9b22ad4679911de4b06a0
Reviewed-on: https://go-review.googlesource.com/c/gollvm/+/330609
Trust: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
diff --git a/driver/CompileGo.cpp b/driver/CompileGo.cpp
index 533a9d5..622a36b 100644
--- a/driver/CompileGo.cpp
+++ b/driver/CompileGo.cpp
@@ -251,7 +251,7 @@
 
   // Open output file.
   std::error_code EC;
-  sys::fs::OpenFlags OpenFlags = sys::fs::F_Text;
+  sys::fs::OpenFlags OpenFlags = sys::fs::OF_Text;
   auto FDOut = std::make_unique<ToolOutputFile>(asmOutFileName_, EC,
                                                 OpenFlags);
   if (EC) {
diff --git a/driver/IntegAssembler.cpp b/driver/IntegAssembler.cpp
index f6262c8..ee3253d 100644
--- a/driver/IntegAssembler.cpp
+++ b/driver/IntegAssembler.cpp
@@ -57,6 +57,7 @@
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/raw_ostream.h"
@@ -204,16 +205,25 @@
   // may be created with a combination of default and explicit settings.
   MAI->setCompressDebugSections(CompressDebugSections);
 
-  // FIXME: This is not pretty. MCContext has a ptr to MCObjectFileInfo and
-  // MCObjectFileInfo needs a MCContext reference in order to initialize itself.
-  std::unique_ptr<MCObjectFileInfo> MOFI(new MCObjectFileInfo());
+  // Build up the feature string from the target feature list.
+  std::string FS;
+  std::string CPU;
+  std::unique_ptr<MCStreamer> Str;
+  std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo());
+  std::unique_ptr<MCSubtargetInfo> STI(
+      TheTarget->createMCSubtargetInfo(Trip, CPU, FS));
 
-  MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &SrcMgr, &MCOptions);
+  MCContext Ctx(triple_, MAI.get(), MRI.get(), STI.get(), &SrcMgr, &MCOptions);
 
   bool PIC = (driver_.getPicLevel() != PICLevel::NotPIC);
-  MOFI->InitMCObjectFileInfo(triple_, PIC, Ctx);
   Ctx.setGenDwarfForAssembly(true);
 
+  // FIXME: This is not pretty. MCContext has a ptr to MCObjectFileInfo and
+  // MCObjectFileInfo needs a MCContext reference in order to initialize itself.
+  std::unique_ptr<MCObjectFileInfo> MOFI(
+      TheTarget->createMCObjectFileInfo(Ctx, PIC));
+  Ctx.setObjectFileInfo(MOFI.get());
+
   // Use current dir (llvm-goc does not yet support -fdebug-compilation-dir)
   SmallString<128> CWD;
   if (!sys::fs::current_path(CWD))
@@ -231,14 +241,6 @@
   // FIXME: incorporate version here?
   Ctx.setDwarfDebugProducer("llvm-goc");
 
-  // Build up the feature string from the target feature list.
-  std::string FS;
-  std::string CPU;
-  std::unique_ptr<MCStreamer> Str;
-  std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo());
-  std::unique_ptr<MCSubtargetInfo> STI(
-      TheTarget->createMCSubtargetInfo(Trip, CPU, FS));
-
   raw_pwrite_stream *Out = objout_.get();
   std::unique_ptr<buffer_ostream> BOS;
 
diff --git a/libgo/godumpspec/godumpspec.cpp b/libgo/godumpspec/godumpspec.cpp
index 58d7bb7..06682f9 100644
--- a/libgo/godumpspec/godumpspec.cpp
+++ b/libgo/godumpspec/godumpspec.cpp
@@ -31,6 +31,7 @@
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MemoryBuffer.h"
diff --git a/passes/GC.cpp b/passes/GC.cpp
index 9bdd602..3932bab 100644
--- a/passes/GC.cpp
+++ b/passes/GC.cpp
@@ -17,7 +17,7 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/CodeGen/GCMetadataPrinter.h"
-#include "llvm/CodeGen/GCStrategy.h"
+#include "llvm/IR/GCStrategy.h"
 #include "llvm/CodeGen/StackMaps.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/MC/MCContext.h"