[cfe-dev] [RFC] Call ParseLangArgs for all inputs
Harald van Dijk via cfe-dev
cfe-dev at lists.llvm.org
Thu Sep 10 14:37:03 PDT 2020
On 10/09/2020 21:51, Robinson, Paul wrote:
>> -----Original Message-----
>> From: cfe-dev <cfe-dev-bounces at lists.llvm.org> On Behalf Of Harald van
>> Dijk via cfe-dev
>> Sent: Thursday, September 10, 2020 2:31 PM
>> To: cfe-dev at lists.llvm.org
>> Subject: Re: [cfe-dev] [RFC] Call ParseLangArgs for all inputs
>>
>> ping 2
>>
>> On 03/09/2020 12:24, Harald van Dijk via cfe-dev wrote:
>>> ping
>>>
>>> On 27/08/2020 12:17, Harald van Dijk via cfe-dev wrote:
>>>> Hi,
>>>>
>>>> clang/lib/CodeGen/BackendUtil.cpp contains multiple checks for
>>>> attributes of LangOpts. The option processing that sets up LangOpts is
>>>> mostly done by ParseLangArgs, which is skipped for LLVM IR files.
>>>> Because of this, there are code generation differences when the
>>>> -save-temps command line option is used: that command line option
>>>> causes LLVM IR to be emitted to file and a new process to be spawned
>>>> to process that file, which does not process options the same way.
>
> I have to wonder whether some of those options really belong in the CodeGen
> category, rather than the Lang category. FP handling and sanitizers (the
> two groups that first caught my eye) really don't seem like LangOpts to me.
>
> Moving them would be more typing, of course, but I suspect the original
> reason ParseLangArgs isn't used on that path is that language-relevant
> actions should already have been taken by the time we're reading IR back in.
This is true. That may be a misunderstanding of the intent of the
function, as the name can be read two ways: it can be read as processing
the options that are relevant for the language handling, and it can be
read as processing the options that are *only* relevant for the language
handling. The FP options are definitely relevant for the language
handling and later codegen both. The sanitizers I'm not sure about, they
are used during language handling, but I do not really know how they are
used during later codegen. I had thought it would not be worth the
effort to move the options, but if that would be the preferred route, I
can submit that as a patch instead. It would have to be limited to the
options where I can actually verify they affect codegen though, so it
may be less complete.
> Just a thought. Offhand I don't know who would be super invested in this.
The reason I was looking at this was to fix an issue reported by a
customer who was trying to reproduce a bug reported to them. Bug
handling by them is often done on LLVM IR files, so having different
behaviour between -save-temps and not -save-temps, and the possibility
of bugs that only show up when -save-temps is not used, was a problem
for them. I do not know how common this is in other organisations using
LLVM, I would think they are not the only one doing this, but it may be
true that it is only a problem for a minority of users.
Regardless, I'm willing to do the work in getting this fixed, I just
need some guidance on the preferred way of fixing it.
Cheers,
Harald van Dijk
More information about the cfe-dev
mailing list