llvm.org GIT mirror llvm / a5d0ab5
The PowerPC VRSAVE register has been somewhat of an odd beast since the Altivec extensions were introduced. Its use is optional, and allows the compiler to communicate to the operating system which vector registers should be saved and restored during a context switch. In practice, this information is ignored by the various operating systems using the SVR4 ABI; the kernel saves and restores the entire register state. Setting the VRSAVE register is no longer performed by the AIX XL compilers, the IBM i compilers, or by GCC on Power Linux systems. It seems best to avoid this logic within LLVM as well. This patch avoids generating code to update and restore VRSAVE for the PowerPC SVR4 ABIs (32- and 64-bit). The code remains in place for the Darwin ABI. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165656 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Schmidt 7 years ago
3 changed file(s) with 30 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
4949 /// to manipulate the VRSAVE register, even though it uses vector registers.
5050 /// This can happen when the only registers used are known to be live in or out
5151 /// of the function. Remove all of the VRSAVE related code from the function.
52 /// FIXME: The removal of the code results in a compile failure at -O0 when the
53 /// function contains a function call, as the GPR containing original VRSAVE
54 /// contents is spilled and reloaded around the call. Without the prolog code,
55 /// the spill instruction refers to an undefined register. This code needs
56 /// to account for all uses of that GPR.
5257 static void RemoveVRSaveCode(MachineInstr *MI) {
5358 MachineBasicBlock *Entry = MI->getParent();
5459 MachineFunction *MF = Entry->getParent();
282287
283288 // Scan the prolog, looking for an UPDATE_VRSAVE instruction. If we find it,
284289 // process it.
285 for (unsigned i = 0; MBBI != MBB.end(); ++i, ++MBBI) {
286 if (MBBI->getOpcode() == PPC::UPDATE_VRSAVE) {
287 HandleVRSaveUpdate(MBBI, TII);
288 break;
289 }
290 }
290 if (!Subtarget.isSVR4ABI())
291 for (unsigned i = 0; MBBI != MBB.end(); ++i, ++MBBI) {
292 if (MBBI->getOpcode() == PPC::UPDATE_VRSAVE) {
293 HandleVRSaveUpdate(MBBI, TII);
294 break;
295 }
296 }
291297
292298 // Move MBBI back to the beginning of the function.
293299 MBBI = MBB.begin();
5252 GlobalBaseReg = 0;
5353 SelectionDAGISel::runOnMachineFunction(MF);
5454
55 InsertVRSaveCode(MF);
55 if (!PPCSubTarget.isSVR4ABI())
56 InsertVRSaveCode(MF);
57
5658 return true;
5759 }
5860
0 ; RUN: llc -O0 -mtriple=powerpc-unknown-linux-gnu < %s | FileCheck %s
1 ; RUN: llc -O0 -mtriple=powerpc64-unknown-linux-gnu < %s | FileCheck %s
2
3 ; This verifies that the code to update VRSAVE has been removed for SVR4.
4
5 define <4 x float> @bar(<4 x float> %v) nounwind {
6 entry:
7 %v.addr = alloca <4 x float>, align 16
8 store <4 x float> %v, <4 x float>* %v.addr, align 16
9 %0 = load <4 x float>* %v.addr, align 16
10 ret <4 x float> %0
11 }
12
13 ; CHECK-NOT: mfspr
14 ; CHECK-NOT: mtspr