[PATCH] D78952: [LangRef] Describe linkage types, allocation size of declarations for global variables
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 31 01:50:44 PST 2023
nikic added a comment.
Herald added a project: All.
In `getPointerDereferenceableBytes()`, we currently assume that non-extern_weak globals are dereferenceable up to their type store size: https://github.com/llvm/llvm-project/blob/2153544865a9733b06579823814c981f735e4201/llvm/lib/IR/Value.cpp#L907
In `ConstantFoldGetElementPtr()`, we currently assume that GEPs without notional overindexing are inbounds of non-extern_weak globals: https://github.com/llvm/llvm-project/blob/2153544865a9733b06579823814c981f735e4201/llvm/lib/IR/ConstantFold.cpp#L2283 (Note that this code is broken for other reasons, it's missing a pointee type check -- this is why I'm looking into this in the first place.)
In `getObjectSize()` we do check for a definitive initializer: https://github.com/llvm/llvm-project/blob/a6f66d57e1d626a9b676f6e3ec0e084bdca3a934/llvm/lib/Analysis/MemoryBuiltins.cpp#L821
So I wanted to double check what the intended semantics here are. For a global without definitive initializer, do we assume that the global is *at least* as large as the value type, or do we allow it to be smaller? If the latter, then we need to fix our dereferencability assumptions.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D78952/new/
https://reviews.llvm.org/D78952
More information about the llvm-commits
mailing list