summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-08-01 16:52:50 +0000
committerChris Lattner <sabre@nondot.org>2005-08-01 16:52:50 +0000
commite17c5d0e594a930d557fd6a361c33ca57cad5b6a (patch)
tree939ed3d2ae135904239f98c8f91bc82db9136d3e /llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
parent546fd5944e9679ce8171ac895fb02342fd2ed052 (diff)
downloadbcm5719-llvm-e17c5d0e594a930d557fd6a361c33ca57cad5b6a.tar.gz
bcm5719-llvm-e17c5d0e594a930d557fd6a361c33ca57cad5b6a.zip
ConstantInt::get only works for arguments < 128.
SimplifyLibCalls probably has to be audited to make sure it does not make this mistake elsewhere. Also, if this code knows that the type will be unsigned, obviously one arm of this is dead. Reid, can you take a look into this further? llvm-svn: 22566
Diffstat (limited to 'llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp b/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
index 754143bea7f..99675b3cb35 100644
--- a/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
@@ -962,8 +962,12 @@ struct StrLenOptimization : public LibCallOptimization
return false;
// strlen("xyz") -> 3 (for example)
- ci->replaceAllUsesWith(
- ConstantInt::get(SLC.getTargetData()->getIntPtrType(),len));
+ const Type *Ty = SLC.getTargetData()->getIntPtrType();
+ if (Ty->isSigned())
+ ci->replaceAllUsesWith(ConstantSInt::get(Ty, len));
+ else
+ ci->replaceAllUsesWith(ConstantUInt::get(Ty, len));
+
ci->eraseFromParent();
return true;
}
OpenPOWER on IntegriCloud