PATCH + test for PR17099.

Stepan Dyatkovskiy stpworld at narod.ru
Fri Sep 6 04:36:39 PDT 2013


Hi Duncan,
Thanks for hint!
New patch is in attachment.

-Stepan.

Duncan Sands wrote:
> Hi Stepan,
>
>> Please find patch + regression test for MergeFunctions pass that fixes
>> PR17099
>> issue.
>
>> --- lib/Transforms/IPO/MergeFunctions.cpp    (revision 189742)
>> +++ lib/Transforms/IPO/MergeFunctions.cpp    (working copy)
>> @@ -738,7 +738,15 @@
>>    FunctionType *FFTy = F->getFunctionType();
>>    for (Function::arg_iterator AI = NewG->arg_begin(), AE =
>> NewG->arg_end();
>>         AI != AE; ++AI) {
>> -    Args.push_back(Builder.CreateBitCast(AI, FFTy->getParamType(i)));
>> +    Type* Ty1 = AI->getType();
>> +    Type* Ty2 = FFTy->getParamType(i);
>> +    LLVMContext &Ctx = Ty1->getContext();
>> +    if (isa<PointerType>(Ty1) && Ty2 == TD->getIntPtrType(Ctx))
>> +      Args.push_back(Builder.CreatePtrToInt(AI, Ty2));
>> +    else if (isa<PointerType>(Ty2) && Ty1 == TD->getIntPtrType(Ctx))
>> +      Args.push_back(Builder.CreateIntToPtr(AI, Ty2));
>> +    else
>> +      Args.push_back(Builder.CreateBitCast(AI, Ty2));
>
> you can use CastInst::getCastOpcode, which will produce BitCast,
> IntToPtr or
> PtrToInt as appropriate.
>
> Ciao, Duncan.
>
>>      ++i;
>>    }
>>
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr17099-2013-09-06.patch
Type: text/x-diff
Size: 1347 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130906/cc2714ae/attachment.patch>


More information about the llvm-commits mailing list