Fix windows bot breakages due to D143110
authorMircea Trofin <mtrofin@google.com>
Thu, 2 Feb 2023 00:27:44 +0000 (16:27 -0800)
committerMircea Trofin <mtrofin@google.com>
Thu, 2 Feb 2023 00:27:44 +0000 (16:27 -0800)
llvm/include/llvm/Analysis/InteractiveModelRunner.h
llvm/lib/Analysis/InteractiveModelRunner.cpp
llvm/unittests/Analysis/MLModelRunnerTest.cpp

index ffcd4a3..efec9d0 100644 (file)
@@ -61,7 +61,7 @@ private:
   const TensorSpec OutputSpec;
   std::error_code OutEC;
   std::error_code InEC;
-  sys::fs::file_t Inbound;
+  int Inbound = 0;
   std::vector<char> OutputBuffer;
   std::unique_ptr<Logger> Log;
 };
index c449ab4..2e9a906 100644 (file)
@@ -59,7 +59,8 @@ InteractiveModelRunner::InteractiveModelRunner(
 }
 
 InteractiveModelRunner::~InteractiveModelRunner() {
-  sys::fs::closeFile(Inbound);
+  sys::fs::file_t FDAsOSHandle = sys::fs::convertFDToNativeFile(Inbound);
+  sys::fs::closeFile(FDAsOSHandle);
 }
 
 void *InteractiveModelRunner::evaluateUntyped() {
@@ -74,7 +75,8 @@ void *InteractiveModelRunner::evaluateUntyped() {
   const size_t Limit = OutputBuffer.size();
   while (InsPoint < Limit) {
     auto ReadOrErr = ::sys::fs::readNativeFile(
-        Inbound, {Buff + InsPoint, OutputBuffer.size() - InsPoint});
+        sys::fs::convertFDToNativeFile(Inbound),
+        {Buff + InsPoint, OutputBuffer.size() - InsPoint});
     if (ReadOrErr.takeError()) {
       Ctx.emitError("Failed reading from inbound file");
       break;
index f953c45..007a8cf 100644 (file)
@@ -167,8 +167,11 @@ TEST(InteractiveModelRunner, Evaluation) {
     // host to open the pipes RW.
     raw_fd_ostream ToCompiler(ToCompilerName, EC);
     EXPECT_FALSE(EC);
-    sys::fs::file_t FromCompiler = {};
-    EXPECT_FALSE(sys::fs::openFileForRead(FromCompilerName, FromCompiler));
+    int FromCompilerHandle = 0;
+    EXPECT_FALSE(
+        sys::fs::openFileForRead(FromCompilerName, FromCompilerHandle));
+    sys::fs::file_t FromCompiler =
+        sys::fs::convertFDToNativeFile(FromCompilerHandle);
     EXPECT_EQ(SeenObservations, 0);
     // Helper to read headers and other json lines.
     SmallVector<char, 1024> Buffer;