//===---------- PPCTLSDynamicCall.cpp - TLS Dynamic Call Fixup ------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This pass expands ADDItls{ld,gd}LADDR[32] machine instructions into // separate ADDItls[gd]L[32] and GETtlsADDR[32] instructions, both of // which define GPR3. A copy is added from GPR3 to the target virtual // register of the original instruction. The GETtlsADDR[32] is really // a call instruction, so its target register is constrained to be GPR3. // This is not true of ADDItls[gd]L[32], but there is a legacy linker // optimization bug that requires the target register of the addi of // a local- or general-dynamic TLS access sequence to be GPR3. // // This is done in a late pass so that TLS variable accesses can be // fully commoned by MachineCSE. // //===----------------------------------------------------------------------===// #include "PPC.h" #include "PPCInstrBuilder.h" #include "PPCInstrInfo.h" #include "PPCTargetMachine.h" #include "llvm/CodeGen/LiveIntervals.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/InitializePasses.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" usingnamespacellvm; #define DEBUG_TYPE … namespace { struct PPCTLSDynamicCall : public MachineFunctionPass { … }; } INITIALIZE_PASS_BEGIN(PPCTLSDynamicCall, DEBUG_TYPE, "PowerPC TLS Dynamic Call Fixup", false, false) INITIALIZE_PASS_DEPENDENCY(LiveIntervalsWrapperPass) INITIALIZE_PASS_DEPENDENCY(SlotIndexesWrapperPass) INITIALIZE_PASS_END(PPCTLSDynamicCall, DEBUG_TYPE, "PowerPC TLS Dynamic Call Fixup", false, false) char PPCTLSDynamicCall::ID = …; FunctionPass* llvm::createPPCTLSDynamicCallPass() { … }