@@ -6169,6 +6169,8 @@ TEST_F(OpenMPIRBuilderTest, TargetRegion) {
61696169 OpenMPIRBuilderConfig Config (false , false , false , false , false , false , false );
61706170 OMPBuilder.setConfig (Config);
61716171 F->setName (" func" );
6172+ F->addFnAttr (" target-cpu" , " x86-64" );
6173+ F->addFnAttr (" target-features" , " +mmx,+sse" );
61726174 IRBuilder<> Builder (BB);
61736175 auto *Int32Ty = Builder.getInt32Ty ();
61746176
@@ -6320,6 +6322,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegion) {
63206322 StringRef FunctionName2 = OutlinedFunc->getName ();
63216323 EXPECT_TRUE (FunctionName2.starts_with (" __omp_offloading" ));
63226324
6325+ // Check that target-cpu and target-features were propagated to the outlined
6326+ // function
6327+ EXPECT_EQ (OutlinedFunc->getFnAttribute (" target-cpu" ),
6328+ F->getFnAttribute (" target-cpu" ));
6329+ EXPECT_EQ (OutlinedFunc->getFnAttribute (" target-features" ),
6330+ F->getFnAttribute (" target-features" ));
6331+
63236332 EXPECT_FALSE (verifyModule (*M, &errs ()));
63246333}
63256334
@@ -6330,6 +6339,8 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
63306339 OMPBuilder.initialize ();
63316340
63326341 F->setName (" func" );
6342+ F->addFnAttr (" target-cpu" , " gfx90a" );
6343+ F->addFnAttr (" target-features" , " +gfx9-insts,+wavefrontsize64" );
63336344 IRBuilder<> Builder (BB);
63346345 OpenMPIRBuilder::LocationDescription Loc ({Builder.saveIP (), DL});
63356346
@@ -6407,6 +6418,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
64076418 Function *OutlinedFn = TargetStore->getFunction ();
64086419 EXPECT_NE (F, OutlinedFn);
64096420
6421+ // Check that target-cpu and target-features were propagated to the outlined
6422+ // function
6423+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-cpu" ),
6424+ F->getFnAttribute (" target-cpu" ));
6425+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-features" ),
6426+ F->getFnAttribute (" target-features" ));
6427+
64106428 EXPECT_TRUE (OutlinedFn->hasWeakODRLinkage ());
64116429 // Account for the "implicit" first argument.
64126430 EXPECT_EQ (OutlinedFn->getName (), " __omp_offloading_1_2_parent_l3" );
@@ -6657,6 +6675,13 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDeviceSPMD) {
66576675 EXPECT_NE (OutlinedFn, nullptr );
66586676 EXPECT_NE (F, OutlinedFn);
66596677
6678+ // Check that target-cpu and target-features were propagated to the outlined
6679+ // function
6680+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-cpu" ),
6681+ F->getFnAttribute (" target-cpu" ));
6682+ EXPECT_EQ (OutlinedFn->getFnAttribute (" target-features" ),
6683+ F->getFnAttribute (" target-features" ));
6684+
66606685 EXPECT_TRUE (OutlinedFn->hasWeakODRLinkage ());
66616686 // Account for the "implicit" first argument.
66626687 EXPECT_EQ (OutlinedFn->getName (), " __omp_offloading_1_2_parent_l3" );
0 commit comments