diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -1567,26 +1567,6 @@
   return success();
 }
 
-static bool getTargetEntryUniqueInfo(llvm::TargetRegionEntryInfo &targetInfo,
-                                     omp::TargetOp targetOp,
-                                     llvm::StringRef parentName = "") {
-  auto fileLoc = targetOp.getLoc()->findInstanceOf<FileLineColLoc>();
-
-  assert(fileLoc && "No file found from location");
-  StringRef fileName = fileLoc.getFilename().getValue();
-
-  llvm::sys::fs::UniqueID id;
-  if (auto ec = llvm::sys::fs::getUniqueID(fileName, id)) {
-    targetOp.emitError("Unable to get unique ID for file");
-    return false;
-  }
-
-  uint64_t line = fileLoc.getLine();
-  targetInfo = llvm::TargetRegionEntryInfo(parentName, id.getDevice(),
-                                           id.getFile(), line);
-  return true;
-}
-
 static bool targetOpSupported(Operation &opInst) {
   auto targetOp = cast<omp::TargetOp>(opInst);
   if (targetOp.getIfExpr()) {
@@ -1643,11 +1623,27 @@
   };
 
   llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
-  StringRef parentName = opInst.getParentOfType<LLVM::LLVMFuncOp>().getName();
-  llvm::TargetRegionEntryInfo entryInfo;
 
-  if (!getTargetEntryUniqueInfo(entryInfo, targetOp, parentName))
-    return failure();
+  auto fileInfoCallBack = [&]() {
+    auto loc = opInst.getParentOfType<LLVM::LLVMFuncOp>()
+                   ->getLoc()
+                   ->findInstanceOf<FileLineColLoc>();
+    llvm::StringRef filename = loc.getFilename();
+    // handle split file from mlir-translate that for some reason
+    // manipulates the string to contain other components than
+    // filename
+    if (filename.contains("within split at")) {
+      filename.consume_front("within split at ");
+      filename = filename.rsplit(":").first;
+    }
+
+    return std::pair<std::string, uint64_t>(filename, loc.getLine());
+  };
+
+  llvm::TargetRegionEntryInfo entryInfo =
+      moduleTranslation.getOpenMPBuilder()->getTargetEntryUniqueInfo(
+          fileInfoCallBack,
+          opInst.getParentOfType<LLVM::LLVMFuncOp>().getName());
 
   int32_t defaultValTeams = -1;
   int32_t defaultValThreads = -1;