[llvm] [BOLT] Add support for safe-icf (PR #116275)

Alexander Yermolovich via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 5 11:48:57 PST 2024


ayermolo wrote:

> > Scanning .rela.rodata I think will add things like class destructors to skip list even thought they are safe to ICF.
> > Should the user have an option to disable check of this section?
> 
> Which class destructors are included in .rodata?

g++ produces it for virtual destructors:
Basic example:

```
static int x = 5; // global variable with constructor
class MyClass {
public:
    MyClass() { MY_PRINTF("MyClass constructor\n"); }
    virtual ~MyClass() { MY_PRINTF("MyClass destructor\n"); }
};
MyClass myObject; // global object with constructor
int main() {
    MY_PRINTF("Hello, world!\n");
    return 0;
}
```

```
Relocation section '.rela.rodata' at offset 0x4eb0 contains 5 entries:
    Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
0000000000402048  0000004700000001 R_X86_64_64            0000000000402060 _ZTI7MyClass + 0
0000000000402050  0000003d00000001 R_X86_64_64            0000000000401226 _ZN7MyClassD1Ev + 0
0000000000402058  0000004000000001 R_X86_64_64            000000000040124c _ZN7MyClassD0Ev + 0
0000000000402060  0000004400000001 R_X86_64_64            0000000000403d90 _ZTVN10__cxxabiv117__class_type_infoE at CXXABI_1.3 + 10
0000000000402068  0000005a00000001 R_X86_64_64            0000000000402070 _ZTS7MyClass + 0
```


https://github.com/llvm/llvm-project/pull/116275


More information about the llvm-commits mailing list