OSDN Git Service

Change the way the lint sanity checking pass detects misaligned memory accesses.
authorDuncan Sands <baldrick@free.fr>
Tue, 25 Sep 2012 10:00:49 +0000 (10:00 +0000)
committerDuncan Sands <baldrick@free.fr>
Tue, 25 Sep 2012 10:00:49 +0000 (10:00 +0000)
commit00edf4c1d8a691543faf5adf7b05558497d38abb
treea4d3876a1cd9d802ea9e704501aef037a07a17db
parentb1cacc74232164a9d80ee65d20e0095b25eb74d8
Change the way the lint sanity checking pass detects misaligned memory accesses.
Previously it was only be able to detect problems if the pointer was a numerical
value (eg inttoptr i32 1 to i32*), but not if it was an alloca or globa.  The
reason was the use of ComputeMaskedBits: imagine you have "alloca i8, align 2",
and ask ComputeMaskedBits what it knows about the bits of the alloca pointer.
It can tell you that the bottom bit is known zero (due to align 2) but it can't
tell you that bit 1 is known one.  That's because the address could be an even
multiple of 2 rather than an odd multiple, eg it might be a multiple of 4.  Thus
trying to use KnownOne is ineffective in the case of an alloca as it will never
have any bits set.  Instead look explicitly for constant offsets from allocas
and globals.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164595 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/Lint.cpp
test/Other/lint.ll