PATCH + test for PR17099.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Fri Sep 6 07:15:51 PDT 2013


; RUN: opt -S -mergefunc < %s

Please run FileCheck to show that you get the expected output.

On 6 September 2013 07:36, Stepan Dyatkovskiy <stpworld at narod.ru> wrote:
> 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
>
>



More information about the llvm-commits mailing list