[LLVMdev] Regarding LLVM Compiler
Lang Hames
lhames at gmail.com
Fri May 7 17:33:54 PDT 2010
Hi Kameshwar,
You're best off sending emails such as this to the LLVM developers mailing
list (llvmdev at cs.uiuc.edu). You'll reach a much wider audience.
The PBQPRegAlloc::buildInterferenceMatrix method constructs a PBQP cost
matrix representing a single interference constraint, which doesn't sound
like what you want. It is only used by the PBQP allocator (-regalloc=pbqp),
whereas LLVM uses linear scan by default (-regalloc=linscan). That's why
you're not seeing it called.
LLVM does not currently have an interference graph as such, because we do
not have a graph coloring register allocator. You can get the same
information from the LiveIntervals pass though. The LiveIntervals pass holds
a set of LiveInterval objects, one for each register (both virtual and
physical) that is live in the function. Each LiveInterval object describes
the set of instructions for which its register is live. The
LiveInterval::overlaps method will tell you whether or not two intervals
overlap, which means the registers for those intervals interfere.
(One caution: LiveInterval::overlaps currently triggers an assertion if the
interval passed as a parameter is empty. You'll want to explicitly skip
testing of empty intervals. They can just be treated as non-interfering.)
To sum up, you probably want something like this:
LiveIntervals *li_ = &getAnalysis<LiveIntervals>();
for (LiveIntervals::iterator liItr = li_->begin(), liEnd = li_->end(); liItr
!= liEnd; ++liItr) {
LiveInterval *li = liItr->second;
if (li->empty())
continue;
for (LiveIntervals::iterator li2Itr = llvm::next(liItr); li2Itr != liEnd;
++liItr) {
LiveInterval *li2 = li2Itr->second;
if (li2->empty())
continue;
if (li->overlaps(*li2)) {
// li->reg interferes with li2->reg.
// Handle this however you need to.
}
}
}
Cheers,
Lang.
On Fri, May 7, 2010 at 9:59 PM, kameshwar nayak <kameshwar.snayak at gmail.com>
wrote:
> Dear Sir,
>
> I am Kameshwar Nayak from India. I am in Final year Engineering.
> We are working on Code-Optimization in a Compiler. We chose LLVM in order
to
> test our approach. But we are finding it difficult to access the
> interference graph generated.
>
> We initially assumed PBQPRegAlloc::buildInterferenceMatrix() function
> defined in "lib/CodeGen/RegAllocPBQP.cpp" builds interference graph. But
we
> discovered that the function is not being called during the course of
> compilation
> Could you please help us to access the interference graph generated.?
>
> Waiting for your reply
>
> --
> Regards,
>
> Kameshwar
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100508/75cc4b05/attachment.html>
More information about the llvm-dev
mailing list