diff --git a/dmd/struct.c b/dmd/struct.c index 7d6d3936..7af158d0 100644 --- a/dmd/struct.c +++ b/dmd/struct.c @@ -151,7 +151,7 @@ void AggregateDeclaration::alignmember( unsigned size, // alignment requirement of field unsigned *poffset) { - //printf("salign = %d, size = %d, offset = %d\n",salign,size,offset); + //printf("salign = %d, size = %d, offset = %d\n",salign,size, *poffset); if (salign > 1) { assert(size != 3); @@ -160,7 +160,7 @@ void AggregateDeclaration::alignmember( sa = salign; *poffset = (*poffset + sa - 1) & ~(sa - 1); } - //printf("result = %d\n",offset); + //printf("result = %d\n", *poffset); } 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 d1aec882..c09806ec 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; @@ -494,6 +495,9 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) // parameter attributes if (!fdecl->isIntrinsic()) { set_param_attrs(f, func, fdecl); + if (opts::disableRedZone) { + func->addFnAttr(NoRedZone); + } } // main