[PATCH] Reject bitcasts between address spaces with different sizes

Nick Lewycky nicholas at mxc.ca
Thu Jul 4 12:55:45 PDT 2013


Eli Friedman wrote:
> On Tue, Jul 2, 2013 at 8:16 PM, Matt Arsenault
> <Matthew.Arsenault at amd.com <mailto:Matthew.Arsenault at amd.com>> wrote:
>
>     Reject bitcasts between address spaces with different sizes
>
>     Autoupgrade from address space bitcasts in existing binaries
>     to ptrtoint / inttoptr. This conversion does not happen for
>     bitcasts between address spaces with the same pointer size for now.
>
>     For bitcode, turn bitcasts from pointers to different address
>     spaces into ptrtoint -> inttoptr to the different address space.
>
>     For text IR, the module fails verification.
>
>     This was discussed a while ago in this thread:
>     http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-September/053277.html
>
>
>     http://llvm-reviews.chandlerc.com/D1083
>
>     Files:
>        docs/LangRef.rst
>        include/llvm/AutoUpgrade.h
>        lib/AsmParser/LLParser.cpp
>        lib/Bitcode/Reader/BitcodeReader.cpp
>        lib/IR/AutoUpgrade.cpp
>        lib/IR/Verifier.cpp
>        test/Bitcode/bitcast-upgrade.ll
>        test/Bitcode/bitcast.ll
>
>
> High-level issues:
>
> 1. The way this is written, adding a data layout string to a module can
> turn a valid module into an invalid module.  We should consider
> introducing some sort of safe invariant here (either ban modules without
> data layouts outright, or don't allow them to use non-zero address spaces).
> 2. What are your long-term plans here?  I'm particularly worried about
> how you're planning on testing this.

I share the same concerns. Another option is to make address space sizes 
a property of the module itself. Module already has a 
Module::getPointerSize method that doesn't rely on DataLayout, have you 
considered extending this for multiple address spaces?

Nick

>
> -Eli
>
>
> On Tue, Jul 2, 2013 at 8:16 PM, Matt Arsenault
> <Matthew.Arsenault at amd.com <mailto:Matthew.Arsenault at amd.com>> wrote:
>
>     Reject bitcasts between address spaces with different sizes
>
>     Autoupgrade from address space bitcasts in existing binaries
>     to ptrtoint / inttoptr. This conversion does not happen for
>     bitcasts between address spaces with the same pointer size for now.
>
>     For bitcode, turn bitcasts from pointers to different address
>     spaces into ptrtoint -> inttoptr to the different address space.
>
>     For text IR, the module fails verification.
>
>     This was discussed a while ago in this thread:
>     http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-September/053277.html
>
>
>     http://llvm-reviews.chandlerc.com/D1083
>
>     Files:
>        docs/LangRef.rst
>        include/llvm/AutoUpgrade.h
>        lib/AsmParser/LLParser.cpp
>        lib/Bitcode/Reader/BitcodeReader.cpp
>        lib/IR/AutoUpgrade.cpp
>        lib/IR/Verifier.cpp
>        test/Bitcode/bitcast-upgrade.ll
>        test/Bitcode/bitcast.ll
>
>     _______________________________________________
>     llvm-commits mailing list
>     llvm-commits at cs.uiuc.edu <mailto:llvm-commits at cs.uiuc.edu>
>     http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list