[llvm] Make `IntrinsicLowering` external function call lowering configurable (PR #102148)

Jannik Silvanus via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 8 00:50:02 PDT 2024


https://github.com/jasilvanus commented:

Thanks for working on this.

Apparently LLVM has an interface to query support for library functions which `IntrinsicLowering` seems to be ignoring, see `canEmitLibcall` in `PreISelIntrinsicLowering.cpp` (which is another place working on intrinsic lowering). I don't know whether that is intentional, or whether we should use that here. (Also, it's unclear how much effort it would be to enable that in our downstream usage.)

In general, I'm not sure how the intrinsic lowering infrastructure is supposed to be used. For instance, in case the target doesn't support `memcpy`, `PreISelIntrinsicLowering` seems to emit explicit mem copy loops (using `LowerMemIntrinsics.cpp`), while always emit a library call here. 

In case we did not lower an intrinsic because it would have required an unsupported library call, we shouldn't silently ignore the intrinsic, and instead make it apparent that we failed.

This could be done via a return value, or by failing with `report_fatal_error`. In isolation, I'd prefer that former, so the caller can decide what to do, but we are already failing with `report_fatal_error` for unsupported intrinsics (see the `default` case), so it would be consistent to do the same here.

We should add a test, but I guess the way we want to test this depends on how we implement the above, so I'm fine with doing that first.

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


More information about the llvm-commits mailing list