[llvm] r185024 - ARM: Proactively ensure that the LowerCallResult hack for 'this'-returns is not used for incompatible calling conventions.
Stephen Lin
stephenwlin at gmail.com
Wed Jun 26 14:42:14 PDT 2013
Author: stephenwlin
Date: Wed Jun 26 16:42:14 2013
New Revision: 185024
URL: http://llvm.org/viewvc/llvm-project?rev=185024&view=rev
Log:
ARM: Proactively ensure that the LowerCallResult hack for 'this'-returns is not used for incompatible calling conventions.
(Currently, ARM 'this'-returns are handled in the standard calling convention case by treating R0 as preserved and doing some extra magic in LowerCallResult; this may not apply to calling conventions added in the future so this patch provides and documents an interface for indicating such)
Modified:
llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp
llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h
llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=185024&r1=185023&r2=185024&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Wed Jun 26 16:42:14 2013
@@ -75,6 +75,9 @@ const uint32_t*
ARMBaseRegisterInfo::getThisReturnPreservedMask(CallingConv::ID) const {
return (STI.isTargetIOS() && !STI.isAAPCS_ABI())
? CSR_iOS_ThisReturn_RegMask : CSR_AAPCS_ThisReturn_RegMask;
+ // This should return NULL in the case of any calling convention that does
+ // not use the same register for an i32 first argument and an i32 return
+ // value
}
const uint32_t*
Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h?rev=185024&r1=185023&r2=185024&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h (original)
+++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h Wed Jun 26 16:42:14 2013
@@ -94,9 +94,18 @@ public:
/// Code Generation virtual methods...
const uint16_t *getCalleeSavedRegs(const MachineFunction *MF = 0) const;
const uint32_t *getCallPreservedMask(CallingConv::ID) const;
- const uint32_t *getThisReturnPreservedMask(CallingConv::ID) const;
const uint32_t *getNoPreservedMask() const;
+ // getThisReturnPreservedMask - Returns a call preserved mask specific to the
+ // case that 'returned' is an i32 first argument if the calling convention
+ // is one that can (partially) model this attribute with a preserved mask
+ // (i.e. it is a calling convention that uses the same register for the first
+ // i32 argument and an i32 return value)
+ //
+ // Should return NULL in the case that the calling convention does not have
+ // this property
+ const uint32_t *getThisReturnPreservedMask(CallingConv::ID) const;
+
BitVector getReservedRegs(const MachineFunction &MF) const;
const TargetRegisterClass*
Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=185024&r1=185023&r2=185024&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Wed Jun 26 16:42:14 2013
@@ -1711,10 +1711,17 @@ ARMTargetLowering::LowerCall(TargetLower
const uint32_t *Mask;
const TargetRegisterInfo *TRI = getTargetMachine().getRegisterInfo();
const ARMBaseRegisterInfo *ARI = static_cast<const ARMBaseRegisterInfo*>(TRI);
- if (isThisReturn)
- // For 'this' returns, use the R0-preserving mask
+ if (isThisReturn) {
+ // For 'this' returns, use the R0-preserving mask if applicable
Mask = ARI->getThisReturnPreservedMask(CallConv);
- else
+ if (!Mask) {
+ // Set isThisReturn to false if the calling convention is not one that
+ // allows 'returned' to be modeled in this way, so LowerCallResult does
+ // not try to pass 'this' straight through
+ isThisReturn = false;
+ Mask = ARI->getCallPreservedMask(CallConv);
+ }
+ } else
Mask = ARI->getCallPreservedMask(CallConv);
assert(Mask && "Missing call preserved mask for calling convention");
More information about the llvm-commits
mailing list