@@ -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
@@ -6269,6 +6271,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegion) {
6269
6271
StringRef FunctionName2 = OutlinedFunc->getName ();
6270
6272
EXPECT_TRUE (FunctionName2.starts_with (" __omp_offloading" ));
6271
6273
6274
+ // Check that target-cpu and target-features were propagated to the outlined
6275
+ // function
6276
+ EXPECT_EQ (OutlinedFunc->getFnAttribute (" target-cpu" ),
6277
+ F->getFnAttribute (" target-cpu" ));
6278
+ EXPECT_EQ (OutlinedFunc->getFnAttribute (" target-features" ),
6279
+ F->getFnAttribute (" target-features" ));
6280
+
6272
6281
EXPECT_FALSE (verifyModule (*M, &errs ()));
6273
6282
}
6274
6283
@@ -6279,6 +6288,8 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
6279
6288
OMPBuilder.initialize ();
6280
6289
6281
6290
F->setName (" func" );
6291
+ F->addFnAttr (" target-cpu" , " gfx90a" );
6292
+ F->addFnAttr (" target-features" , " +gfx9-insts,+wavefrontsize64" );
6282
6293
IRBuilder<> Builder (BB);
6283
6294
OpenMPIRBuilder::LocationDescription Loc ({Builder.saveIP (), DL});
6284
6295
@@ -6355,6 +6366,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
6355
6366
Function *OutlinedFn = TargetStore->getFunction ();
6356
6367
EXPECT_NE (F, OutlinedFn);
6357
6368
6369
+ // Check that target-cpu and target-features were propagated to the outlined
6370
+ // function
6371
+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-cpu" ),
6372
+ F->getFnAttribute (" target-cpu" ));
6373
+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-features" ),
6374
+ F->getFnAttribute (" target-features" ));
6375
+
6358
6376
EXPECT_TRUE (OutlinedFn->hasWeakODRLinkage ());
6359
6377
// Account for the "implicit" first argument.
6360
6378
EXPECT_EQ (OutlinedFn->getName (), " __omp_offloading_1_2_parent_l3" );
@@ -6594,6 +6612,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDeviceSPMD) {
6594
6612
EXPECT_NE (OutlinedFn, nullptr );
6595
6613
EXPECT_NE (F, OutlinedFn);
6596
6614
6615
+ // Check that target-cpu and target-features were propagated to the outlined
6616
+ // function
6617
+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-cpu" ),
6618
+ F->getFnAttribute (" target-cpu" ));
6619
+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-features" ),
6620
+ F->getFnAttribute (" target-features" ));
6621
+
6597
6622
EXPECT_TRUE (OutlinedFn->hasWeakODRLinkage ());
6598
6623
// Account for the "implicit" first argument.
6599
6624
EXPECT_EQ (OutlinedFn->getName (), " __omp_offloading_1_2_parent_l3" );
0 commit comments