[llvm] [BOLT] Avoid reference updates for non-JT symbol operands (PR #88838)
Maksim Panchenko via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 18 10:50:50 PDT 2024
maksfb wrote:
Thanks for the context. It's interesting how you hit a corner case where the pass does the exact opposite of what it's supposed to do. I.e it fetches a symbol at `TargetAddress - 1` which happens to be a jump table symbol and uses it instead of the original non-jump table symbol.
Instead of verifying if the symbol `Sym` matches the first label of the jump table, I suggest we detect the jump table at the address of the symbol. I.e.:
```
JumpTable *JT = BC.getJumpTableContainingAddress(BD->getAddress());
```
This way, we are also making sure the symbol will not collide with other symbols registered at the same address. Then you'll also have to adjust the way the new object is created:
```
MCSymbol *NewSym = BC.getOrCreateGlobalSymbol(BD->getAddress() - 1, "DATAat");
BC.MIB->
setOperandToSymbolRef(Inst, OperandNum, NewSym, Offset + 1, &*BC.Ctx, 0);
```
https://github.com/llvm/llvm-project/pull/88838
More information about the llvm-commits
mailing list