summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/Loads.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-10-19 08:17:50 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-10-19 08:17:50 +0000
commita801dd5799bd6f6641ce3a7ea48f32d274ef95a0 (patch)
tree560a472c66fbfae4ebb35d7040168d6787b365a2 /llvm/lib/Analysis/Loads.cpp
parent0c28bc20da65169dac6133be5e230b7c5c0914c1 (diff)
downloadbcm5719-llvm-a801dd5799bd6f6641ce3a7ea48f32d274ef95a0.tar.gz
bcm5719-llvm-a801dd5799bd6f6641ce3a7ea48f32d274ef95a0.zip
Fix a long-standing miscompile in the load analysis that was uncovered
by my refactoring of this code. The method isSafeToLoadUnconditionally assumes that the load will proceed with the preferred type alignment. Given that, it has to ensure that the alloca or global is at least that aligned. It has always done this historically when a datalayout is present, but has never checked it when the datalayout is absent. When I refactored the code in r220156, I exposed this path when datalayout was present and that turned the latent bug into a patent bug. This fixes the issue by just removing the special case which allows folding things without datalayout. This isn't worth the complexity of trying to tease apart when it is or isn't safe without actually knowing the preferred alignment. llvm-svn: 220161
Diffstat (limited to 'llvm/lib/Analysis/Loads.cpp')
-rw-r--r--llvm/lib/Analysis/Loads.cpp11
1 files changed, 0 insertions, 11 deletions
diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp
index f5eb7055726..4838d856ae3 100644
--- a/llvm/lib/Analysis/Loads.cpp
+++ b/llvm/lib/Analysis/Loads.cpp
@@ -73,11 +73,6 @@ bool llvm::isSafeToLoadUnconditionally(Value *V, Instruction *ScanFrom,
Type *BaseType = nullptr;
unsigned BaseAlign = 0;
if (const AllocaInst *AI = dyn_cast<AllocaInst>(Base)) {
- // Loading directly from an alloca is trivially safe. We can't even look
- // through pointer casts here though, as that might change the size loaded.
- if (AI == V)
- return true;
-
// An alloca is safe to load from as load as it is suitably aligned.
BaseType = AI->getAllocatedType();
BaseAlign = AI->getAlignment();
@@ -86,12 +81,6 @@ bool llvm::isSafeToLoadUnconditionally(Value *V, Instruction *ScanFrom,
// overridden. Their size may change or they may be weak and require a test
// to determine if they were in fact provided.
if (!GV->mayBeOverridden()) {
- // Loading directly from the non-overridden global is trivially safe. We
- // can't even look through pointer casts here though, as that might change
- // the size loaded.
- if (GV == V)
- return true;
-
BaseType = GV->getType()->getElementType();
BaseAlign = GV->getAlignment();
}
OpenPOWER on IntegriCloud