Editors' pick: Originally published Feb. 14. Updated with additional information about Apple.

Some of Silicon Valley's largest tech companies stand to reap the benefits of a possible tax holiday and fiscal stimulus under President Donald Trump -- policies that could open up opportunities for accelerated stock buybacks and spur M&A activity. 

But Trump's stance on trade and immigration poses a threat to many of those tech behemoths by making it harder for them to attract talent and do business overseas, according to Goldman Sachs. 

"While final details are not yet known and certain proposals from both President Trump and Congress face fiscal and political hurdles, our economists see the most likely scenario as a somewhat scaled-down version of the proposals...," the firm said in a Tuesday note. 

Goldman predicts that the administration will settle on a corporate tax rate of 25% (Trump has said he wants a 15% rate vs. the current rate of 35%), reduce U.S. taxation of foreign corporate income with no destination-based tax and allow for repatriation of overseas cash with a one-time reduced tax rate. 

Apple (AAPL) sales could take a hit if Trump decides to enforce a border adjustment tax, impose a 45% tariff on Chinese imports or if he chooses to amend key trade agreements like NAFTA.

Trump and the Republicans in the House of Representatives have backed a destination-based tax system, also known as a border adjustment tax, which would tax products that are imported and subsidize products that are exported. The policy's goal is to incentivize US production, aid US exports and help fund other tax reductions, and it's also viewed by some as a solution to the U.S. trade deficit.

The border-adjusted corporate tax stands to hurt Apple, Hewlett Packard Enterprise (HPE)  and many other tech companies, however. Both companies would no longer be able to deduct the cost of imported goods (like imported components of the iPhone), which could impact profits and create a greater tax burden.

Apple CFO Luca Maestri rejected the notion of a border-adjustment tax this week, saying it would not only hurt consumers but could also drag down the economy. 

"It is very hard for us to imagine that a border tax would be good for the U.S. economy," Luca said yesterday at the Goldman Sachs technology conference in San Francisco, according to the Financial Times

Luca also hinted that Apple would consider utilizing a lower corporate tax rate and potential tax holiday as a vehicle for returning capital to shareholders. 

Goldman explained in the note that it doesn't expect a 45% tariff to be enacted, but said some trade restrictions may be imposed in 2017. 

"The trade policy changes in consideration...would be negative for most U.S. tech companies given most of their products are manufactured overseas and thus, technically, imported," the firm said. 

Trump has continuously called for Apple to "bring back manufacturing" to the U.S., but Apple's supply chain is heavily based in China and other areas overseas. 

Apple CEO Tim Cook

Goldman estimates that Apple's cost of imports represent about 59% of total sales, while approximately 64% of HPE's sales come from its cost of imports.

Goldman said the destination-based tax proposal raises several concerns: If exchange rates don't adjust adequately to compensate for the changes, companies like Apple would have to raise prices to preserve its margins. That said, the firm believes there's just a 20% chance that the border-adjustment tax becomes law.

Trump is more likely to successfully restrict the issuance of H-1B visas, a program that's heavily relied upon by the tech industry in its efforts to recruit skilled, foreign workers to the U.S. Tech giants including Facebook (FB) , Apple and Amazon (AMZN) all use the program extensively. 

Goldman estimates that between 900,000 and one million individuals are employed under H-1B visas in the U.S., with H-1B visa holders making up about 12% to 13% of tech-related jobs. 

Under Trump's plan, the administration could impose a salary "bidding" system where employers willing to pay more to sponsor foreign workers would have preference over bidders at lower salaries. Another proposal would require companies to employ a minimum number of domestic workers -- some have suggested a minimum of 50%. 

Aside from the fact that tech companies could possibly be unable to hire as many skilled foreign employees as before, Goldman said there are other possible implications. IT consulting and outsourcing companies, which typically pay H-1B employees lower salaries compared to other industries, face the "greatest risk" from proposed reforms, the firm said. 

"We would expect overall labor costs to increase across the tech universe, with the potential structural change in how IT consulting and outsourcing industry approaches its labor pyramid in terms of both seniority/offshore mix," Goldman added. 

Jim Cramer and the AAP team holds positions in Apple, Hewlett Packard Enterprise, and Facebook for their Action Alerts PLUS Charitable Trust Portfolio. Want to be alerted before Cramer buys or sells AAPL, HPE or FB? Learn more now.