diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2016-07-21 05:59:53 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2016-07-21 05:59:53 +0000 |
| commit | 4808f2642248da849a9ec03d3b9888ea9a031ec5 (patch) | |
| tree | 574bf8696511977b8a0ffcd42b70935211e9ae81 /llvm/lib/Transforms | |
| parent | 15cf7b83d1efa80f25a8c7b52f29082f4924541a (diff) | |
| download | bcm5719-llvm-4808f2642248da849a9ec03d3b9888ea9a031ec5.tar.gz bcm5719-llvm-4808f2642248da849a9ec03d3b9888ea9a031ec5.zip | |
[GVNHoist] Don't wrongly preserve TBAA
We hoisted loads/stores without taking into account which can cause
miscompiles.
llvm-svn: 276240
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/GVNHoist.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp b/llvm/lib/Transforms/Scalar/GVNHoist.cpp index 494f36bb3a7..9ca6ea04f4d 100644 --- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp +++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp @@ -603,12 +603,20 @@ public: // Copy the gep before moving the ld/st. Instruction *ClonedGep = Gep->clone(); ClonedGep->insertBefore(HoistPt->getTerminator()); + // Conservatively discard any optimization hints, they may differ on the + // other paths. + ClonedGep->dropUnknownNonDebugMetadata(); + ClonedGep->clearSubclassOptionalData(); Repl->replaceUsesOfWith(Gep, ClonedGep); // Also copy Val. if (Val) { Instruction *ClonedVal = Val->clone(); ClonedVal->insertBefore(HoistPt->getTerminator()); + // Conservatively discard any optimization hints, they may differ on the + // other paths. + ClonedVal->dropUnknownNonDebugMetadata(); + ClonedVal->clearSubclassOptionalData(); Repl->replaceUsesOfWith(Val, ClonedVal); } @@ -647,6 +655,9 @@ public: !makeOperandsAvailable(Repl, HoistPt)) continue; Repl->moveBefore(HoistPt->getTerminator()); + // TBAA may differ on one of the other paths, we need to get rid of + // anything which might conflict. + Repl->dropUnknownNonDebugMetadata(); } if (isa<LoadInst>(Repl)) @@ -668,6 +679,7 @@ public: ++NumStoresRemoved; else if (isa<CallInst>(Repl)) ++NumCallsRemoved; + Repl->intersectOptionalDataWith(I); I->replaceAllUsesWith(Repl); I->eraseFromParent(); } |

