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

Keith Packard via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 18 18:32:07 PDT 2024


================
@@ -3664,12 +3680,18 @@ static void RenderSSPOptions(const Driver &D, const ToolChain &TC,
           << A->getOption().getName() << Value;
       return;
     }
+    if (EffectiveTriple.isRISCV() && (Offset <= -2048 || Offset >= 2048)) {
----------------
keith-packard wrote:

Yeah, this is used as an offset from the TLS base register (tp). GCC doesn't allow arbitrary offsets for this value, permitting only a value that can be encoded as an immediate value in the load instruction. I mirrored those limits (slightly incorrectly) in my patch. Given that llvm can support arbitrary values as the compiler is happy to use multiple instructions as required, I think it's probably best to just remove this test instead of introducing an artificial limit to match gcc's behavior?

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


More information about the cfe-commits mailing list