[clang] [clang] Better bitfield access units (PR #65742)

Nathan Sidwell via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 23 01:07:57 PST 2024


urnathan wrote:

> On the target hook, it's a shame we can't easily get this information from LLVM. I believe it's already there — `TargetLowering` has an `allowsMisalignedMemoryAccesses` method that includes some approximation of how fast a particular access would be. In practice, it seems to be quite complex and often specific to the type and subtarget. Maybe it'd be worth starting a conversation with LLVM folks to see if this could reasonably be lifted somewhere we could use it?

Agreed, I did look at that, and AFAICT the allowsMisalignedMemoryAccess is a property of the llvm subtarget, which can, IIUC, change on a per-function basis? One at least needs a function codegen context around? And, clang needs to generate the llvm-structure in non-function contexts (eg namespace-scope variables). I'd really like to not tangle this particular change with a complex reorg.  

I had a discourse thread at, https://discourse.llvm.org/t/targetinfo-for-unaligned-load-capability/72832 about such a target hook.

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


More information about the cfe-commits mailing list