[llvm-commits] [rfc][pr11785] Make sure contained types when we map a type

Rafael Ávila de Espíndola rafael.espindola at gmail.com
Sun Jan 22 08:17:04 PST 2012

I still think that there is some memory corruption problem in pr11785,
but this patch fixes a problem and is sufficient to make the testcase in
pr11785 pass.

What is happening in pr11785 is

* We map a "complex" type (a pointer to an array of structs), but we
don't map the contained types (the struct for example).
* We find a gep instruction, and its type is found on the mapping (the
pointer to an array of structs).
* We find a load using that gep, its type is not found on the mapping
and we create a new struct type when recursing in getImpl
* The verifier finds out that the load is invalid.

The attached patch adds a fairly heavy handed makeConsistent method. It
might be equivalent to just removing

 if (DstTy == SrcTy) {
    Entry = DstTy;

from addTypeMapping and letting areTypeIsomorphic do the job, but I have
not tested that yet.

The patch also adds an assert to ValueMapper.cpp that makes it easier to
find where we are producing an invalid load.

The main question is if getImpl was supposed to work with incomplete
information or if something equivalent to this patch's makeConsistent is

Since the testcase is very sensitive to address values and running
valgrind makes it pass, I think there is still an independent problem
somewhere. I am currently testing for DenseMap iterators being

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr11785.patch
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120122/d3787fd0/attachment.ksh>

More information about the llvm-commits mailing list