[LLVMdev] Analysis Passes
Devang Patel
dpatel at apple.com
Mon Jul 28 08:31:26 PDT 2008
On Jul 25, 2008, at 1:57 PM, John Criswell wrote:
> Devang Patel wrote:
>> On Jul 25, 2008, at 12:58 PM, Marc de Kruijf wrote:
>>
>> I'd like to write a pass that does both: implements a code
>> transformation and saves information that can be accessed by
>> subsequent passes.
>>
>> Ideally, we want to use two separate pass. However, it is quiet
>> possible that your requirement is unique. Would it be possible to
>> provide more info. on what your pass does ?
>>
> We actually have a similar situation with Automatic Pool Allocation
> (APA) and SAFECode. Some of the SAFECode passes need to query the
> Automatic Pool Allocation transform pass to determine what it has
> done.
> Examples include:
>
> 1) Given a pointer, what pool did APA use to allocate objects to which
> the pointer can point?
> 2) Is a function a clone of an original function, and if so, which
> function is the original function?
> 3) What is the LLVM type of a pool descriptor? Different versions of
> APA use a different type.
>
> I think we could refactor APA into an analysis pass and transform
> pass.
> The analysis pass does nothing on its own but has update methods that
> other passes can use to update it's information. When APA is run, it
> updates the analysis pass, and when the SAFECode passes run, they get
> the APA information from the analysis pass.
>
> Just FYI.
Let's say you do not refactor APA into two passes. And continue to
request APA through getAnalysisUsage(). How does requesting APA ( a
transformation pass) through getAnalysisUsage() help here ? Note,
getAnalysisUsage() is a pass manager contract that ensures that APA
pass is available. It does not handle how information is stored and
extracted.
Let's say your APA pass implements
APA {
void runOnFunction(); // do pool allocation. A
const PoolInfo *getPoolInfo(); // provides pool info
};
If pass A1 and A2 wants to use info collected during APA and request
it through getAnalysisUsage() then following might happen
A1 // requires APA
SomeOtherPass // does not preserve APA
A2 // requires APA
will instruction pass manager to schedule
APA
A1
SomeOtherPass
APA
A2
Is it appropriate to run APA transformation pass twice ?
-
Devang
More information about the llvm-dev
mailing list