[llvm] ff2e619 - [MC] Remove duplicate getFixupKindInfo calls. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 13:57:39 PDT 2024
Author: Fangrui Song
Date: 2024-08-19T13:57:35-07:00
New Revision: ff2e619dfcd77328812a42d2ba2b11c3ff96f410
URL: https://github.com/llvm/llvm-project/commit/ff2e619dfcd77328812a42d2ba2b11c3ff96f410
DIFF: https://github.com/llvm/llvm-project/commit/ff2e619dfcd77328812a42d2ba2b11c3ff96f410.diff
LOG: [MC] Remove duplicate getFixupKindInfo calls. NFC
Due to 8728e097dfbec3630a1dd907431c0f14274a1ae8
(`std::unique_ptr<MCAsmBackend> Backend`), the compiler doesn't know
that `Backend` will not be modified across function calls.
Added:
Modified:
llvm/lib/MC/MCAssembler.cpp
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index cbeb41f58c99b..55139dae7b1d7 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -167,18 +167,12 @@ bool MCAssembler::evaluateFixup(const MCFixup &Fixup, const MCFragment *DF,
}
}
- assert(getBackendPtr() && "Expected assembler backend");
- bool IsTarget = getBackendPtr()->getFixupKindInfo(Fixup.getKind()).Flags &
- MCFixupKindInfo::FKF_IsTarget;
-
- if (IsTarget)
+ unsigned FixupFlags = getBackend().getFixupKindInfo(Fixup.getKind()).Flags;
+ if (FixupFlags & MCFixupKindInfo::FKF_IsTarget)
return getBackend().evaluateTargetFixup(*this, Fixup, DF, Target, STI,
Value, WasForced);
- unsigned FixupFlags = getBackendPtr()->getFixupKindInfo(Fixup.getKind()).Flags;
- bool IsPCRel = getBackendPtr()->getFixupKindInfo(Fixup.getKind()).Flags &
- MCFixupKindInfo::FKF_IsPCRel;
-
+ bool IsPCRel = FixupFlags & MCFixupKindInfo::FKF_IsPCRel;
bool IsResolved = false;
if (IsPCRel) {
if (Target.getSymB()) {
@@ -213,8 +207,7 @@ bool MCAssembler::evaluateFixup(const MCFixup &Fixup, const MCFragment *DF,
Value -= getSymbolOffset(Sym);
}
- bool ShouldAlignPC = getBackend().getFixupKindInfo(Fixup.getKind()).Flags &
- MCFixupKindInfo::FKF_IsAlignedDownTo32Bits;
+ bool ShouldAlignPC = FixupFlags & MCFixupKindInfo::FKF_IsAlignedDownTo32Bits;
assert((ShouldAlignPC ? IsPCRel : true) &&
"FKF_IsAlignedDownTo32Bits is only allowed on PC-relative fixups!");
More information about the llvm-commits
mailing list