[llvm] [X86][APX] Fix issues of suppressing APX for relocation (PR #139285)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Sun May 11 20:54:30 PDT 2025
================
@@ -79,11 +78,32 @@ static void suppressEGPRRegClass(MachineFunction &MF, MachineInstr &MI,
MRI->setRegClass(Reg, NewRC);
}
+// Suppress EGPR in operand 0 of uses to avoid APX relocation types emitted. The
+// register in operand 0 of instruction with relocation may be replaced with
+// operand 0 of uses which may be EGPR. That may lead to emit APX relocation
+// types which breaks the backward compatibility with builtin linkers on
+// existing OS. For example, the register in operand 0 of instruction with
+// relocation is used in PHI instruction, and it may be replaced with operand 0
+// of PHI instruction after PHI elimination and Machine Copy Propagation pass.
+static void suppressEGPRRegClassInRegAndUses(MachineRegisterInfo *MRI,
+ MachineInstr &MI,
+ const X86Subtarget &ST,
+ unsigned int OpNum) {
+ suppressEGPRRegClass(MRI, MI, ST, OpNum);
+ Register Reg = MI.getOperand(OpNum).getReg();
+ for (MachineInstr &Use : MRI->use_instructions(Reg)) {
+ const unsigned UseOpNum = 0;
+ if (Use.getOperand(UseOpNum).isReg())
----------------
phoebewang wrote:
It looks like a general problem to me. We have some instructions not promoted to APX encoding, e.g., BSR/BSF. They should have the same problem. @KanRobert is it a design defect or something wrong in some where?
https://github.com/llvm/llvm-project/pull/139285
More information about the llvm-commits
mailing list