@@ -6122,6 +6122,8 @@ TEST_F(OpenMPIRBuilderTest, TargetRegion) {
61226122 OpenMPIRBuilderConfig Config (false , false , false , false , false , false , false );
61236123 OMPBuilder.setConfig (Config);
61246124 F->setName (" func" );
6125+ F->addFnAttr (" target-cpu" , " x86-64" );
6126+ F->addFnAttr (" target-features" , " +mmx,+sse" );
61256127 IRBuilder<> Builder (BB);
61266128 auto *Int32Ty = Builder.getInt32Ty ();
61276129
@@ -6270,6 +6272,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegion) {
62706272 StringRef FunctionName2 = OutlinedFunc->getName ();
62716273 EXPECT_TRUE (FunctionName2.starts_with (" __omp_offloading" ));
62726274
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+
62736282 EXPECT_FALSE (verifyModule (*M, &errs ()));
62746283}
62756284
@@ -6280,6 +6289,8 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
62806289 OMPBuilder.initialize ();
62816290
62826291 F->setName (" func" );
6292+ F->addFnAttr (" target-cpu" , " gfx90a" );
6293+ F->addFnAttr (" target-features" , " +gfx9-insts,+wavefrontsize64" );
62836294 IRBuilder<> Builder (BB);
62846295 OpenMPIRBuilder::LocationDescription Loc ({Builder.saveIP (), DL});
62856296
@@ -6356,6 +6367,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
63566367 Function *OutlinedFn = TargetStore->getFunction ();
63576368 EXPECT_NE (F, OutlinedFn);
63586369
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+
63596377 EXPECT_TRUE (OutlinedFn->hasWeakODRLinkage ());
63606378 // Account for the "implicit" first argument.
63616379 EXPECT_EQ (OutlinedFn->getName (), " __omp_offloading_1_2_parent_l3" );
@@ -6602,6 +6620,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDeviceSPMD) {
66026620 EXPECT_NE (OutlinedFn, nullptr );
66036621 EXPECT_NE (F, OutlinedFn);
66046622
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+
66056630 EXPECT_TRUE (OutlinedFn->hasWeakODRLinkage ());
66066631 // Account for the "implicit" first argument.
66076632 EXPECT_EQ (OutlinedFn->getName (), " __omp_offloading_1_2_parent_l3" );
0 commit comments