[LLVMdev] The Trouble with Triples

Owen Anderson resistor at mac.com
Fri Jul 31 13:10:23 PDT 2015


> On Jul 31, 2015, at 1:07 PM, Owen Anderson <resistor at mac.com> wrote:
> 
>> 
>> On Jul 31, 2015, at 1:01 PM, Eric Christopher <echristo at gmail.com <mailto:echristo at gmail.com>> wrote:
>> 
>> 
>> 
>> On Fri, Jul 31, 2015 at 12:40 PM Eric Christopher <echristo at gmail.com <mailto:echristo at gmail.com>> wrote:
>> On Fri, Jul 31, 2015 at 12:22 PM Owen Anderson <resistor at mac.com <mailto:resistor at mac.com>> wrote:
>> 
>>> On Jul 31, 2015, at 11:28 AM, Mehdi Amini <mehdi.amini at apple.com <mailto:mehdi.amini at apple.com>> wrote:
>>> 
>>>> 
>>>> On Jul 31, 2015, at 10:56 AM, Eric Christopher <echristo at gmail.com <mailto:echristo at gmail.com>> wrote:
>>>> 
>>>> 
>>>> On 30 July 2015 at 14:52, Daniel Sanders <Daniel.Sanders at imgtec.com <mailto:Daniel.Sanders at imgtec.com>> wrote:
>>>> > We will need a string serialization of the TargetTuple so that we can store it in the IR and read it back.
>>>> 
>>>> Why does it have to be in the IR? If every tool that deals with IR has
>>>> the same options and they mean the same thing I don't see why we'd
>>>> need that.
>>>> 
>>>> 
>>>> I agree with the need for serializing information and options into the module.
>>>>  
>>>> 
>>>> > Whether this is in one piece (e.g. 'target tuple = "...") or multiple pieces (e.g. 'target arch = "..."', 'target endian = "..."') doesn't matter too much at first but I can see the benefits of the latter being the end point. If we do choose that multiple pieces then I'd like to pass through the former first to keep the early steps of the migration to a TargetTuple as simple and mechanical as possible.
>>>> 
>>>> Assuming we really need it, wouldn't it work if we put in metadata?
>>>> That way, it would bloat the IR of targets that really needed it and
>>>> not the ones that don't, at the same time as being non-critical to
>>>> parsing and validating the IR, so you could safely drop some
>>>> information without breaking the file.
>>>> 
>>>> 
>>>> Metadata won't work. Metadata is defined to not affect code correctness and this obviously does.
>>> 
>>> 
>>> Is it true for Module level Metadata and not only for instruction attached one?
>> 
>> There are examples of module-level metadata that impact the correctness of the generated code in the LangRef today:
>> 
>> http://llvm.org/docs/LangRef.html#module-flags-metadata <http://llvm.org/docs/LangRef.html#module-flags-metadata>
>> http://llvm.org/docs/LangRef.html#objective-c-garbage-collection-module-flags-metadata <http://llvm.org/docs/LangRef.html#objective-c-garbage-collection-module-flags-metadata>
>> http://llvm.org/docs/LangRef.html#automatic-linker-flags-module-flags-metadata <http://llvm.org/docs/LangRef.html#automatic-linker-flags-module-flags-metadata>
>> http://llvm.org/docs/LangRef.html#c-type-width-module-flags-metadata <http://llvm.org/docs/LangRef.html#c-type-width-module-flags-metadata>
>> 
>> Wow, those are terrible. I remember the first as it was a hack for dealing with LTO and being unable to specify code generation flags. It definitely was not meant to affect whether or not correct output happened.
>> 
>> The rest appear to be even worse and should not have gone in. I can prepare a patch to remove them if you'd like.
>> 
>> In case it wasn't obvious this is me both being sad, mostly joking, and a little serious about it. I realize that apparently the ship has sailed here, but these should probably be first class IR citizens rather than building off of the "named metadata" extension.
> 
> The problem with this direction is that clients need to be able to extend the IR with their own additional annotations according to their own schemas.  We cannot practically bake all of those in as first-class IR citizens.  
> To throw in another example, SPIR 1.2 uses module metadata for required-for-correctness purposes:  https://www.khronos.org/files/opencl-spir-12-provisional.pdf <https://www.khronos.org/files/opencl-spir-12-provisional.pdf>
As does NVVM: http://docs.nvidia.com/cuda/nvvm-ir-spec/index.html#global-property-annotation-chapter-11 <http://docs.nvidia.com/cuda/nvvm-ir-spec/index.html#global-property-annotation-chapter-11>

—Owen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150731/e367bb32/attachment.html>


More information about the llvm-dev mailing list