Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
25 changes: 25 additions & 0 deletions flang/test/Lower/OpenMP/target-data-if-false.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
!RUN: %flang_fc1 -emit-llvm -fopenmp %openmp_flags -fopenmp-version=52 %s -o - | FileCheck %s

!Check that this doesn't crash.

!CHECK-LABEL: define void @f00_()
!CHECK: call i1 @_FortranAioOutputDerivedType

subroutine f00
use iso_c_binding
type(c_ptr) :: x

!$omp target data use_device_ptr(x) if(.false.)
print *, x
!$omp end target data
end

!CHECK-LABEL: define void @f01_()
!CHECK: call i1 @_FortranAioOutputInteger32
subroutine f01
integer :: x

!$omp target data use_device_addr(x) if(.false.)
print *, x
!$omp end target data
end
Original file line number Diff line number Diff line change
Expand Up @@ -4549,6 +4549,18 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
}
break;
case BodyGenTy::DupNoPriv:
if (info.DevicePtrInfoMap.empty()) {
// For host device we still need to do the mapping for codegen,
// otherwise it may try to lookup a missing value.
if (!ompBuilder->Config.IsTargetDevice.value_or(false)) {
mapUseDevice(llvm::OpenMPIRBuilder::DeviceInfoTy::Address,
blockArgIface.getUseDeviceAddrBlockArgs(),
useDeviceAddrVars, mapData);
mapUseDevice(llvm::OpenMPIRBuilder::DeviceInfoTy::Pointer,
blockArgIface.getUseDevicePtrBlockArgs(),
useDevicePtrVars, mapData);
}
}
// We must always restoreIP regardless of doing anything the caller
// does not restore it, leading to incorrect (no) branch generation.
builder.restoreIP(codeGenIP);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Sorry unrelated to your change, minor code cleanup.

This restoreIP call seems redundant as we have one at the entry of bodyGenCB, can we please remove it and move the comment to the restoreIP call above.

Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one at the beginning of bodyGenCB?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the new revision is what I wanted :)

Expand Down
Loading