diff options
| author | Mark Seaborn <mseaborn@chromium.org> | 2013-05-24 12:18:12 -0700 |
|---|---|---|
| committer | Mark Seaborn <mseaborn@chromium.org> | 2013-05-24 12:18:12 -0700 |
| commit | c90dfbd2f293eb69e9ba40454e87525a3d4e94c7 (patch) | |
| tree | 491ffe6a14cbeedb1ddedc117874d99ed8a0fc34 /lib/Transforms/NaCl/PNaClABISimplify.cpp | |
| parent | fde18fe06ae70f60e0f184a9d384055c4f08cbbb (diff) | |
PNaCl: Fix ReplacePtrsWithInts to handle some corner cases correctly
Running the LLVM test suite with the ReplacePtrsWithInts pass enabled
produced a single failure (in MultiSource/Applications/SPASS),
revealing a corner case in which a mixture of forward and backward
references plus a bitcast causes the pass to fail (see
@forwards_reference() in the test).
The problem was that we were doing replaceAllUsesWith() on a
placeholder value too early. RewriteMap was mapping a bitcast to a
placeholder P, but RewriteMap's reference to P didn't get updated by
P->replaceAllUsesWith() and P became a dangling pointer.
The fix is:
* Change convert() to strip off casts first, so that RewriteMap isn't
used for mapping casts to converted values.
* Defer the replaceAllUsesWith() calls until after creating all the
replacement instructions. This makes the pass more robust against
instruction ordering in the input.
This requires debug instrinsics to be updated in a separate pass,
because replaceAllUsesWith() doesn't work for references by
metadata nodes.
This also fixes some pathological corner cases of cyclic references in
unreachable blocks.
Fix indentation in one place.
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3343
TEST=replace-ptrs-with-ints.ll + LLVM test suite
Review URL: https://codereview.chromium.org/15761003
Diffstat (limited to 'lib/Transforms/NaCl/PNaClABISimplify.cpp')
0 files changed, 0 insertions, 0 deletions
