mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-08 11:56:12 +03:00
Add --fwarn-stack-size=<threshold>
for LLVM >= 13. (#4378)
This commit is contained in:
parent
a71625b373
commit
044b919bf6
3 changed files with 24 additions and 0 deletions
|
@ -664,6 +664,15 @@ cl::opt<std::string>
|
|||
"of optimizations performed by LLVM"),
|
||||
cl::ValueOptional);
|
||||
|
||||
#if LDC_LLVM_VER >= 1300
|
||||
// LLVM < 13 has "--warn-stack-size", but let's not do the effort of forwarding
|
||||
// the string to that option, and instead let the user do it himself.
|
||||
cl::opt<unsigned>
|
||||
fWarnStackSize("fwarn-stack-size", cl::ZeroOrMore, cl::init(UINT_MAX),
|
||||
cl::desc("Warn for stack size bigger than the given number"),
|
||||
cl::value_desc("threshold"));
|
||||
#endif
|
||||
|
||||
#if LDC_LLVM_SUPPORTED_TARGET_SPIRV || LDC_LLVM_SUPPORTED_TARGET_NVPTX
|
||||
cl::list<std::string>
|
||||
dcomputeTargets("mdcompute-targets", cl::CommaSeparated,
|
||||
|
|
|
@ -132,6 +132,11 @@ inline bool isUsingLTO() { return ltoMode != LTO_None; }
|
|||
inline bool isUsingThinLTO() { return ltoMode == LTO_Thin; }
|
||||
|
||||
extern cl::opt<std::string> saveOptimizationRecord;
|
||||
|
||||
#if LDC_LLVM_VER >= 1300
|
||||
extern cl::opt<unsigned> fWarnStackSize;
|
||||
#endif
|
||||
|
||||
#if LDC_LLVM_SUPPORTED_TARGET_SPIRV || LDC_LLVM_SUPPORTED_TARGET_NVPTX
|
||||
extern cl::list<std::string> dcomputeTargets;
|
||||
extern cl::opt<std::string> dcomputeFilePrefix;
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "gen/runtime.h"
|
||||
#include "gen/scope_exit.h"
|
||||
#include "gen/tollvm.h"
|
||||
#include "gen/to_string.h"
|
||||
#include "gen/uda.h"
|
||||
#include "ir/irdsymbol.h"
|
||||
#include "ir/irfunction.h"
|
||||
|
@ -702,6 +703,15 @@ void DtoDeclareFunction(FuncDeclaration *fdecl, const bool willDefine) {
|
|||
if (f->next->toBasetype()->ty == TY::Tnoreturn) {
|
||||
func->addFnAttr(LLAttribute::NoReturn);
|
||||
}
|
||||
#if LDC_LLVM_VER >= 1300
|
||||
if (opts::fWarnStackSize.getNumOccurrences() > 0 &&
|
||||
opts::fWarnStackSize < UINT_MAX) {
|
||||
// Cache the int->string conversion result.
|
||||
static std::string thresholdString = ldc::to_string(opts::fWarnStackSize);
|
||||
|
||||
func->addFnAttr("warn-stack-size", thresholdString);
|
||||
}
|
||||
#endif
|
||||
|
||||
applyFuncDeclUDAs(fdecl, irFunc);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue