[llvm] r302137 - [ArgPromotion] Fix a truncated variable

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Thu May 4 12:48:11 PDT 2017


On Thu, May 4, 2017 at 11:52 AM, Martin Storsjö <martin at martin.st> wrote:
> On Thu, 4 May 2017, Davide Italiano wrote:
>
>> On Thu, May 4, 2017 at 3:54 AM, Martin Storsjo via llvm-commits
>> <llvm-commits at lists.llvm.org> wrote:
>>>
>>> Author: mstorsjo
>>> Date: Thu May  4 05:54:35 2017
>>> New Revision: 302137
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=302137&view=rev
>>> Log:
>>> [ArgPromotion] Fix a truncated variable
>>>
>>> This fixes a regression since SVN rev 273808 (which was supposed to
>>> not change functionality).
>>>
>>> The regression caused miscompilations (noted in the wild when targeting
>>> AArch64) on platforms with 32 bit long.
>>>
>>> Differential Revision: https://reviews.llvm.org/D32850
>>>
>>> Modified:
>>>     llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
>>>
>>> Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=302137&r1=302136&r2=302137&view=diff
>>>
>>> ==============================================================================
>>> --- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
>>> +++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Thu May  4
>>> 05:54:35 2017
>>> @@ -247,7 +247,7 @@ doPromotion(Function *F, SmallPtrSetImpl
>>>            if (!ArgIndex.second.empty()) {
>>>              Ops.reserve(ArgIndex.second.size());
>>>              Type *ElTy = V->getType();
>>> -            for (unsigned long II : ArgIndex.second) {
>>> +            for (auto II : ArgIndex.second) {
>>>                // Use i32 to index structs, and i64 for others
>>> (pointers/arrays).
>>>                // This satisfies GEP constraints.
>>>                Type *IdxTy =
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>>
>> Please add the testcase that caused the miscompilation.
>
>
> I've got a reduced testcase in https://bugs.llvm.org/show_bug.cgi?id=32917.
> Should I add the produced IR from this as a testcase in LLVM, looking e.g.
> for the string "#-4" in the output assembly, or do you have any more
> concrete suggestions on how to do such a test?
>
> // Martin

That would definitely much better than no system at all.
Alternatively you can try getting the output before argpromotion and
run argpromotion on it.
You can probably run `opt` with `-opt-bisect-limit=X` to grab the IR
before and after. Make sure your test fails before the change and
passes after.

Thanks,

-- 
Davide

"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare


More information about the llvm-commits mailing list