This is an archive of the discontinued LLVM Phabricator instance.

[mips] [IAS] Fix LW with relative label operands.
ClosedPublic

Authored by tomatabacu on May 22 2015, 7:56 AM.

Details

Summary

Previously, MCSymbolRefExpr::create() was called with a StringRef of the symbol
name, which it would then search for in the Symbols StringMap (from MCContext).

However, relative labels (which are temporary symbols) are apparently not stored
in the Symbols StringMap, so we end up creating a new {$,.L}tmp symbol
({$,.L}tmp00, {$,.L}tmp10 etc.) each time we create an MCSymbolRefExpr by
passing in the symbol name as a StringRef.

Fortunately, there is a version of MCSymbolRefExpr::create() which takes an
MCSymbol* and we already have an MCSymbol* at that point, so we can just pass
that in instead of the StringRef.

I also removed the local StringRef calls to MCSymbolRefExpr::create() from
expandMemInst(), as those cases can be handled by evaluateRelocExpr() anyway.

Diff Detail

Event Timeline

tomatabacu updated this revision to Diff 26323.May 22 2015, 7:56 AM
tomatabacu retitled this revision from to [mips] [IAS] Fix creation of MCSymbolRefExpr's of $tmp symbols in evaluateRelocExpr()..
tomatabacu updated this object.
tomatabacu edited the test plan for this revision. (Show Details)
tomatabacu added a reviewer: dsanders.
tomatabacu added a subscriber: Unknown Object (MLST).

Rebased (for Sean Bruno's convenience).

dsanders accepted this revision.Jun 12 2015, 5:29 AM
dsanders edited edge metadata.

The overall change LGTM. I think it probably ought to be committed in two steps but the patch is small enough that I don't mind either way. If you do split it, the first step would drop the .getName() calls and the second step would fold the remaining code into evaluateRelocExpr().

This revision is now accepted and ready to land.Jun 12 2015, 5:29 AM
tomatabacu updated this object.Jun 16 2015, 7:58 AM
tomatabacu edited edge metadata.
tomatabacu retitled this revision from [mips] [IAS] Fix creation of MCSymbolRefExpr's of $tmp symbols in evaluateRelocExpr(). to [mips] [IAS] Fix LW with $tmp symbol operands..Jun 16 2015, 8:02 AM
tomatabacu updated this object.
tomatabacu retitled this revision from [mips] [IAS] Fix LW with $tmp symbol operands. to [mips] [IAS] Fix LW with relative label operands..Jun 17 2015, 3:45 AM
tomatabacu updated this object.
tomatabacu closed this revision.Jun 17 2015, 3:47 AM