[cfe-dev] libc++ std::cout alignment trouble (was: Re: [llvm] r240144 - [SLP] Vectorize for all-constant entries.)
James Y Knight via cfe-dev
cfe-dev at lists.llvm.org
Thu Dec 31 15:07:36 PST 2015
On Dec 31, 2015, at 5:03 AM, Dimitry Andric via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> This thread unfortunately died out without any resolution, so we are now
> nearing 3.8 branching, and the problem is still not fixed. E.g., the
> only custom patch we have now left in FreeBSD's version of llvm (which
> we would really like to get rid of!) is the reversal of r240144: it is a
> pretty gross workaround, but it works for now.
> But is there any way that we can get this resolved before 3.8.0 ships,
> please? :-)
I believe the summary of the thread is that LLVM has a fundamentally unsound transformation: automatically increasing the required alignment of an externally visible global variable.
In enforceKnownAlignment in lib/Transforms/Utils/Local.cpp, it checks isStrongDefinitionForLinker() purportedly to ensure that the "memory we set aside for the global" is "the memory used by the final program.". However, even if said predicate returns true, that condition is NOT guaranteed, at least on ELF platforms, because of copy relocations.
(There's also very similar-looking alignment-fixing code in CodeGenPrepare::optimizeCallInst, too, I'm not sure why it's duplicated there.)
Basically, we need to not modify the alignment if:
if (Subtarget->isTargetELF() &&
TM.getRelocationModel() == Reloc::PIC_ &&
GV->hasDefaultVisibility() && !GV->hasLocalLinkage())
The above code snippet appears in X86FastISel.cpp, and equivalent-but-not-identical code appears in several other places, to determine whether a PLT load for the variable is required.
I'm not sure if isStrongDefinitionForLinker itself ought to be taking that into account, or if there should be a different new predicate for that check. isReallyActuallyTrulyStrongDefinitionForLinker()? :)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev