aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Module.cpp
diff options
context:
space:
mode:
authorNick Desaulniers <ndesaulniers@google.com>2021-06-10 16:03:14 -0700
committerNick Desaulniers <ndesaulniers@google.com>2021-06-10 16:15:27 -0700
commitfc018ebb608ee0c1239b405460e49f1835ab6175 (patch)
tree65006b30f9612228e5508df56f7e48af457df81e /llvm/lib/IR/Module.cpp
parent189428c8fc2465c25efbf4f0bb73e26fecf150ce (diff)
downloadllvm-fc018ebb608ee0c1239b405460e49f1835ab6175.zip
llvm-fc018ebb608ee0c1239b405460e49f1835ab6175.tar.gz
llvm-fc018ebb608ee0c1239b405460e49f1835ab6175.tar.bz2
[IR] make -warn-frame-size into a module attr
-Wframe-larger-than= is an interesting warning; we can't know the frame size until PrologueEpilogueInsertion (PEI); very late in the compilation pipeline. -Wframe-larger-than= was propagated through CC1 as an -mllvm flag, then was a cl::opt in LLVM's PEI pass; this meant it was dropped during LTO and needed to be re-specified via -plugin-opt. Instead, make it part of the IR proper as a module level attribute, similar to D103048. Introduce -fwarn-stack-size CC1 option. Reviewed By: rsmith, qcolombet Differential Revision: https://reviews.llvm.org/D103928
Diffstat (limited to 'llvm/lib/IR/Module.cpp')
-rw-r--r--llvm/lib/IR/Module.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index 9b95550..40d3401 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -732,6 +732,17 @@ void Module::setOverrideStackAlignment(unsigned Align) {
addModuleFlag(ModFlagBehavior::Error, "override-stack-alignment", Align);
}
+unsigned Module::getWarnStackSize() const {
+ Metadata *MD = getModuleFlag("warn-stack-size");
+ if (auto *CI = mdconst::dyn_extract_or_null<ConstantInt>(MD))
+ return CI->getZExtValue();
+ return UINT_MAX;
+}
+
+void Module::setWarnStackSize(unsigned Threshold) {
+ addModuleFlag(ModFlagBehavior::Error, "warn-stack-size", Threshold);
+}
+
void Module::setSDKVersion(const VersionTuple &V) {
SmallVector<unsigned, 3> Entries;
Entries.push_back(V.getMajor());