@@ -6380,6 +6380,11 @@ TEST_F(OpenMPIRBuilderTest, TargetRegion) {
6380
6380
6381
6381
TEST_F (OpenMPIRBuilderTest, TargetRegionDevice) {
6382
6382
M->setTargetTriple (Triple (" amdgcn-amd-amdhsa" ));
6383
+ std::string oldDLStr = M->getDataLayoutStr ();
6384
+ M->setDataLayout (" e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:"
6385
+ " 32:32-p7:160:256:256:32-p8:128:128-p9:192:256:256:32-i64:"
6386
+ " 64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-"
6387
+ " v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9" );
6383
6388
OpenMPIRBuilder OMPBuilder (*M);
6384
6389
OMPBuilder.setConfig (
6385
6390
OpenMPIRBuilderConfig (true , false , false , false , false , false , false ));
@@ -6472,7 +6477,7 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
6472
6477
OMPBuilder.finalize ();
6473
6478
6474
6479
// Check outlined function
6475
- // XFAIL: EXPECT_FALSE(verifyModule(*M, &errs()));
6480
+ EXPECT_FALSE (verifyModule (*M, &errs ()));
6476
6481
EXPECT_NE (TargetStore, nullptr );
6477
6482
Function *OutlinedFn = TargetStore->getFunction ();
6478
6483
EXPECT_NE (F, OutlinedFn);
@@ -6497,19 +6502,24 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
6497
6502
EXPECT_NE (Alloca1, nullptr );
6498
6503
6499
6504
EXPECT_TRUE (isa<AllocaInst>(Alloca1));
6500
- auto *Store1 = Alloca1->getNextNode ();
6505
+ auto *AsCast1 = Alloca1->getNextNode ();
6506
+ EXPECT_TRUE (isa<AddrSpaceCastInst>(AsCast1));
6507
+ auto *Store1 = AsCast1->getNextNode ();
6501
6508
EXPECT_TRUE (isa<StoreInst>(Store1));
6502
6509
auto *Alloca2 = Store1->getNextNode ();
6503
6510
EXPECT_TRUE (isa<AllocaInst>(Alloca2));
6504
- auto *Store2 = Alloca2->getNextNode ();
6511
+ auto *AsCast2 = Alloca2->getNextNode ();
6512
+ EXPECT_TRUE (isa<AddrSpaceCastInst>(AsCast2));
6513
+ auto *Store2 = AsCast2->getNextNode ();
6505
6514
EXPECT_TRUE (isa<StoreInst>(Store2));
6506
6515
6507
6516
auto *InitCall = dyn_cast<CallInst>(Store2->getNextNode ());
6508
6517
EXPECT_NE (InitCall, nullptr );
6509
6518
EXPECT_EQ (InitCall->getCalledFunction ()->getName (), " __kmpc_target_init" );
6510
6519
EXPECT_EQ (InitCall->arg_size (), 2U );
6511
- EXPECT_TRUE (isa<GlobalVariable>(InitCall->getArgOperand (0 )));
6512
- auto *KernelEnvGV = cast<GlobalVariable>(InitCall->getArgOperand (0 ));
6520
+ EXPECT_TRUE (isa<GlobalVariable>(InitCall->getArgOperand (0 )->stripPointerCasts ()));
6521
+ auto *KernelEnvGV =
6522
+ cast<GlobalVariable>(InitCall->getArgOperand (0 )->stripPointerCasts ());
6513
6523
EXPECT_TRUE (isa<ConstantStruct>(KernelEnvGV->getInitializer ()));
6514
6524
auto *KernelEnvC = cast<ConstantStruct>(KernelEnvGV->getInitializer ());
6515
6525
EXPECT_TRUE (isa<ConstantStruct>(KernelEnvC->getAggregateElement (0U )));
@@ -6565,13 +6575,14 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
6565
6575
EXPECT_TRUE (isa<ConstantArray>(UsedInit));
6566
6576
auto *UsedInitData = cast<ConstantArray>(UsedInit);
6567
6577
EXPECT_EQ (1U , UsedInitData->getNumOperands ());
6568
- Constant *ExecMode = UsedInitData->getOperand (0 );
6578
+ Constant *ExecMode = UsedInitData->getOperand (0 )-> stripPointerCasts () ;
6569
6579
EXPECT_TRUE (isa<GlobalVariable>(ExecMode));
6570
6580
Constant *ExecModeValue = cast<GlobalVariable>(ExecMode)->getInitializer ();
6571
6581
EXPECT_NE (ExecModeValue, nullptr );
6572
6582
EXPECT_TRUE (isa<ConstantInt>(ExecModeValue));
6573
6583
EXPECT_EQ (OMP_TGT_EXEC_MODE_GENERIC,
6574
6584
cast<ConstantInt>(ExecModeValue)->getZExtValue ());
6585
+ M->setDataLayout (oldDLStr);
6575
6586
}
6576
6587
6577
6588
TEST_F (OpenMPIRBuilderTest, TargetRegionSPMD) {
@@ -6776,6 +6787,11 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDeviceSPMD) {
6776
6787
6777
6788
TEST_F (OpenMPIRBuilderTest, ConstantAllocaRaise) {
6778
6789
M->setTargetTriple (Triple (" amdgcn-amd-amdhsa" ));
6790
+ std::string oldDLStr = M->getDataLayoutStr ();
6791
+ M->setDataLayout (" e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:"
6792
+ " 32:32-p7:160:256:256:32-p8:128:128-p9:192:256:256:32-i64:"
6793
+ " 64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-"
6794
+ " v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9" );
6779
6795
OpenMPIRBuilder OMPBuilder (*M);
6780
6796
OMPBuilder.setConfig (
6781
6797
OpenMPIRBuilderConfig (true , false , false , false , false , false , false ));
@@ -6868,7 +6884,7 @@ TEST_F(OpenMPIRBuilderTest, ConstantAllocaRaise) {
6868
6884
OMPBuilder.finalize ();
6869
6885
6870
6886
// Check outlined function
6871
- // XFAIL: EXPECT_FALSE(verifyModule(*M, &errs()));
6887
+ EXPECT_FALSE (verifyModule (*M, &errs ()));
6872
6888
EXPECT_NE (TargetStore, nullptr );
6873
6889
Function *OutlinedFn = TargetStore->getFunction ();
6874
6890
EXPECT_NE (F, OutlinedFn);
@@ -6894,15 +6910,17 @@ TEST_F(OpenMPIRBuilderTest, ConstantAllocaRaise) {
6894
6910
// inappropriately with our alloca movement.
6895
6911
auto *Alloca2 = Alloca1->getNextNode ();
6896
6912
EXPECT_TRUE (isa<AllocaInst>(Alloca2));
6897
- auto *Store2 = Alloca2->getNextNode ();
6913
+ auto *AsCast1 = Alloca2->getNextNode ();
6914
+ EXPECT_TRUE (isa<AddrSpaceCastInst>(AsCast1));
6915
+ auto *Store2 = AsCast1->getNextNode ();
6898
6916
EXPECT_TRUE (isa<StoreInst>(Store2));
6899
6917
6900
6918
auto *InitCall = dyn_cast<CallInst>(Store2->getNextNode ());
6901
6919
EXPECT_NE (InitCall, nullptr );
6902
6920
EXPECT_EQ (InitCall->getCalledFunction ()->getName (), " __kmpc_target_init" );
6903
6921
EXPECT_EQ (InitCall->arg_size (), 2U );
6904
- EXPECT_TRUE (isa<GlobalVariable>(InitCall->getArgOperand (0 )));
6905
- auto *KernelEnvGV = cast<GlobalVariable>(InitCall->getArgOperand (0 ));
6922
+ EXPECT_TRUE (isa<GlobalVariable>(InitCall->getArgOperand (0 )-> stripPointerCasts () ));
6923
+ auto *KernelEnvGV = cast<GlobalVariable>(InitCall->getArgOperand (0 )-> stripPointerCasts () );
6906
6924
EXPECT_TRUE (isa<ConstantStruct>(KernelEnvGV->getInitializer ()));
6907
6925
auto *KernelEnvC = cast<ConstantStruct>(KernelEnvGV->getInitializer ());
6908
6926
EXPECT_TRUE (isa<ConstantStruct>(KernelEnvC->getAggregateElement (0U )));
@@ -6948,6 +6966,7 @@ TEST_F(OpenMPIRBuilderTest, ConstantAllocaRaise) {
6948
6966
auto *ExitBlock = EntryBlockBranch->getSuccessor (1 );
6949
6967
EXPECT_EQ (ExitBlock->getName (), " worker.exit" );
6950
6968
EXPECT_TRUE (isa<ReturnInst>(ExitBlock->getFirstNonPHIIt ()));
6969
+ M->setDataLayout (oldDLStr);
6951
6970
}
6952
6971
6953
6972
TEST_F (OpenMPIRBuilderTest, CreateTask) {
0 commit comments