[LLVMdev] [cfe-dev] [RFC] Encoding Compile Flags into the IR

Rafael EspĂ­ndola rafael.espindola at gmail.com
Sun Apr 29 18:43:57 PDT 2012


>> * The recent discussion about metadata points out that it is not
>> really safe to add information that only part of the compiler reasons
>> about. Metadata adds the nice property that it is safe to drop, but
>> that is it. Passes have to know about it, it should be documented in
>> the language ref and the verifier should check it. I am afraid that
>> this part of the proposal would again create a feeling that we have a
>> magic bullet for passing semantic info from the FE to some passes.
>>
> I'm not sure I understand your meaning here. The point of making this named metadata is that it cannot be stripped from the module via normal methods. And it's inevitable that we will need for passes to know about the metadata and modify their behavior accordingly. That's the whole point, of course. :) (They will, at least, be able to query the Module object for the information they care about. The Module is the one which knows about the metadata.)

My point is that many passes might need to know about it, not just the
pass doing the modification. Any change to the IR has that property,
so it is better that it stays a somewhat formal process, involving a
discussion of each change and documentation on the language
reference..

A simple example of a problem it would be nice to handle in LTO: A
single file in a project is compiled with -mavx and the project uses
cpuid to decide if it should use that function or not. With LTO
currently we would miss the information that functions from one file
could use AVX.

Faced with this problem and with the above scheme implemented, it is
very likely I would jump to recording -mavx in the IL. A more
conventional review of an instruction_set metadata or attribute would
be way more likely to find and document issues like: can the inliner
inline a function into one having a more restrictive instruction set?
What about the other way? What should the resulting instruction set
be? It is unlikely the answer would be to just ignore the attribute.

In summary, I like the current review and discussion process that goes
with proposed changes to the IL and I am afraid the second part of the
proposal would cause us to loose (not lose) it.

>
> -bw
>

Cheers,
Rafael




More information about the llvm-dev mailing list