@@ -1863,7 +1863,6 @@ void AttributeInferer::run(const SCCNodeSet &SCCNodes,
18631863
18641864struct SCCNodesResult {
18651865 SCCNodeSet SCCNodes;
1866- bool HasUnknownCall;
18671866};
18681867
18691868} // end anonymous namespace
@@ -2087,11 +2086,13 @@ static void addNoRecurseAttrs(const SCCNodeSet &SCCNodes,
20872086 for (auto &BB : *F)
20882087 for (auto &I : BB.instructionsWithoutDebug ())
20892088 if (auto *CB = dyn_cast<CallBase>(&I)) {
2089+ if (CB->hasFnAttr (Attribute::NoRecurse))
2090+ continue ;
2091+
20902092 Function *Callee = CB->getCalledFunction ();
20912093 if (!Callee || Callee == F ||
2092- (!Callee->doesNotRecurse () &&
2093- !(Callee->isDeclaration () &&
2094- Callee->hasFnAttribute (Attribute::NoCallback))))
2094+ !(Callee->isDeclaration () &&
2095+ Callee->hasFnAttribute (Attribute::NoCallback)))
20952096 // Function calls a potentially recursive function.
20962097 return ;
20972098 }
@@ -2227,29 +2228,13 @@ static void addWillReturn(const SCCNodeSet &SCCNodes,
22272228
22282229static SCCNodesResult createSCCNodeSet (ArrayRef<Function *> Functions) {
22292230 SCCNodesResult Res;
2230- Res.HasUnknownCall = false ;
22312231 for (Function *F : Functions) {
22322232 if (!F || F->hasOptNone () || F->hasFnAttribute (Attribute::Naked) ||
22332233 F->isPresplitCoroutine ()) {
2234- // Treat any function we're trying not to optimize as if it were an
2235- // indirect call and omit it from the node set used below.
2236- Res.HasUnknownCall = true ;
2234+ // Omit any functions we're trying not to optimize from the set.
22372235 continue ;
22382236 }
2239- // Track whether any functions in this SCC have an unknown call edge.
2240- // Note: if this is ever a performance hit, we can common it with
2241- // subsequent routines which also do scans over the instructions of the
2242- // function.
2243- if (!Res.HasUnknownCall ) {
2244- for (Instruction &I : instructions (*F)) {
2245- if (auto *CB = dyn_cast<CallBase>(&I)) {
2246- if (!CB->getCalledFunction ()) {
2247- Res.HasUnknownCall = true ;
2248- break ;
2249- }
2250- }
2251- }
2252- }
2237+
22532238 Res.SCCNodes .insert (F);
22542239 }
22552240 return Res;
@@ -2282,15 +2267,10 @@ deriveAttrsInPostOrder(ArrayRef<Function *> Functions, AARGetterT &&AARGetter,
22822267 addColdAttrs (Nodes.SCCNodes , Changed);
22832268 addWillReturn (Nodes.SCCNodes , Changed);
22842269 addNoUndefAttrs (Nodes.SCCNodes , Changed);
2285-
2286- // If we have no external nodes participating in the SCC, we can deduce some
2287- // more precise attributes as well.
2288- if (!Nodes.HasUnknownCall ) {
2289- addNoAliasAttrs (Nodes.SCCNodes , Changed);
2290- addNonNullAttrs (Nodes.SCCNodes , Changed);
2291- inferAttrsFromFunctionBodies (Nodes.SCCNodes , Changed);
2292- addNoRecurseAttrs (Nodes.SCCNodes , Changed);
2293- }
2270+ addNoAliasAttrs (Nodes.SCCNodes , Changed);
2271+ addNonNullAttrs (Nodes.SCCNodes , Changed);
2272+ inferAttrsFromFunctionBodies (Nodes.SCCNodes , Changed);
2273+ addNoRecurseAttrs (Nodes.SCCNodes , Changed);
22942274
22952275 // Finally, infer the maximal set of attributes from the ones we've inferred
22962276 // above. This is handling the cases where one attribute on a signature
0 commit comments