[LLVMdev] LoadInst result

Tim Northover t.p.northover at gmail.com
Mon Feb 3 04:24:16 PST 2014


> Yes. I could use the LLVM custom RTTI implementation. However, i think there
> isnt a type called VirtualRegister. If it exists, i could do a dyn_cast<> to
> check if an operand (represented by Value *) is indeed virtual-register or
> not. I hope i explained the problem i am facing.

I think the question itself is problematic in LLVM terms. (Almost) all
Values are inevitably going to become virtual registers in the
backend, and after that may or may not be spilled to stack slots at
some points. Much of the time, even the other cases you explicitly
mentioned will be allocated to a virtual register too.

You're probably going to have to implement custom logic to spot just
what you consider not to be a virtual-register. Some possible
edge-cases you might want to think about are:
1. Is getelementptr(i8* @var, i32 %a) a virtual register or a global?
2. What about "%a = ptrtoint i8* @var to i64; %b = add i64 %a, 42; %c
= inttoptr i64 %b to i8*"?
3. And "%a = sub i64 ptrtoint(i8* @var1 to i64), ptrtoint(i8* @var2 to
i64); %b = inttoptr i64 %a to i8*"?

It might be time to rethink why you want to classify every Value into
virtual-register or not. As an outsider it sounds like you're trying
to pick the wrong way to divide instructions. Could you explain a bit
about what you intend to do with this partition once you have it? What
operations do you want to do that only work on virtual registers, or
vice versa?

Cheers.

Tim.



More information about the llvm-dev mailing list