[llvm-commits] CVS: llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp

Chris Lattner sabre at nondot.org
Mon Aug 1 19:32:24 PDT 2005


On Mon, 1 Aug 2005, Reid Spencer wrote:

> I audited the remaining 3 ConstantInt::get calls in SimplifyLibCalls
> pass. The only remaining calls all pass 0 as the second argument so they
> are within range of the restrictions of that call.

Thanks a LOT Reid!

-Chris

> On Mon, 2005-08-01 at 11:53 -0500, Chris Lattner wrote:
>>
>> Changes in directory llvm/lib/Transforms/IPO:
>>
>> SimplifyLibCalls.cpp updated: 1.46 -> 1.47
>> ---
>> Log message:
>>
>> 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?
>>
>>
>>
>> ---
>> Diffs of the changes:  (+6 -2)
>>
>>  SimplifyLibCalls.cpp |    8 ++++++--
>>  1 files changed, 6 insertions(+), 2 deletions(-)
>>
>>
>> Index: llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
>> diff -u llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.46 llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.47
>> --- llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.46	Wed Jul 27 01:12:34 2005
>> +++ llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp	Mon Aug  1 11:52:50 2005
>> @@ -962,8 +962,12 @@
>>        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;
>>    }
>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/




More information about the llvm-commits mailing list