aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2010-02-01 17:41:44 +0000
committerBob Wilson <bob.wilson@apple.com>2010-02-01 17:41:44 +0000
commit05d62e9e8c1be6d758781323009ba94476060970 (patch)
tree20ea8e1fa3a6a4c8e77f528aadfe6524c2193005 /lib/Transforms/Utils/Local.cpp
parent8ce0e3cc4b2b21f2cf6cf368d443e9f306bed6c7 (diff)
downloadexternal_llvm-05d62e9e8c1be6d758781323009ba94476060970.zip
external_llvm-05d62e9e8c1be6d758781323009ba94476060970.tar.gz
external_llvm-05d62e9e8c1be6d758781323009ba94476060970.tar.bz2
Fix pr6198 by moving the isSized() check to an outer conditional.
The testcase from pr6198 does not crash for me -- I don't know what's up with that -- so I'm not adding it to the tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94984 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/Local.cpp')
-rw-r--r--lib/Transforms/Utils/Local.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp
index 62c0ae0..7e7973a 100644
--- a/lib/Transforms/Utils/Local.cpp
+++ b/lib/Transforms/Utils/Local.cpp
@@ -95,13 +95,15 @@ bool llvm::isSafeToLoadUnconditionally(Value *V, Instruction *ScanFrom,
BaseAlign = GV->getAlignment();
}
}
- if (TD && BaseType && BaseAlign == 0)
- BaseAlign = TD->getPrefTypeAlignment(BaseType);
- if (BaseType && Align <= BaseAlign) {
- if (!TD)
- return true; // Loading directly from an alloca or global is OK.
- if (BaseType->isSized()) {
+ if (BaseType && BaseType->isSized()) {
+ if (TD && BaseAlign == 0)
+ BaseAlign = TD->getPrefTypeAlignment(BaseType);
+
+ if (Align <= BaseAlign) {
+ if (!TD)
+ return true; // Loading directly from an alloca or global is OK.
+
// Check if the load is within the bounds of the underlying object.
const PointerType *AddrTy = cast<PointerType>(V->getType());
uint64_t LoadSize = TD->getTypeStoreSize(AddrTy->getElementType());