Skip to content

[flang][OpenMP] Fix missing missing inode issue #130798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions flang/test/Lower/OpenMP/missing-inode.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
! RUN: %flang_fc1 -emit-llvm -fopenmp -fopenmp-version=51 -fopenmp-targets=amdgcn-amd-amdhsa -o - %s | FileCheck %s
program missing_inode
#line "/this_path_should_not_exist_on_any_system_out_there/and_if_it_does_it_will_break_the/tes.f90" 700
! CHECK: define internal void @__omp_offloading_{{[0-9a-f]+}}_{{[0-9a-f]+}}__QQmain_l701
!$omp target
call some_routine()
!$omp end target
end program missing_inode
20 changes: 10 additions & 10 deletions mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4284,7 +4284,7 @@ LogicalResult convertFlagsAttr(Operation *op, mlir::omp::FlagsAttr attribute,
return success();
}

static bool getTargetEntryUniqueInfo(llvm::TargetRegionEntryInfo &targetInfo,
static void getTargetEntryUniqueInfo(llvm::TargetRegionEntryInfo &targetInfo,
omp::TargetOp targetOp,
llvm::StringRef parentName = "") {
auto fileLoc = targetOp.getLoc()->findInstanceOf<FileLineColLoc>();
Expand All @@ -4293,15 +4293,16 @@ static bool getTargetEntryUniqueInfo(llvm::TargetRegionEntryInfo &targetInfo,
StringRef fileName = fileLoc.getFilename().getValue();

llvm::sys::fs::UniqueID id;
uint64_t line = fileLoc.getLine();
if (auto ec = llvm::sys::fs::getUniqueID(fileName, id)) {
targetOp.emitError("Unable to get unique ID for file");
return false;
size_t fileHash = llvm::hash_value(fileName.str());
size_t deviceId = 0xdeadf17e;
targetInfo =
llvm::TargetRegionEntryInfo(parentName, deviceId, fileHash, line);
} else {
targetInfo = llvm::TargetRegionEntryInfo(parentName, id.getDevice(),
id.getFile(), line);
}

uint64_t line = fileLoc.getLine();
targetInfo = llvm::TargetRegionEntryInfo(parentName, id.getDevice(),
id.getFile(), line);
return true;
}

static void
Expand Down Expand Up @@ -4901,8 +4902,7 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,

llvm::TargetRegionEntryInfo entryInfo;

if (!getTargetEntryUniqueInfo(entryInfo, targetOp, parentName))
return failure();
getTargetEntryUniqueInfo(entryInfo, targetOp, parentName);

MapInfoData mapData;
collectMapDataFromMapOperands(mapData, mapVars, moduleTranslation, dl,
Expand Down