yaxunl added a comment.

In D98783#2633261 <https://reviews.llvm.org/D98783#2633261>, @tra wrote:

> In D98783#2632244 <https://reviews.llvm.org/D98783#2632244>, @yaxunl wrote:
>
>> In D98783#2632143 <https://reviews.llvm.org/D98783#2632143>, @tra wrote:
>>
>>> Shouldn't the unused ASCs be eliminated by DCE? We seem to be cleaning up 
>>> the consequences of a problem that happened somewhere else.
>>
>> DCE does not eliminate these unused ASCs because normally they should not 
>> exist. That's why we do not want them to be kept in the IR emitted by clang.
>
> TBH, these 'invisible' ASCs do bother me. I wonder what else is present in 
> the IR that we can't easily examine with existing tools?
> In principle I'm OK with eliminating such dangling ASCs here as a short-term 
> workaround, but I think it's potentially a more general issue which needs a 
> more general solution.

The invisible LLVM constants only happen when they are created but not used 
later, which is rare since usually a constant is created and used immediately, 
making them visible.

> One way to consistently deal with something like that is to codegen something 
> using those ASCs, but which would be considered unused and later DCE'd along 
> with unused ASCs. 
> We could use some sort of counterpart for `@llvm.used` only for potentially 
> unused IR we create.
> Tying them to such `@llvm_maybe_unused` would avoid the problem.

That's one solution. Another solution is to add a member function to LLVM 
module to clean up unused LLVM constants and add check to LLVM IR verifier to 
make sure there is no unused constants.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98783/new/

https://reviews.llvm.org/D98783

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to