This PR should fix a bug in the implementation of the insertvalue instruction which causes segmentation faults under certain conditions. More specifically, this bug concerns the allocation of the result aggregate. The LLVM reference (insertvalue instruction) does not indicate that insertvalue should behave like alloca with regards to its return value. Here is a minimal program which reproduces the observed issue (target: Ubuntu 64-bit):
Executing this program on Sulong yields a segfault after a few seconds (after several loop iterations). I suspect what happens is basically a stack overflow.
Note: Replacing %0 with undef in insertvalue in the IR shown above will still cause a segfault with the fix enabled. However, this is a different issue concerning undef and struct literals. This other issue is not restricted to the insertvalue instruction, but also occurs, when undef or struct literals are used on extractvalue or store instructions.
This PR should fix a bug in the implementation of the
insertvalue
instruction which causes segmentation faults under certain conditions. More specifically, this bug concerns the allocation of the result aggregate. The LLVM reference (insertvalue instruction) does not indicate thatinsertvalue
should behave likealloca
with regards to its return value. Here is a minimal program which reproduces the observed issue (target: Ubuntu 64-bit):Executing this program on Sulong yields a segfault after a few seconds (after several loop iterations). I suspect what happens is basically a stack overflow.
Note: Replacing
%0
withundef
ininsertvalue
in the IR shown above will still cause a segfault with the fix enabled. However, this is a different issue concerningundef
and struct literals. This other issue is not restricted to theinsertvalue
instruction, but also occurs, whenundef
or struct literals are used onextractvalue
orstore
instructions.