This is an archive of the discontinued LLVM Phabricator instance.

Fix bitcast to gep constant folding transform.
ClosedPublic

Authored by deadalnix on Dec 5 2015, 9:56 PM.

Details

Summary

It is checking is the destination type is sized, when the source type is the one that shoul dbe checked. It cause assertion failure down the road is the source type is unsized but destination type is.

Diff Detail

Repository
rL LLVM

Event Timeline

deadalnix updated this revision to Diff 42003.Dec 5 2015, 9:56 PM
deadalnix retitled this revision from to Fix bitcast to gep constant folding transform..
deadalnix updated this object.
deadalnix added a subscriber: llvm-commits.
majnemer edited edge metadata.Dec 5 2015, 10:37 PM

Can you please provide a test-case to ensure we won't regress?

deadalnix updated this revision to Diff 42004.Dec 5 2015, 11:37 PM
deadalnix edited edge metadata.

Add test

majnemer accepted this revision.Dec 6 2015, 12:49 PM
majnemer edited edge metadata.

LGTM

unittests/IR/ConstantsTest.cpp
387–398 ↗(On Diff #42004)

This test doesn't seem related to the change in question. It worked before your change.

400–408 ↗(On Diff #42004)

I'd move this test to test/Assembler/ConstantExprFoldCast.ll

The IR translation of this test would be something like:

%Unsized = type opaque
%S2 = type { i32, %Unsized }
@G2 = external global %S2
@G3 = global i32* bitcast (%S2* @G2 to i32*)
This revision is now accepted and ready to land.Dec 6 2015, 12:49 PM
deadalnix added inline comments.Dec 6 2015, 9:39 PM
unittests/IR/ConstantsTest.cpp
387–398 ↗(On Diff #42004)

It doesn't looks like it is well tested.

400–408 ↗(On Diff #42004)

The file check that there is no cast. I can put the first part of the test in there, but it doesn't looks like it is adequate for checking that this doesn't assert fail.

deadalnix updated this revision to Diff 42028.Dec 6 2015, 9:51 PM
deadalnix edited edge metadata.

Move the GEP test in test/Assembler/ConstantExprFoldCast.ll
The regression test cannot be moved there.

deadalnix updated this revision to Diff 42387.Dec 9 2015, 9:58 PM

Fix rebase conflict and ping.

This revision was automatically updated to reflect the committed changes.