[llvm] [NFC] Reduce copies created of ConstantRange when getting ConstantRangeAttributes. (PR #90335)

Andreas Jonson via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 28 03:29:46 PDT 2024


andjo403 wrote:

hmm maybe this is not the solution that we want. have today been looking at how to handle the ConstantRangeAttributes in the c api and have not found any good solution for how to set and get the range and the allocation of the ConstantRange is the hardest thing.

my initial ide was to have something like
```
LLVMConstantRangeRef LLVMCreateConstantRange(LLVMContextRef C, LLVMValueRef Lower,
                                             LLVMValueRef Upper);
LLVMAttributeRef LLVMCreateConstantRangeAttribute(LLVMContextRef C,
                                                  unsigned KindID,
                                                  LLVMConstantRangeRef CR);
LLVMConstantRangeRef LLVMGetConstantRangeAttributeValue(LLVMAttributeRef A);
```
but I can not find any place to allocate the ConstantRange in LLVMCreateConstantRange.

Started to think that we maybe only shall have a pointer to the ConstantRange in the attribute same as the type attributes and have a ConstantRange allocator in the context instead of a ConstantRangeAttributeImpl that we have now.

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


More information about the llvm-commits mailing list