llvm.org GIT mirror llvm / 7e7bbf8
Only adjust esp around calls in presence of alloca. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40028 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 13 years ago
3 changed file(s) with 12 addition(s) and 50 deletion(s). Raw diff Collapse all Expand all
10391039
10401040 //===---------------------------------------------------------------------===//
10411041
1042 We use push/pop of stack space around calls in situations where we don't have to.
1043 Call to f below produces:
1044 subl $16, %esp <<<<<
1045 movl %eax, (%esp)
1046 call L_f$stub
1047 addl $16, %esp <<<<<
1048 The stack push/pop can be moved into the prolog/epilog. It does this because it's
1049 building the frame pointer, but this should not be sufficient, only the use of alloca
1050 should cause it to do this.
1051 (There are other issues shown by this code, but this is one.)
1052
1053 typedef struct _range_t {
1054 float fbias;
1055 float fscale;
1056 int ibias;
1057 int iscale;
1058 int ishift;
1059 unsigned char lut[];
1060 } range_t;
1061
1062 struct _decode_t {
1063 int type:4;
1064 int unit:4;
1065 int alpha:8;
1066 int N:8;
1067 int bpc:8;
1068 int bpp:16;
1069 int skip:8;
1070 int swap:8;
1071 const range_t*const*range;
1072 };
1073
1074 typedef struct _decode_t decode_t;
1075
1076 extern int f(const decode_t* decode);
1077
1078 int decode_byte (const decode_t* decode) {
1079 if (decode->swap != 0)
1080 return f(decode);
1081 return 0;
1082 }
1083
1084
1085 //===---------------------------------------------------------------------===//
1086
10871042 This:
10881043 #include
10891044 unsigned test(float f) {
10211021 MachineModuleInfo *MMI = MFI->getMachineModuleInfo();
10221022
10231023 return (NoFramePointerElim ||
1024 MF.getFrameInfo()->hasVarSizedObjects() ||
1024 MFI->hasVarSizedObjects() ||
10251025 MF.getInfo()->getForceFramePointer() ||
10261026 (MMI && MMI->callsUnwindInit()));
1027 }
1028
1029 bool X86RegisterInfo::hasReservedCallFrame(MachineFunction &MF) const {
1030 return !MF.getFrameInfo()->hasVarSizedObjects();
10271031 }
10281032
10291033 void X86RegisterInfo::
10301034 eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
10311035 MachineBasicBlock::iterator I) const {
1032 if (hasFP(MF)) {
1033 // If we have a frame pointer, turn the adjcallstackup instruction into a
1034 // 'sub ESP, ' and the adjcallstackdown instruction into 'add ESP,
1035 // '
1036 if (!hasReservedCallFrame(MF)) {
1037 // If the stack pointer can be changed after prologue, turn the
1038 // adjcallstackup instruction into a 'sub ESP, ' and the
1039 // adjcallstackdown instruction into 'add ESP, '
1040 // TODO: consider using push / pop instead of sub + store / add
10361041 MachineInstr *Old = I;
10371042 uint64_t Amount = Old->getOperand(0).getImm();
10381043 if (Amount != 0) {
9797
9898 bool hasFP(const MachineFunction &MF) const;
9999
100 bool hasReservedCallFrame(MachineFunction &MF) const;
101
100102 void eliminateCallFramePseudoInstr(MachineFunction &MF,
101103 MachineBasicBlock &MBB,
102104 MachineBasicBlock::iterator MI) const;