LLVM Lowering: support for `cir.delete.array`
The following code fails to compile, which is reduced from libcxx code.
int *newmem();
struct cls {
~cls();
};
cls::~cls() { delete[] newmem(); }
error failed to legalize operation 'cir.delete.array' that was explicitly marked illegal
It is because we do not have a lowering prep implementation for cir.delelte.array, once we have it, we should be able to compile this. Not sure for this simple case, array cookie info is needed, but in general, it is needed for ABI lowering cir.delelte.array.
Create this issue so that we can track implementation as it would help ClangIR build libcxx
@ChuanqiXu9, keep you in the loop as you introduced cir.delelte.array in https://github.com/llvm/clangir/pull/1172, I understand that you guys don't need it to be lowered for analysis purpose, but you might be interested if someone in community picks it up.
@bcardosolopes assign me please
@elhewaty Assigned to you.
@elhewaty if this is your first contribution I recommend something a bit easier, but happy to review regardless. FWIW, @andykaylor is working on a similar issue https://github.com/llvm/clangir/pull/1286 here.
@bcardosolopes, please recommend easier ones if possible, and I can delay this for later.
@elhewaty any bug marked with good-first-issue should be good: https://github.com/llvm/clangir/issues?q=is%3Aissue%20is%3Aopen%20label%3A%22good%20first%20issue%22%20
One specific example: https://github.com/llvm/clangir/issues/589
I wouldn't be worried about people claiming the issues, if there hasn't been an update in a while (maybe more than a week?) they might not ever work on it anyways (from my experience so far), just post a comment that you are working on it and I'll assign it to you too.
I am interested in this one, should I be using /clang/lib/CodeGen/CGExprCXX.cpp as reference here?
failed to legalize operation 'cir.delete.array' that was explicitly marked illegal
What did you invoke to get this error? @ghehg
What did you invoke to get this error?
Trying to lower to LLVM will give you that. If you add an extra RUN line to clang/test/CIR/CodeGen/delete-array.cpp that does -emit-llvm instead of -emit-cir you'll gonna be able to repro
@bcardosolopes, I made an initial attempt to implement this. Would you please take a look and let me know if I am on the right track.