mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-28 14:10:41 +00:00
Add new function attribute - noredzone.
Update code generator to use this attribute and remove DisableRedZone target option. Update llc to set this attribute when -disable-red-zone command line option is used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72894 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4c9369df57
commit
d18e31ae17
@ -54,13 +54,15 @@ const Attributes Alignment = 31<<16; ///< Alignment of parameter (5 bits)
|
||||
// stored as log2 of alignment with +1 bias
|
||||
// 0 means unaligned different from align 1
|
||||
const Attributes NoCapture = 1<<21; ///< Function creates no aliases of pointer
|
||||
const Attributes NoRedZone = 1<<22; /// disable redzone
|
||||
|
||||
/// @brief Attributes that only apply to function parameters.
|
||||
const Attributes ParameterOnly = ByVal | Nest | StructRet | NoCapture;
|
||||
|
||||
/// @brief Attributes that only apply to function.
|
||||
const Attributes FunctionOnly = NoReturn | NoUnwind | ReadNone | ReadOnly |
|
||||
NoInline | AlwaysInline | OptimizeForSize | StackProtect | StackProtectReq;
|
||||
NoInline | AlwaysInline | OptimizeForSize | StackProtect | StackProtectReq |
|
||||
NoRedZone;
|
||||
|
||||
/// @brief Parameter attributes that do not apply to vararg call arguments.
|
||||
const Attributes VarArgsIncompatible = StructRet;
|
||||
|
@ -117,10 +117,6 @@ namespace llvm {
|
||||
/// wth earlier copy coalescing.
|
||||
extern bool StrongPHIElim;
|
||||
|
||||
/// DisableRedZone - This flag disables use of the "Red Zone" on
|
||||
/// targets which would otherwise have one.
|
||||
extern bool DisableRedZone;
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
||||
|
@ -547,6 +547,7 @@ lltok::Kind LLLexer::LexIdentifier() {
|
||||
KEYWORD(optsize);
|
||||
KEYWORD(ssp);
|
||||
KEYWORD(sspreq);
|
||||
KEYWORD(noredzone);
|
||||
|
||||
KEYWORD(type);
|
||||
KEYWORD(opaque);
|
||||
|
@ -730,7 +730,7 @@ bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) {
|
||||
case lltok::kw_optsize: Attrs |= Attribute::OptimizeForSize; break;
|
||||
case lltok::kw_ssp: Attrs |= Attribute::StackProtect; break;
|
||||
case lltok::kw_sspreq: Attrs |= Attribute::StackProtectReq; break;
|
||||
|
||||
case lltok::kw_noredzone: Attrs |= Attribute::NoRedZone; break;
|
||||
|
||||
case lltok::kw_align: {
|
||||
unsigned Alignment;
|
||||
|
@ -80,6 +80,7 @@ namespace lltok {
|
||||
kw_optsize,
|
||||
kw_ssp,
|
||||
kw_sspreq,
|
||||
kw_noredzone,
|
||||
|
||||
kw_type,
|
||||
kw_opaque,
|
||||
|
@ -908,6 +908,7 @@ void PPCRegisterInfo::determineFrameLayout(MachineFunction &MF) const {
|
||||
// If we are a leaf function, and use up to 224 bytes of stack space,
|
||||
// don't have a frame pointer, calls, or dynamic alloca then we do not need
|
||||
// to adjust the stack pointer (we fit in the Red Zone).
|
||||
bool DisableRedZone = MF.getFunction()->hasFnAttr(Attribute::NoRedZone);
|
||||
if (!DisableRedZone &&
|
||||
FrameSize <= 224 && // Fits in red zone.
|
||||
!MFI->hasVarSizedObjects() && // No dynamic alloca.
|
||||
|
@ -41,7 +41,6 @@ namespace llvm {
|
||||
bool RealignStack;
|
||||
bool DisableJumpTables;
|
||||
bool StrongPHIElim;
|
||||
bool DisableRedZone;
|
||||
bool AsmVerbosityDefault(false);
|
||||
}
|
||||
|
||||
@ -163,11 +162,6 @@ EnableStrongPHIElim(cl::Hidden, "strong-phi-elim",
|
||||
cl::desc("Use strong PHI elimination."),
|
||||
cl::location(StrongPHIElim),
|
||||
cl::init(false));
|
||||
static cl::opt<bool, true>
|
||||
DisableRedZoneOption("disable-red-zone",
|
||||
cl::desc("Do not emit code that uses the red zone."),
|
||||
cl::location(DisableRedZone),
|
||||
cl::init(false));
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// TargetMachine Class
|
||||
|
@ -751,6 +751,7 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
|
||||
// function, and use up to 128 bytes of stack space, don't have a frame
|
||||
// pointer, calls, or dynamic alloca then we do not need to adjust the
|
||||
// stack pointer (we fit in the Red Zone).
|
||||
bool DisableRedZone = Fn->hasFnAttr(Attribute::NoRedZone);
|
||||
if (Is64Bit && !DisableRedZone &&
|
||||
!needsStackRealignment(MF) &&
|
||||
!MFI->hasVarSizedObjects() && // No dynamic alloca.
|
||||
|
@ -59,6 +59,8 @@ std::string Attribute::getAsString(Attributes Attrs) {
|
||||
Result += "ssp ";
|
||||
if (Attrs & Attribute::StackProtectReq)
|
||||
Result += "sspreq ";
|
||||
if (Attrs & Attribute::NoRedZone)
|
||||
Result += "noredzone ";
|
||||
if (Attrs & Attribute::Alignment) {
|
||||
Result += "align ";
|
||||
Result += utostr(Attribute::getAlignmentFromAttrs(Attrs));
|
||||
|
9
test/CodeGen/X86/red-zone2.ll
Normal file
9
test/CodeGen/X86/red-zone2.ll
Normal file
@ -0,0 +1,9 @@
|
||||
; RUN: llvm-as < %s | llc -march=x86-64 > %t
|
||||
; RUN: grep subq %t | count 1
|
||||
; RUN: grep addq %t | count 1
|
||||
|
||||
define x86_fp80 @f0(float %f) nounwind readnone noredzone {
|
||||
entry:
|
||||
%0 = fpext float %f to x86_fp80 ; <x86_fp80> [#uses=1]
|
||||
ret x86_fp80 %0
|
||||
}
|
@ -100,6 +100,11 @@ cl::opt<bool> NoVerify("disable-verify", cl::Hidden,
|
||||
cl::desc("Do not verify input module"));
|
||||
|
||||
|
||||
static cl::opt<bool>
|
||||
DisableRedZone("disable-red-zone",
|
||||
cl::desc("Do not emit code that uses the red zone."),
|
||||
cl::init(false));
|
||||
|
||||
// GetFileNameRoot - Helper function to get the basename of a filename.
|
||||
static inline std::string
|
||||
GetFileNameRoot(const std::string &InputFilename) {
|
||||
@ -336,8 +341,11 @@ int main(int argc, char **argv) {
|
||||
// Run our queue of passes all at once now, efficiently.
|
||||
// TODO: this could lazily stream functions out of the module.
|
||||
for (Module::iterator I = mod.begin(), E = mod.end(); I != E; ++I)
|
||||
if (!I->isDeclaration())
|
||||
if (!I->isDeclaration()) {
|
||||
if (DisableRedZone)
|
||||
I->addFnAttr(Attribute::NoRedZone);
|
||||
Passes.run(*I);
|
||||
}
|
||||
|
||||
Passes.doFinalization();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user