OSDN Git Service

AArch64: Don't modify other modules in AArch64PromoteConstant
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 18 Mar 2016 23:30:54 +0000 (23:30 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 18 Mar 2016 23:30:54 +0000 (23:30 +0000)
commita41843d06795bce4d262169e328e183e05e7bf6d
treec18e8ee311ec5bf18ba34a655b87b7ec367ea360
parentdc0299a7449c2081990cb858b80b465cb1e82bde
AArch64: Don't modify other modules in AArch64PromoteConstant

Avoid modifying other modules in `AArch64PromoteConstant` when the
constant is `ConstantData` (a horrible accident, I'm sure, caught by an
experimental follow-up to r261464).

Previously, this walked through all the users of a constant, but that
reaches into other modules when the constant doesn't depend transitively
on a `GlobalValue`!  Since we're walking instructions anyway, just
modify the instructions we actually see.

As a drive-by, instead of storing `Use` and getting the instructions
again via `Use::getUser()` (which is not a constantant time lookup),
store `std::pair<Instruction, unsigned>`.  Besides being cheaper, this
makes it easier to drop use-lists form `ConstantData` in the future.
(I threw this in because I was touching all the code anyway.)

Because the patch completely changes the traversal logic, it looks
like a rewrite of the pass, but the core logic is all the same (or
should be, minus the out-of-module changes).  In other words, there
should be NFC as long as the LLVMContext only has a single Module.

I didn't think of a good way to test this, but I hope to submit a patch
eventually that makes walking these use-lists illegal/impossible.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263853 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/AArch64/AArch64PromoteConstant.cpp