When emitting the assembly we perform some late global variables demotion.
Prior to this patch, this optimization was only performed on variables with
the internal linkage whereas any local global variable can be demoted.
Fix that by using `hasLocalLinkage` instead of `hasInternalLinkage`.
Without this change, global variables with the `private` linkage wouldn't
be demoted.
Differential Revision: https://reviews.llvm.org/D154507