PATCH + test for PR17099.

Stepan Dyatkovskiy stpworld at narod.ru
Fri Sep 6 07:39:32 PDT 2013


Ah!! My failure!
I have added FileCheck. Note, that I removed some extradata from CHECK 
directives, so for example I added
'tail call void @f0(i64'
instead of tail 'call void @f0(i64 %2)'
-Stepan.

Rafael EspĂ­ndola wrote:
> ; 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
>>
>>

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


More information about the llvm-commits mailing list