diff options
Diffstat (limited to 'lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 8e8962928d..b2a6864194 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -11043,12 +11043,11 @@ static Instruction *InstCombineLoadCast(InstCombiner &IC, LoadInst &LI, if (ConstantExpr *CE = dyn_cast<ConstantExpr>(CI)) { // Instead of loading constant c string, use corresponding integer value // directly if string length is small enough. - const char *Str = GetConstantStringInfo(CE->getOperand(0)); - if (Str) { - unsigned len = strlen(Str); + std::string Str; + if (GetConstantStringInfo(CE->getOperand(0), Str) && !Str.empty()) { + unsigned len = Str.length(); const Type *Ty = cast<PointerType>(CE->getType())->getElementType(); unsigned numBits = Ty->getPrimitiveSizeInBits(); - // Replace LI with immediate integer store. if ((numBits >> 3) == len + 1) { APInt StrVal(numBits, 0); |