diff options
-rw-r--r-- | lib/Transforms/Utils/Local.cpp | 14 |
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()); |