llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.13k stars 12.01k forks source link

[LLD] [X86_64] Adjust symbol value/size after optimize basic block jump #110095

Open ywgrit opened 1 month ago

ywgrit commented 1 month ago

After basic block jump optimization on X86_64, symbol size may need to be adjusted. Is the def->value <= OldSize should be def->value <= NewSize?

static void fixSymbolsAfterShrinking() { 
   // ... 
   if (def->value + def->size > NewSize && def->value <= OldSize &&
          def->value + def->size <= OldSize) {
        LLVM_DEBUG(llvm::dbgs()
                   << "Shrinking symbol " << Sym->getName() << " from "
                   << def->size << " to " << def->size - inputSec->bytesDropped
                   << " bytes\n");
        def->size -= inputSec->bytesDropped;
   }
   //...
}
ywgrit commented 1 month ago

@MaskRay @MQ-mengqing

MaskRay commented 1 month ago

IIUI The x86 basic block feature has not ever been utilized after it landed. There could be issues that never get sorted out.

It probably should use Arch/RISCV.cpp style st_value/st_size adjustment. https://reviews.llvm.org/D127581

I am inclined to remove the code, but I am happy to accept it when it actually gets used and properly tested.

@tmsri