[ELF] resolve LazySymbol: remove a branch in the fast path

This commit is contained in:
Fangrui Song
2024-12-01 23:07:38 -08:00
parent 0a44b24d66
commit d9d656edd4

View File

@@ -619,20 +619,18 @@ void Symbol::resolve(Ctx &ctx, const LazySymbol &other) {
return;
}
// For common objects, we want to look for global or weak definitions that
// should be extracted as the canonical definition instead.
if (LLVM_UNLIKELY(isCommon()) && ctx.arg.fortranCommon &&
other.file->shouldExtractForCommon(getName())) {
ctx.backwardReferences.erase(this);
other.overwrite(*this);
other.extract(ctx);
return;
}
if (!isUndefined()) {
// See the comment in resolveUndefined().
if (isDefined())
if (LLVM_UNLIKELY(!isUndefined())) {
// See the comment in resolve(Ctx &, const Undefined &).
if (isDefined()) {
ctx.backwardReferences.erase(this);
} else if (isCommon() && ctx.arg.fortranCommon &&
other.file->shouldExtractForCommon(getName())) {
// For common objects, we want to look for global or weak definitions that
// should be extracted as the canonical definition instead.
ctx.backwardReferences.erase(this);
other.overwrite(*this);
other.extract(ctx);
}
return;
}