Skip to content

Commit 0d37b66

Browse files
jansvoboda11ronlieb
andcommitted
[clang] Invert condition refactored in llvm#160935 (llvm#161583)
The PR llvm#160935 incorrectly replaced `llvm::sys::fs::getUniqueID()` with `llvm::vfs::FileSystem::exists()` in a condition. That's incorrect, since the first function returns `std::error_code` that evaluates to `true` when there is an error (file doesn't exist), while the new code does the opposite. This PR fixes that issue by inverting the conditional. Co-authored-by: ronlieb <ron.lieberman@amd.com>
1 parent 8f6ed3a commit 0d37b66

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,7 @@ static llvm::TargetRegionEntryInfo getEntryInfoFromPresumedLoc(
15391539
SourceManager &SM = CGM.getContext().getSourceManager();
15401540
PresumedLoc PLoc = SM.getPresumedLoc(BeginLoc);
15411541

1542-
if (CGM.getFileSystem()->exists(PLoc.getFilename()))
1542+
if (!CGM.getFileSystem()->exists(PLoc.getFilename()))
15431543
PLoc = SM.getPresumedLoc(BeginLoc, /*UseLineDirectives=*/false);
15441544

15451545
return std::pair<std::string, uint64_t>(PLoc.getFilename(), PLoc.getLine());
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
// REQUIRES: amdgpu-registered-target
3+
4+
// RUN: %clang_cc1 -E -fopenmp -x c -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -save-temps=cwd %s -o %t-openmp-amdgcn-amd-amdhsa-gfx90a.i
5+
// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -save-temps=cwd -emit-llvm-bc %s -o %t-x86_64-unknown-unknown.bc
6+
// RUN: %clang_cc1 -fopenmp -x c -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -save-temps=cwd -emit-llvm -fopenmp-is-target-device -x cpp-output %t-openmp-amdgcn-amd-amdhsa-gfx90a.i -fopenmp-host-ir-file-path %t-x86_64-unknown-unknown.bc -o - | FileCheck %s
7+
// expected-no-diagnostics
8+
#ifndef HEADER
9+
#define HEADER
10+
11+
#define N 1000
12+
13+
int test_amdgcn_save_temps() {
14+
int arr[N];
15+
#pragma omp target
16+
for (int i = 0; i < N; i++) {
17+
arr[i] = 1;
18+
}
19+
return arr[0];
20+
}
21+
#endif
22+
23+
// CHECK: define {{[^@]+}}@{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_test_amdgcn_save_temps

0 commit comments

Comments
 (0)