diff options
| author | Bob Wilson <bob.wilson@apple.com> | 2010-02-01 17:41:44 +0000 | 
|---|---|---|
| committer | Bob Wilson <bob.wilson@apple.com> | 2010-02-01 17:41:44 +0000 | 
| commit | f65ba356e12514ff868154b6c29443394258db01 (patch) | |
| tree | cb23d80dab43d6544ef0b0c7086e8a6cb914a1a7 /llvm/lib/Transforms | |
| parent | de047f2051151443c5a0a3deecb0b3e7e826376c (diff) | |
| download | bcm5719-llvm-f65ba356e12514ff868154b6c29443394258db01.tar.gz bcm5719-llvm-f65ba356e12514ff868154b6c29443394258db01.zip  | |
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.
llvm-svn: 94984
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 14 | 
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 62c0ae0d844..7e7973ae0b7 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/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());  | 

