OSDN Git Service

Remove the folding rule
authorDan Gohman <gohman@apple.com>
Thu, 28 Jan 2010 18:08:26 +0000 (18:08 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 28 Jan 2010 18:08:26 +0000 (18:08 +0000)
commit8ca83b4111972f626a3e3f9af41f55718bf68927
tree5c8d5afbfe2cb69bf9797f04b76cc986eb61080c
parent12ea66a7277240c5b045ed14c140f94d453eea0e
Remove the folding rule
  getelementptr (i8* inttoptr (i64 1 to i8*), i32 -1)
  to
  inttoptr (i64 0 to i8*)
from the VMCore constant folder. It didn't handle sign-extension properly
in the case where the source integer is smaller than a pointer size. And,
it relied on an assumption about sizeof(i8).

The Analysis constant folder still folds these kinds of things; it has
access to TargetData, so it can do them right.

Add a testcase which tests that the VMCore constant folder doesn't
miscompile this, and that the Analysis folder does fold it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94750 91177308-0d34-0410-b5e6-96231b3b80d8
lib/VMCore/ConstantFold.cpp
test/Other/constant-fold-gep.ll [new file with mode: 0644]