diff options
author | Nick Desaulniers <ndesaulniers@google.com> | 2021-06-08 08:22:48 -0700 |
---|---|---|
committer | Nick Desaulniers <ndesaulniers@google.com> | 2021-06-08 08:31:04 -0700 |
commit | 433c8d950cb3a1fa0977355ce0367e8c763a3f13 (patch) | |
tree | 925ab99b1f6fad5aa16b8c40d5297219a7a0fb69 /llvm/lib/IR/Module.cpp | |
parent | c5d56fec502f36a0c994835ca23bc93a6c682d95 (diff) | |
download | llvm-433c8d950cb3a1fa0977355ce0367e8c763a3f13.zip llvm-433c8d950cb3a1fa0977355ce0367e8c763a3f13.tar.gz llvm-433c8d950cb3a1fa0977355ce0367e8c763a3f13.tar.bz2 |
[IR] make -stack-alignment= into a module attr
Similar to D102742, specifying the stack alignment via CodegenOpts means
that this flag gets dropped during LTO, unless the command line is
re-specified as a plugin opt. Instead, encode this information as a
module level attribute so that we don't have to expose this llvm
internal flag when linking the Linux kernel with LTO.
Looks like external dependencies might need a fix:
* https://github.com/llvm-hs/llvm-hs/issues/345
* https://github.com/halide/Halide/issues/6079
Link: https://github.com/ClangBuiltLinux/linux/issues/1377
Reviewed By: tejohnson
Differential Revision: https://reviews.llvm.org/D103048
Diffstat (limited to 'llvm/lib/IR/Module.cpp')
-rw-r--r-- | llvm/lib/IR/Module.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp index eae4e69..9b95550 100644 --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -721,6 +721,17 @@ void Module::setStackProtectorGuardOffset(int Offset) { addModuleFlag(ModFlagBehavior::Error, "stack-protector-guard-offset", Offset); } +unsigned Module::getOverrideStackAlignment() const { + Metadata *MD = getModuleFlag("override-stack-alignment"); + if (auto *CI = mdconst::dyn_extract_or_null<ConstantInt>(MD)) + return CI->getZExtValue(); + return 0; +} + +void Module::setOverrideStackAlignment(unsigned Align) { + addModuleFlag(ModFlagBehavior::Error, "override-stack-alignment", Align); +} + void Module::setSDKVersion(const VersionTuple &V) { SmallVector<unsigned, 3> Entries; Entries.push_back(V.getMajor()); |