[PATCH] D27560: Always run GlobalDCE at O0

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 13 17:55:55 PST 2016


> On Dec 13, 2016, at 5:47 PM, Duncan P. N. Exon Smith via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> 
> 
>> On 2016-Dec-13, at 17:43, Chandler Carruth <chandlerc at google.com> wrote:
>> 
>> On Tue, Dec 13, 2016 at 5:33 PM Duncan P. N. Exon Smith via llvm-commits <llvm-commits at lists.llvm.org> wrote:
>> I agree that ideally we would teach Clang not to emit the code, but last I checked -O0 has a number of IR-modifying passes thanks to the sanitizers.
>> 
>> Not unless those sanitizers are enabled? I think the always inliner is the big one here...
>> 
>>  To understand how the frontend is (mis)behaving, I think you already need -mllvm -disable-llvm-passes.
>> 
>> Yes, I'm talking about testing whether LLVM is misbehaving which is different? Note that the patch changes the *opt* -O0, not just Clang.
> 
> Ah, I'd conflated LLVM and Clang (and I'd forgotten that opt was part of the patch).  I wonder if we could add such a flag to opt, which would fix the always inliner case too?  Or should we have a separate tool for reading/dumping IR and doing nothing?  (llvm-as|llvm-dis in a single process)

Well opt without any options is doing what you describe: llvm-as|llvm-dis in a single process

I guess for clang it comes down to the semantic of O0, is it *do not run any optimization*? Or is it *build as fast as possible without optimizing the code more than strictly necessary”?

I knew this would be controversial and the only reason I submitted this Global DCE change is because it is a bit on the edge: this “optimization” shouldn’t touch any functions that is reachable and only get rid of purely unreachable code.

Also, if always_inline is “required” for correctness it should process all the calligraph. Inserting global-DCE here was the simple immediate fix I could see to make sure all the call graph is processed.

— 
Mehdi





> 
>> 
>> 
>>> On 2016-Dec-13, at 17:25, Chandler Carruth via Phabricator <reviews at reviews.llvm.org> wrote:
>>> 
>>> chandlerc added a comment.
>>> 
>>> Personally, I would much rather teach Clang to not emit code than run a pass at O0. I really would like to preserve the ability to use O0 to understand why LLVM is misbehaving.
>>> 
>>> (The fact that we need to run the always inliner at O0 is already somewhat frustrating, I think it makes sense to resist worsening that situation.)
>>> 
>>> 
>>> https://reviews.llvm.org/D27560
>>> 
>>> 
>>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list