Skip to content

Commit 65a0d66

Browse files
committed
Fix accessing of aligned arrays in offloaded target regions
1 parent 553bff0 commit 65a0d66

8 files changed

+22804
-1843
lines changed

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,10 +2273,10 @@ bool Sema::isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level,
22732273
// and alignment, because the runtime library only deals with uintptr types.
22742274
// If it does not fit the uintptr size, we need to pass the data by reference
22752275
// instead.
2276-
if (!IsByRef &&
2277-
(Ctx.getTypeSizeInChars(Ty) >
2278-
Ctx.getTypeSizeInChars(Ctx.getUIntPtrType()) ||
2279-
Ctx.getDeclAlign(D) > Ctx.getTypeAlignInChars(Ctx.getUIntPtrType()))) {
2276+
if (!IsByRef && (Ctx.getTypeSizeInChars(Ty) >
2277+
Ctx.getTypeSizeInChars(Ctx.getUIntPtrType()) ||
2278+
Ctx.getAlignOfGlobalVarInChars(Ty) >
2279+
Ctx.getTypeAlignInChars(Ctx.getUIntPtrType()))) {
22802280
IsByRef = true;
22812281
}
22822282

clang/test/OpenMP/amdgpu_target_with_aligned_attribute.c

Lines changed: 305 additions & 0 deletions
Large diffs are not rendered by default.

clang/test/OpenMP/parallel_firstprivate_codegen.cpp

Lines changed: 160 additions & 168 deletions
Large diffs are not rendered by default.

clang/test/OpenMP/parallel_master_taskloop_firstprivate_codegen.cpp

Lines changed: 2229 additions & 333 deletions
Large diffs are not rendered by default.

clang/test/OpenMP/parallel_master_taskloop_simd_firstprivate_codegen.cpp

Lines changed: 2331 additions & 333 deletions
Large diffs are not rendered by default.

clang/test/OpenMP/target_firstprivate_codegen.cpp

Lines changed: 11797 additions & 406 deletions
Large diffs are not rendered by default.

clang/test/OpenMP/target_is_device_ptr_codegen.cpp

Lines changed: 5606 additions & 219 deletions
Large diffs are not rendered by default.

clang/test/OpenMP/teams_firstprivate_codegen.cpp

Lines changed: 372 additions & 380 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)