[llvm] [X86] Insert CALLSEQ when lowering GlobalTLSAddress for ELF targets (PR #113706)

Fabian Ritter via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 29 01:59:22 PDT 2024


ritter-x2a wrote:

> I'm assuming this is a global / function scope constant. If you ignore the incoming chain, and just use DAG.getEntryNode, do you find the pre-existing node on later attempts at construction?

If I
- replace the incoming `Chain` argument of `GetTLSADDR` with `DAG.getEntryNode()`,
- remove the logic to retrieve the previously generated node, and
- just generate the nodes (including the CALLSEQ markers, the call, the load from the segment register, and the addition),

the resulting Node of a second invocation of GetTLSADDR for a function is not the same as that of the first invocation. The call and the CALLSEQ markers (and the addition that uses the call result) are not deduplicated, even though the sequence is based on the same incoming chain.
In the generated code for such a case, two calls are then emitted instead of one.
That CALLSEQ_END markers are not CSE'd seems to be intentional, according to [a comment above getCALLSEQ_END](https://github.com/llvm/llvm-project/blob/d83485a080341688cbb9d5c07a3839bd97f9001e/llvm/include/llvm/CodeGen/SelectionDAG.h#L1095).

https://github.com/llvm/llvm-project/pull/113706


More information about the llvm-commits mailing list