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