From fb418bf2e6270d215ba465105beb70caf6943bf4 Mon Sep 17 00:00:00 2001 From: Moritz Warning Date: Wed, 23 Feb 2011 23:50:53 +0100 Subject: [PATCH] Added -disable-red-zone flag. This will disable the usage of the 'red-zone' in ABIs that make use of it (like x86). This mimics the exact flag used by clang. It is comparable to the -mno-red-zone flag in gcc. - thanks to wilkie --- gen/cl_options.cpp | 4 ++++ gen/cl_options.h | 1 + gen/functions.cpp | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/gen/cl_options.cpp b/gen/cl_options.cpp index cbb8c5c1..7d500aa3 100644 --- a/gen/cl_options.cpp +++ b/gen/cl_options.cpp @@ -100,6 +100,10 @@ cl::opt output_s("output-s", cl::opt output_o("output-o", cl::desc("Write native object")); +// Disabling Red Zone +cl::opt disableRedZone("disable-red-zone", + cl::desc("Do not emit code that uses the red zone."), + cl::init(false)); // DDoc options static cl::opt doDdoc("D", diff --git a/gen/cl_options.h b/gen/cl_options.h index f7bf623a..8965a20e 100644 --- a/gen/cl_options.h +++ b/gen/cl_options.h @@ -26,6 +26,7 @@ namespace opts { extern cl::opt output_ll; extern cl::opt output_s; extern cl::opt output_o; + extern cl::opt disableRedZone; extern cl::opt ddocDir; extern cl::opt ddocFile; extern cl::opt jsonFile; diff --git a/gen/functions.cpp b/gen/functions.cpp index 8065dc0e..32c25bd8 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -22,6 +22,7 @@ #include "gen/dvalue.h" #include "gen/abi.h" #include "gen/nested.h" +#include "gen/cl_options.h" using namespace llvm::Attribute; @@ -501,6 +502,9 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) // parameter attributes if (!fdecl->isIntrinsic()) { set_param_attrs(f, func, fdecl); + if (opts::disableRedZone) { + func->addFnAttr(NoRedZone); + } } // main