@@ -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
@@ -6269,6 +6271,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegion) {
62696271 StringRef FunctionName2 = OutlinedFunc->getName ();
62706272 EXPECT_TRUE (FunctionName2.starts_with (" __omp_offloading" ));
62716273
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+
62726281 EXPECT_FALSE (verifyModule (*M, &errs ()));
62736282}
62746283
@@ -6279,6 +6288,8 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
62796288 OMPBuilder.initialize ();
62806289
62816290 F->setName (" func" );
6291+ F->addFnAttr (" target-cpu" , " gfx90a" );
6292+ F->addFnAttr (" target-features" , " +gfx9-insts,+wavefrontsize64" );
62826293 IRBuilder<> Builder (BB);
62836294 OpenMPIRBuilder::LocationDescription Loc ({Builder.saveIP (), DL});
62846295
@@ -6355,6 +6366,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
63556366 Function *OutlinedFn = TargetStore->getFunction ();
63566367 EXPECT_NE (F, OutlinedFn);
63576368
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+
63586376 EXPECT_TRUE (OutlinedFn->hasWeakODRLinkage ());
63596377 // Account for the "implicit" first argument.
63606378 EXPECT_EQ (OutlinedFn->getName (), " __omp_offloading_1_2_parent_l3" );
@@ -6594,6 +6612,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDeviceSPMD) {
65946612 EXPECT_NE (OutlinedFn, nullptr );
65956613 EXPECT_NE (F, OutlinedFn);
65966614
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+
65976622 EXPECT_TRUE (OutlinedFn->hasWeakODRLinkage ());
65986623 // Account for the "implicit" first argument.
65996624 EXPECT_EQ (OutlinedFn->getName (), " __omp_offloading_1_2_parent_l3" );
0 commit comments