diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp --- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -2494,6 +2494,10 @@ InsertPointTy AllocaIP, unsigned NumLoops, ArrayRef StoreValues, const Twine &Name, bool IsDependSource) { + for (size_t I = 0; I < StoreValues.size(); I++) + assert(StoreValues[I]->getType()->isIntegerTy(64) && + "OpenMP runtime requires depend vec with i64 type"); + if (!updateToLocation(Loc)) return Loc.IP; @@ -2508,7 +2512,8 @@ for (unsigned I = 0; I < NumLoops; ++I) { Value *DependAddrGEPIter = Builder.CreateInBoundsGEP( ArrI64Ty, ArgsBase, {Builder.getInt64(0), Builder.getInt64(I)}); - Builder.CreateStore(StoreValues[I], DependAddrGEPIter); + StoreInst *STInst = Builder.CreateStore(StoreValues[I], DependAddrGEPIter); + STInst->setAlignment(Align(8)); } Value *DependBaseAddrGEP = Builder.CreateInBoundsGEP( diff --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp --- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp +++ b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp @@ -2267,6 +2267,7 @@ ASSERT_NE(StoreValue, nullptr); EXPECT_EQ(StoreValue->getValueOperand(), StoreValues[Iter]); EXPECT_EQ(StoreValue->getPointerOperand(), DependAddrGEPIter); + EXPECT_EQ(StoreValue->getAlignment(), 8); IterInst = dyn_cast(StoreValue); } @@ -2351,6 +2352,7 @@ ASSERT_NE(StoreValue, nullptr); EXPECT_EQ(StoreValue->getValueOperand(), StoreValues[Iter]); EXPECT_EQ(StoreValue->getPointerOperand(), DependAddrGEPIter); + EXPECT_EQ(StoreValue->getAlignment(), 8); IterInst = dyn_cast(StoreValue); } diff --git a/mlir/test/Target/LLVMIR/openmp-llvm.mlir b/mlir/test/Target/LLVMIR/openmp-llvm.mlir --- a/mlir/test/Target/LLVMIR/openmp-llvm.mlir +++ b/mlir/test/Target/LLVMIR/openmp-llvm.mlir @@ -659,14 +659,14 @@ omp.wsloop (%arg7) : i32 = (%arg0) to (%arg1) step (%arg2) ordered(1) { // CHECK: [[TMP:%.*]] = getelementptr inbounds [1 x i64], [1 x i64]* [[ADDR]], i64 0, i64 0 - // CHECK: store i64 [[ARG0:%.*]], i64* [[TMP]], align 4 + // CHECK: store i64 [[ARG0:%.*]], i64* [[TMP]], align 8 // CHECK: [[TMP2:%.*]] = getelementptr inbounds [1 x i64], [1 x i64]* [[ADDR]], i64 0, i64 0 // CHECK: [[OMP_THREAD2:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB3:[0-9]+]]) // CHECK: call void @__kmpc_doacross_wait(%struct.ident_t* @[[GLOB3]], i32 [[OMP_THREAD2]], i64* [[TMP2]]) omp.ordered depend_type("dependsink") depend_vec(%arg3 : i64) {num_loops_val = 1 : i64} // CHECK: [[TMP3:%.*]] = getelementptr inbounds [1 x i64], [1 x i64]* [[ADDR3]], i64 0, i64 0 - // CHECK: store i64 [[ARG0]], i64* [[TMP3]], align 4 + // CHECK: store i64 [[ARG0]], i64* [[TMP3]], align 8 // CHECK: [[TMP4:%.*]] = getelementptr inbounds [1 x i64], [1 x i64]* [[ADDR3]], i64 0, i64 0 // CHECK: [[OMP_THREAD4:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB5:[0-9]+]]) // CHECK: call void @__kmpc_doacross_post(%struct.ident_t* @[[GLOB5]], i32 [[OMP_THREAD4]], i64* [[TMP4]]) @@ -677,25 +677,25 @@ omp.wsloop (%arg7) : i32 = (%arg0) to (%arg1) step (%arg2) ordered(2) { // CHECK: [[TMP5:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[ADDR5]], i64 0, i64 0 - // CHECK: store i64 [[ARG0]], i64* [[TMP5]], align 4 + // CHECK: store i64 [[ARG0]], i64* [[TMP5]], align 8 // CHECK: [[TMP6:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[ADDR5]], i64 0, i64 1 - // CHECK: store i64 [[ARG1:%.*]], i64* [[TMP6]], align 4 + // CHECK: store i64 [[ARG1:%.*]], i64* [[TMP6]], align 8 // CHECK: [[TMP7:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[ADDR5]], i64 0, i64 0 // CHECK: [[OMP_THREAD6:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB7:[0-9]+]]) // CHECK: call void @__kmpc_doacross_wait(%struct.ident_t* @[[GLOB7]], i32 [[OMP_THREAD6]], i64* [[TMP7]]) // CHECK: [[TMP8:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[ADDR7]], i64 0, i64 0 - // CHECK: store i64 [[ARG2:%.*]], i64* [[TMP8]], align 4 + // CHECK: store i64 [[ARG2:%.*]], i64* [[TMP8]], align 8 // CHECK: [[TMP9:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[ADDR7]], i64 0, i64 1 - // CHECK: store i64 [[ARG3:%.*]], i64* [[TMP9]], align 4 + // CHECK: store i64 [[ARG3:%.*]], i64* [[TMP9]], align 8 // CHECK: [[TMP10:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[ADDR7]], i64 0, i64 0 // CHECK: [[OMP_THREAD8:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB7]]) // CHECK: call void @__kmpc_doacross_wait(%struct.ident_t* @[[GLOB7]], i32 [[OMP_THREAD8]], i64* [[TMP10]]) omp.ordered depend_type("dependsink") depend_vec(%arg3, %arg4, %arg5, %arg6 : i64, i64, i64, i64) {num_loops_val = 2 : i64} // CHECK: [[TMP11:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[ADDR9]], i64 0, i64 0 - // CHECK: store i64 [[ARG0]], i64* [[TMP11]], align 4 + // CHECK: store i64 [[ARG0]], i64* [[TMP11]], align 8 // CHECK: [[TMP12:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[ADDR9]], i64 0, i64 1 - // CHECK: store i64 [[ARG1]], i64* [[TMP12]], align 4 + // CHECK: store i64 [[ARG1]], i64* [[TMP12]], align 8 // CHECK: [[TMP13:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[ADDR9]], i64 0, i64 0 // CHECK: [[OMP_THREAD10:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB9:[0-9]+]]) // CHECK: call void @__kmpc_doacross_post(%struct.ident_t* @[[GLOB9]], i32 [[OMP_THREAD10]], i64* [[TMP13]])