[llvm-commits] [patch] Remember the VariantKind when recursively evaluating a variable

Rafael EspĂ­ndola rafael.espindola at gmail.com
Thu Oct 21 10:28:37 PDT 2010


> There's no reason to add the MCContext arguments everywhere. It is
> accessible via Layout->getAssembler().getContext()

But the Layout can be NULL. In the cases where it is NULL the caller
can still provide at least a context so that we can allocate a new
expression.

> I don't fully understand the changes to EvaluateAsRelocatableImpl. Are
> we just recreating the expression? This looks like a hack to me.

It is one of two evils. Not sure if the lesser one. It is for cases like

foo:
bar = foo
        call bar at PLT

The assembler can produce a relocation to foo or bar, but it *has* to
be a R_X86_64_PLT32. The first evil (that I implemented) is to recurse
as we normally do but remember the variant kind. We then construct a
foo at PLT expression that is handled back and that is why we need the
context.

The other possible evil is to just return bar at PLT. But then we have to
change places that expect EvaluateAsRelocatable to go all the way
(MCAssembler::EvaluateFixup at least). It looks like this would match
gnu as a bit better.

A variation of the first option is to have
MCExpr::EvaluateAsRelocatableImpl "return" a variant kind instead of
creating a new expression.

> - Michael Spencer
>

Cheers,
Rafael



More information about the llvm-commits mailing list