[PATCH] D153063: [BOLT] Check if the symbol is not weak in simplify-rodata-loads
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 15 12:05:58 PDT 2023
Amir created this revision.
Amir added a reviewer: bolt.
Herald added a reviewer: rafauler.
Herald added subscribers: treapster, ayermolo.
Herald added a reviewer: maksfb.
Herald added a project: All.
Amir requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.
Weak symbols are typically zero. Don't use them in simplification.
Follow-up to D152944 <https://reviews.llvm.org/D152944>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D153063
Files:
bolt/include/bolt/Core/BinaryData.h
bolt/lib/Core/BinaryData.cpp
bolt/lib/Passes/BinaryPasses.cpp
Index: bolt/lib/Passes/BinaryPasses.cpp
===================================================================
--- bolt/lib/Passes/BinaryPasses.cpp
+++ bolt/lib/Passes/BinaryPasses.cpp
@@ -1159,7 +1159,7 @@
// Look up the symbol address in the global symbols map of the binary
// context object.
BinaryData *BD = BC.getBinaryDataByName(DisplSymbol->getName());
- if (!BD)
+ if (!BD || BD->isWeak())
continue;
TargetAddress = BD->getAddress() + DisplOffset;
} else if (!MIB->evaluateMemOperandTarget(Inst, TargetAddress)) {
Index: bolt/lib/Core/BinaryData.cpp
===================================================================
--- bolt/lib/Core/BinaryData.cpp
+++ bolt/lib/Core/BinaryData.cpp
@@ -32,6 +32,8 @@
bool BinaryData::isAbsolute() const { return Flags & SymbolRef::SF_Absolute; }
+bool BinaryData::isWeak() const { return Flags & SymbolRef::SF_Weak; }
+
bool BinaryData::isMoveable() const {
return (!isAbsolute() && (IsMoveable && (!Parent || isTopLevelJumpTable())));
}
Index: bolt/include/bolt/Core/BinaryData.h
===================================================================
--- bolt/include/bolt/Core/BinaryData.h
+++ bolt/include/bolt/Core/BinaryData.h
@@ -117,6 +117,7 @@
bool isAbsolute() const;
bool isMoveable() const;
+ bool isWeak() const;
uint64_t getAddress() const { return Address; }
uint64_t getEndAddress() const { return Address + Size; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153063.531862.patch
Type: text/x-patch
Size: 1464 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230615/a399204f/attachment.bin>
More information about the llvm-commits
mailing list