This is an archive of the discontinued LLVM Phabricator instance.

[Attributor] Add LoopInfo to InformationCache and improve willreturn deduction
Needs ReviewPublic

Authored by uenoku on Aug 7 2019, 4:43 AM.

Details

Summary

In this patch, LoopInfo is added to InformationCache and used for willreturn function attribute deduction.

We can have willreturn if we assume all the loops in the function are assumed as never-endless (concrete implementation is in D65296. In this patch, only interfaces are provided). If there is an irreducible loop in function, we reach pessimistic fixpoint for now.

Diff Detail

Event Timeline

uenoku created this revision.Aug 7 2019, 4:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 7 2019, 4:43 AM
jdoerfert added inline comments.Aug 7 2019, 12:00 PM
llvm/include/llvm/Transforms/IPO/Attributor.h
374

I think you cannot cache the loop info objects (if you do not create them yourself at least). See also below.

llvm/lib/Transforms/IPO/Attributor.cpp
1255

Add this to the AALoop interface so we can query it easily and cache the results in there.

1296

LoopInfo::begin/end only traverses outermost loops.

Add a helper in the Attributor: checkForAllLoops(...) that traverses the outermost loops and transitively their child loops. We can then also employ liveness transparently.

2430

I think you have to store the LoopInfoGetter in the InfoCache and query it each time. Thought, I might be wrong.

llvm/test/Transforms/FunctionAttrs/read_write_returned_arguments_scc.ll
163 ↗(On Diff #213846)

Can you add the willreturn to the Function Attr: check where it changed?

uenoku updated this revision to Diff 216338.Aug 21 2019, 12:50 AM

Rebase and add checkForAllLoop.

This code doesn't work well with Old PassManager so tests are currently missing.

jdoerfert added inline comments.Aug 23 2019, 11:46 AM
llvm/lib/Transforms/IPO/Attributor.cpp
1390

No static variables as part of the logic please.

uenoku updated this revision to Diff 217118.Aug 26 2019, 5:01 AM

Address comment

Does this affect any tests?

llvm/include/llvm/Transforms/IPO/Attributor.h
1523

Given that this already has an "AbstractState" you can put the implementations in this class.

llvm/lib/Transforms/IPO/Attributor.cpp
2724

You don't seem to use it here. Do you plan to create an AALoop for each loop or one for a function? I guess the latter would allow to cache irreducible information as well.