@@ -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
@@ -6357,6 +6368,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
6357
6368
Function *OutlinedFn = TargetStore->getFunction ();
6358
6369
EXPECT_NE (F, OutlinedFn);
6359
6370
6371
+ // Check that target-cpu and target-features were propagated to the outlined
6372
+ // function
6373
+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-cpu" ),
6374
+ F->getFnAttribute (" target-cpu" ));
6375
+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-features" ),
6376
+ F->getFnAttribute (" target-features" ));
6377
+
6360
6378
EXPECT_TRUE (OutlinedFn->hasWeakODRLinkage ());
6361
6379
// Account for the "implicit" first argument.
6362
6380
EXPECT_EQ (OutlinedFn->getName (), " __omp_offloading_1_2_parent_l3" );
@@ -6598,6 +6616,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDeviceSPMD) {
6598
6616
EXPECT_NE (OutlinedFn, nullptr );
6599
6617
EXPECT_NE (F, OutlinedFn);
6600
6618
6619
+ // Check that target-cpu and target-features were propagated to the outlined
6620
+ // function
6621
+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-cpu" ),
6622
+ F->getFnAttribute (" target-cpu" ));
6623
+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-features" ),
6624
+ F->getFnAttribute (" target-features" ));
6625
+
6601
6626
EXPECT_TRUE (OutlinedFn->hasWeakODRLinkage ());
6602
6627
// Account for the "implicit" first argument.
6603
6628
EXPECT_EQ (OutlinedFn->getName (), " __omp_offloading_1_2_parent_l3" );
0 commit comments