Skip to content

ELF: Remove lock from MTE global relocation handling code. #135123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

pcc
Copy link
Contributor

@pcc pcc commented Apr 10, 2025

This lock is unnecessary because we can add the relocations to
shards and let them be sorted later.

pcc added 2 commits April 9, 2025 20:18
Created using spr 1.3.6-beta.1

[skip ci]
Created using spr 1.3.6-beta.1
@llvmbot
Copy link
Member

llvmbot commented Apr 10, 2025

@llvm/pr-subscribers-lld

Author: Peter Collingbourne (pcc)

Changes

This lock is unnecessary because we can add the relocations to
shards and let them be sorted later.


Full diff: https://github.com/llvm/llvm-project/pull/135123.diff

1 Files Affected:

  • (modified) lld/ELF/Relocations.cpp (+2-3)
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 81de664fd1c23..277acb26987bc 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -847,9 +847,8 @@ static void addRelativeReloc(Ctx &ctx, InputSectionBase &isec,
   Partition &part = isec.getPartition(ctx);
 
   if (sym.isTagged()) {
-    std::lock_guard<std::mutex> lock(ctx.relocMutex);
-    part.relaDyn->addRelativeReloc(ctx.target->relativeRel, isec, offsetInSec,
-                                   sym, addend, type, expr);
+    part.relaDyn->addRelativeReloc<shard>(ctx.target->relativeRel, isec,
+                                          offsetInSec, sym, addend, type, expr);
     // With MTE globals, we always want to derive the address tag by `ldg`-ing
     // the symbol. When we have a RELATIVE relocation though, we no longer have
     // a reference to the symbol. Because of this, when we have an addend that

@llvmbot
Copy link
Member

llvmbot commented Apr 10, 2025

@llvm/pr-subscribers-lld-elf

Author: Peter Collingbourne (pcc)

Changes

This lock is unnecessary because we can add the relocations to
shards and let them be sorted later.


Full diff: https://github.com/llvm/llvm-project/pull/135123.diff

1 Files Affected:

  • (modified) lld/ELF/Relocations.cpp (+2-3)
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 81de664fd1c23..277acb26987bc 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -847,9 +847,8 @@ static void addRelativeReloc(Ctx &ctx, InputSectionBase &isec,
   Partition &part = isec.getPartition(ctx);
 
   if (sym.isTagged()) {
-    std::lock_guard<std::mutex> lock(ctx.relocMutex);
-    part.relaDyn->addRelativeReloc(ctx.target->relativeRel, isec, offsetInSec,
-                                   sym, addend, type, expr);
+    part.relaDyn->addRelativeReloc<shard>(ctx.target->relativeRel, isec,
+                                          offsetInSec, sym, addend, type, expr);
     // With MTE globals, we always want to derive the address tag by `ldg`-ing
     // the symbol. When we have a RELATIVE relocation though, we no longer have
     // a reference to the symbol. Because of this, when we have an addend that

@pcc pcc requested review from MaskRay, smithp35 and fmayer April 10, 2025 03:20
pcc added 2 commits April 10, 2025 10:38
Created using spr 1.3.6-beta.1

[skip ci]
Created using spr 1.3.6-beta.1
@pcc pcc changed the base branch from users/pcc/spr/main.elf-remove-lock-from-mte-global-relocation-handling-code to main April 10, 2025 17:38
@pcc pcc merged commit f53eb88 into main Apr 10, 2025
7 of 15 checks passed
@pcc pcc deleted the users/pcc/spr/elf-remove-lock-from-mte-global-relocation-handling-code branch April 10, 2025 17:39
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Apr 10, 2025
This lock is unnecessary because we can add the relocations to
shards and let them be sorted later.

Reviewers: smithp35, fmayer, MaskRay

Reviewed By: MaskRay

Pull Request: llvm/llvm-project#135123
var-const pushed a commit to ldionne/llvm-project that referenced this pull request Apr 17, 2025
This lock is unnecessary because we can add the relocations to
shards and let them be sorted later.

Reviewers: smithp35, fmayer, MaskRay

Reviewed By: MaskRay

Pull Request: llvm#135123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants