[clang] [compiler-rt] [llvm] [AIX] Implement the ifunc attribute. (PR #153049)

Wael Yehia via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 5 10:57:09 PST 2025


================

----------------
w2yehia wrote:

you're right. Actually, we did an offline code review yesterday and decided to just remove the assert.

Prior to this PR, all platforms (`isOSBinFormatELF` and `isOSBinFormatMachO`) who supported ifunc did their special codegen in one place: a non-virtual function `AsmPrinter::emitGlobalIFunc` (the one we're commenting on now) by doing `if ((isPlatform1)) {...} else { assert(isPlatform2()); ... }` and inside some implementations they called a bunch of virtual functions that are only implemented in the derived class of AsmPrinter corresponding to that implementation (e.g. `emitMachOIFuncStubBody`). 
I thought for AIX, it's cleaner to have it's own implementation of `emitGlobalIFunc`, so I made `emitGlobalIFunc` virtual and overrode it in `PPCAIXAsmPrinter`. Technically, the other platforms can be refactored to use this method but not 100% sure.

An alternative to what I did, is to keep `emitGlobalIFunc` a non-virtual, and then add at the beginning of `AsmPrinter::emitGlobalIFunc`: 
```
if (TM.getTargetTriple().isOSBinFormatXCOFF()) {
  emitGlobalIFuncOnAIX(M, GI);
  return;
}
```
and then define `emitGlobalIFuncOnAIX` as a virtual in AsmPrinter with an implementation that does `assert(false)`, and override it in `PPCAIXAsmPrinter` with an implementation equivalent to what I have now in `PPCAIXAsmPrinter::emitGlobalIFunc`.

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


More information about the llvm-commits mailing list