[PATCH] D83366: [MC] Simplify the logic of applying fixup for fragments, NFCI

Kan Shengchen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 7 22:52:40 PDT 2020


skan added a comment.

In D83366#2138210 <https://reviews.llvm.org/D83366#2138210>, @MaskRay wrote:

> This is: if else if else if -> switch. I think it is just a refactoring and I agree that it is the right thing to do, but I don't find complexity being simplified.


In addition to if else -> switch. The simplified thing is that we don't need to check `isa<MCEncodedFragment>(&Frag)` in the new code.
In the old code,  if we want to add a new kind of fragment that inherits from `MCEncodedFragment` but is not a `MCEncodedFragmentWithFixups`, we have to add `if(!isa<MCxxxFragment>(Frag) continue)` here to avoid reaching "llvm_unreachable("Unknown fragment with fixups!")", it doesn't make sense since the new fragment has nothing to do with fixup.

We only need to process `MCAlignFragment` and `MCEncodedFragmentWithFixups` here, so


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83366/new/

https://reviews.llvm.org/D83366





More information about the llvm-commits mailing list