diff options
author | Momchil Velikov <momchil.velikov@arm.com> | 2023-11-30 11:18:02 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-30 11:18:02 +0000 |
commit | 092507a730fa4fad6dbe544cd139cfb7e8179aa4 (patch) | |
tree | 30ec63218215c0ff897becfa9357721b9119ac1a /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | c80b91bce3a5a92281ad1c7e090ac25e7a5bd395 (diff) | |
download | llvm-092507a730fa4fad6dbe544cd139cfb7e8179aa4.zip llvm-092507a730fa4fad6dbe544cd139cfb7e8179aa4.tar.gz llvm-092507a730fa4fad6dbe544cd139cfb7e8179aa4.tar.bz2 |
[clang][AArch64] Pass down stack clash protection options to LLVM/Backend (#68993)
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 6cb308e..dea58a7 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1121,6 +1121,15 @@ void CodeGenModule::Release() { "sign-return-address-with-bkey", 1); } + if (CodeGenOpts.StackClashProtector) + getModule().addModuleFlag( + llvm::Module::Override, "probe-stack", + llvm::MDString::get(TheModule.getContext(), "inline-asm")); + + if (CodeGenOpts.StackProbeSize && CodeGenOpts.StackProbeSize != 4096) + getModule().addModuleFlag(llvm::Module::Min, "stack-probe-size", + CodeGenOpts.StackProbeSize); + if (!CodeGenOpts.MemoryProfileOutput.empty()) { llvm::LLVMContext &Ctx = TheModule.getContext(); getModule().addModuleFlag( @@ -2335,6 +2344,10 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, if (CodeGenOpts.StackClashProtector) B.addAttribute("probe-stack", "inline-asm"); + if (CodeGenOpts.StackProbeSize && CodeGenOpts.StackProbeSize != 4096) + B.addAttribute("stack-probe-size", + std::to_string(CodeGenOpts.StackProbeSize)); + if (!hasUnwindExceptions(LangOpts)) B.addAttribute(llvm::Attribute::NoUnwind); |