@@ -6169,6 +6169,8 @@ TEST_F(OpenMPIRBuilderTest, TargetRegion) {
6169
6169
OpenMPIRBuilderConfig Config (false , false , false , false , false , false , false );
6170
6170
OMPBuilder.setConfig (Config);
6171
6171
F->setName (" func" );
6172
+ F->addFnAttr (" target-cpu" , " x86-64" );
6173
+ F->addFnAttr (" target-features" , " +mmx,+sse" );
6172
6174
IRBuilder<> Builder (BB);
6173
6175
auto *Int32Ty = Builder.getInt32Ty ();
6174
6176
@@ -6320,6 +6322,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegion) {
6320
6322
StringRef FunctionName2 = OutlinedFunc->getName ();
6321
6323
EXPECT_TRUE (FunctionName2.starts_with (" __omp_offloading" ));
6322
6324
6325
+ // Check that target-cpu and target-features were propagated to the outlined
6326
+ // function
6327
+ EXPECT_EQ (OutlinedFunc->getFnAttribute (" target-cpu" ),
6328
+ F->getFnAttribute (" target-cpu" ));
6329
+ EXPECT_EQ (OutlinedFunc->getFnAttribute (" target-features" ),
6330
+ F->getFnAttribute (" target-features" ));
6331
+
6323
6332
EXPECT_FALSE (verifyModule (*M, &errs ()));
6324
6333
}
6325
6334
@@ -6330,6 +6339,8 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
6330
6339
OMPBuilder.initialize ();
6331
6340
6332
6341
F->setName (" func" );
6342
+ F->addFnAttr (" target-cpu" , " gfx90a" );
6343
+ F->addFnAttr (" target-features" , " +gfx9-insts,+wavefrontsize64" );
6333
6344
IRBuilder<> Builder (BB);
6334
6345
OpenMPIRBuilder::LocationDescription Loc ({Builder.saveIP (), DL});
6335
6346
@@ -6407,6 +6418,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
6407
6418
Function *OutlinedFn = TargetStore->getFunction ();
6408
6419
EXPECT_NE (F, OutlinedFn);
6409
6420
6421
+ // Check that target-cpu and target-features were propagated to the outlined
6422
+ // function
6423
+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-cpu" ),
6424
+ F->getFnAttribute (" target-cpu" ));
6425
+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-features" ),
6426
+ F->getFnAttribute (" target-features" ));
6427
+
6410
6428
EXPECT_TRUE (OutlinedFn->hasWeakODRLinkage ());
6411
6429
// Account for the "implicit" first argument.
6412
6430
EXPECT_EQ (OutlinedFn->getName (), " __omp_offloading_1_2_parent_l3" );
@@ -6657,6 +6675,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDeviceSPMD) {
6657
6675
EXPECT_NE (OutlinedFn, nullptr );
6658
6676
EXPECT_NE (F, OutlinedFn);
6659
6677
6678
+ // Check that target-cpu and target-features were propagated to the outlined
6679
+ // function
6680
+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-cpu" ),
6681
+ F->getFnAttribute (" target-cpu" ));
6682
+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-features" ),
6683
+ F->getFnAttribute (" target-features" ));
6684
+
6660
6685
EXPECT_TRUE (OutlinedFn->hasWeakODRLinkage ());
6661
6686
// Account for the "implicit" first argument.
6662
6687
EXPECT_EQ (OutlinedFn->getName (), " __omp_offloading_1_2_parent_l3" );
0 commit comments