@@ -6122,6 +6122,8 @@ TEST_F(OpenMPIRBuilderTest, TargetRegion) {
6122
6122
OpenMPIRBuilderConfig Config (false , false , false , false , false , false , false );
6123
6123
OMPBuilder.setConfig (Config);
6124
6124
F->setName (" func" );
6125
+ F->addFnAttr (" target-cpu" , " x86-64" );
6126
+ F->addFnAttr (" target-features" , " +mmx,+sse" );
6125
6127
IRBuilder<> Builder (BB);
6126
6128
auto *Int32Ty = Builder.getInt32Ty ();
6127
6129
@@ -6270,6 +6272,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegion) {
6270
6272
StringRef FunctionName2 = OutlinedFunc->getName ();
6271
6273
EXPECT_TRUE (FunctionName2.starts_with (" __omp_offloading" ));
6272
6274
6275
+ // Check that target-cpu and target-features were propagated to the outlined
6276
+ // function
6277
+ EXPECT_EQ (OutlinedFunc->getFnAttribute (" target-cpu" ),
6278
+ F->getFnAttribute (" target-cpu" ));
6279
+ EXPECT_EQ (OutlinedFunc->getFnAttribute (" target-features" ),
6280
+ F->getFnAttribute (" target-features" ));
6281
+
6273
6282
EXPECT_FALSE (verifyModule (*M, &errs ()));
6274
6283
}
6275
6284
@@ -6280,6 +6289,8 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
6280
6289
OMPBuilder.initialize ();
6281
6290
6282
6291
F->setName (" func" );
6292
+ F->addFnAttr (" target-cpu" , " gfx90a" );
6293
+ F->addFnAttr (" target-features" , " +gfx9-insts,+wavefrontsize64" );
6283
6294
IRBuilder<> Builder (BB);
6284
6295
OpenMPIRBuilder::LocationDescription Loc ({Builder.saveIP (), DL});
6285
6296
@@ -6356,6 +6367,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
6356
6367
Function *OutlinedFn = TargetStore->getFunction ();
6357
6368
EXPECT_NE (F, OutlinedFn);
6358
6369
6370
+ // Check that target-cpu and target-features were propagated to the outlined
6371
+ // function
6372
+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-cpu" ),
6373
+ F->getFnAttribute (" target-cpu" ));
6374
+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-features" ),
6375
+ F->getFnAttribute (" target-features" ));
6376
+
6359
6377
EXPECT_TRUE (OutlinedFn->hasWeakODRLinkage ());
6360
6378
// Account for the "implicit" first argument.
6361
6379
EXPECT_EQ (OutlinedFn->getName (), " __omp_offloading_1_2_parent_l3" );
@@ -6602,6 +6620,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDeviceSPMD) {
6602
6620
EXPECT_NE (OutlinedFn, nullptr );
6603
6621
EXPECT_NE (F, OutlinedFn);
6604
6622
6623
+ // Check that target-cpu and target-features were propagated to the outlined
6624
+ // function
6625
+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-cpu" ),
6626
+ F->getFnAttribute (" target-cpu" ));
6627
+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-features" ),
6628
+ F->getFnAttribute (" target-features" ));
6629
+
6605
6630
EXPECT_TRUE (OutlinedFn->hasWeakODRLinkage ());
6606
6631
// Account for the "implicit" first argument.
6607
6632
EXPECT_EQ (OutlinedFn->getName (), " __omp_offloading_1_2_parent_l3" );
0 commit comments