[clang] [llvm] riscv: Support -mstack-protector-guard=tls (PR #108942)

Alexander Richardson via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 17 16:07:20 PDT 2024


================
@@ -3644,13 +3645,28 @@ static void RenderSSPOptions(const Driver &D, const ToolChain &TC,
           << A->getOption().getName() << Value << "sysreg global";
       return;
     }
+    if (EffectiveTriple.isRISCV()) {
+      if (Value != "tls" && Value != "global") {
----------------
arichardson wrote:

Some of these could probably be simplified if we did something like

```
SmallVector<StringRef, 4> SupportedModes;
if (EffectiveTriple.isX86() || EffectiveTriple.isARM() ||         EffectiveTriple.isThumb() || EffectiveTriple.isRISCV()) {
    SupportedModes = {"global", "tls"};
} else if (EffectiveTriple.isAArch64()) {
    SupportedModes = {"global", "sysreg"};
}
if (!llvm::contains(SupportedModes, Value)) {
      D.Diag(diag::err_drv_invalid_value_with_suggestion)
          << A->getOption().getName() << Value << "sysreg global";
      return;
}
```

https://github.com/llvm/llvm-project/pull/108942


More information about the cfe-commits mailing list