aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Transforms/IPO/SimplifyLibCalls.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Transforms/IPO/SimplifyLibCalls.cpp b/lib/Transforms/IPO/SimplifyLibCalls.cpp
index 754143bea7..99675b3cb3 100644
--- a/lib/Transforms/IPO/SimplifyLibCalls.cpp
+++ b/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;
}