[clang] a9656bd - [CodeGen][OpenMP] Make EmitLoadOfPointer() type consistent
Nikita Popov via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 22 01:37:56 PDT 2022
Author: Nikita Popov
Date: 2022-03-22T09:37:48+01:00
New Revision: a9656bd1bc3792b81ad5a7277bdf7d8159b3b924
URL: https://github.com/llvm/llvm-project/commit/a9656bd1bc3792b81ad5a7277bdf7d8159b3b924
DIFF: https://github.com/llvm/llvm-project/commit/a9656bd1bc3792b81ad5a7277bdf7d8159b3b924.diff
LOG: [CodeGen][OpenMP] Make EmitLoadOfPointer() type consistent
If necessary insert a bitcast beforehand, so the LLVM-level pointer
type and the Clang-level pointer type line up.
Added:
Modified:
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 94e7e1a3f68bc..7ce3cd99c1b76 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -6949,16 +6949,13 @@ void CodeGenFunction::EmitOMPUseDeviceAddrClause(
// For declrefs and variable length array need to load the pointer for
// correct mapping, since the pointer to the data was passed to the runtime.
if (isa<DeclRefExpr>(Ref->IgnoreParenImpCasts()) ||
- MatchingVD->getType()->isArrayType())
- PrivAddr =
- EmitLoadOfPointer(PrivAddr, getContext()
- .getPointerType(OrigVD->getType())
- ->castAs<PointerType>());
- llvm::Type *RealElTy =
- ConvertTypeForMem(OrigVD->getType().getNonReferenceType());
- llvm::Type *RealTy = RealElTy->getPointerTo();
- PrivAddr =
- Builder.CreatePointerBitCastOrAddrSpaceCast(PrivAddr, RealTy, RealElTy);
+ MatchingVD->getType()->isArrayType()) {
+ QualType PtrTy = getContext().getPointerType(
+ OrigVD->getType().getNonReferenceType());
+ PrivAddr = EmitLoadOfPointer(
+ Builder.CreateElementBitCast(PrivAddr, ConvertTypeForMem(PtrTy)),
+ PtrTy->castAs<PointerType>());
+ }
(void)PrivateScope.addPrivate(OrigVD, PrivAddr);
}
diff --git a/clang/test/OpenMP/target_data_use_device_addr_codegen.cpp b/clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
index 9a3f7aa17b166..6bc1631c9ab86 100644
--- a/clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
+++ b/clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
@@ -90,8 +90,8 @@ int main() {
// CHECK: [[A_REF:%.+]] = load float*, float** [[BPTR0_A_ADDR]],
// CHECK: [[REF_REF:%.+]] = load float*, float** [[BPTR2_REF_ADDR]],
// CHECK: store float* [[REF_REF]], float** [[TMP_REF_ADDR:%.+]],
-// CHECK: [[ARR:%.+]] = load float*, float** [[BPTR3_ARR_ADDR]],
-// CHECK: [[ARR_REF:%.+]] = bitcast float* [[ARR]] to [4 x float]*
+// CHECK: [[BPTR3_ARR_ADDR_CAST:%.+]] = bitcast float** [[BPTR3_ARR_ADDR]] to [4 x float]**
+// CHECK: [[ARR_REF:%.+]] = load [4 x float]*, [4 x float]** [[BPTR3_ARR_ADDR_CAST]],
// CHECK: [[VLA_REF:%.+]] = load float*, float** [[BPTR4_VLA_ADDR]],
// CHECK: [[A:%.+]] = load float, float* [[A_REF]],
// CHECK: [[INC:%.+]] = fadd float [[A]], 1.000000e+00
More information about the cfe-commits
mailing list