[clang] [clang] Better bitfield access units (PR #65742)
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 23 11:02:23 PST 2024
rjmccall 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.
Yeah, LLVM supports changing subtarget options on a per-function basis. We would presumably make the query based on the global setting.
Anyway, getting this information from LLVM doesn't seem tractable in the short-to-medium term; it's just unfortunate.
https://github.com/llvm/llvm-project/pull/65742
More information about the cfe-commits
mailing list