fixes issue with emitting partially initialized constant arrays larger than 2^32.
issue #57353 on github.
Details
- Reviewers
mehdi_amini rjmccall efriedma
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
its my first time contributing. this is probably very bad and goes against a lot of guidelines, but I wouldnt resist to fix this
Welcome, and thank you for the patch! I'm going to add a few more reviewers who typically look at codegen changes, but I do have some high-level suggestions. Can you edit the title of the review (there's an "edit revision" link in the upper-right of the review) so that there's a short description of what is being fixed in the title? The title is what most reviewers see in our inbox/review list, so knowing what the patch is about helps reviewers immensely (also, we use the title of the review as the title of the commit message). Also, we ask that all changes to the code base come with test coverage showing what has been fixed, so please add some test coverage (most likely to clang/test/CodeGen/). Finally, we like to add information to our release notes about bug fixes so users know about the improvements, so please add a short release note (to clang/docs/ReleaseNotes.rst).
hello! thank you so much, Ill do that now, thanks! just a question, what are your guidelines when it comes to commit naming/number etc?
hmm, one problem, seems like nor clang and nor gcc can compile the example in the github issue fully, only to assembly. is there something like c -> llir, llir -> asm checks? in the issue, it did succeed to compile to either llir and asm, just not correctly
Thanks, the new title is great! I'm not certain I understand your question, but our full developer policy can be found at: https://llvm.org/docs/DeveloperPolicy.html which may help.
hello again, I added two tests, one for llvm and one for clang. how do I run those specifically so I see I didnt do something wrong?
The short answer is: you can run the check-all to run the LLVM and Clang tests together. For more details, our testing documentation can be found at: https://llvm.org/docs/TestingGuide.html though we also have some details at: https://clang.llvm.org/hacking.html#testing as well.
clang/lib/CodeGen/CGExprConstant.cpp | ||
---|---|---|
1225 | Note that getNumInits() itself is returning "unsigned". (Looks easy to fix, though.) | |
1265 | Need to be careful here: in general, you can't just fill everything with zero. Need to check how getArrayFiller() is lowered. (For example, consider class X; int X::*a[10] = { 0 };.) |
yep @eli.friedman. probably gonna scratch this idea, makes more sense to actually tackle the problem itself, which is that getArrayFiller doesnt return anything. trying to actually get to the problem, but its quite hard, Visit's are thrown everywhere, and I cant really look at the problem. tryEmitPrivateForVarInit is called, and then it calls a Visit, which somehow transfers it to VisitInitListExpr. that thing worked just because it worked around that problem, even if not intentionally. though, I think Im closing in onto the problem
FYI, the "Visit" method comes from the base class StmtVisitor; it just forwards to the relevant method. (For example, if you call "Visit" with an InitListExpr, it calls VisitInitListExpr.)
Yeah. But it's really not clear how it does that, as it gets all the functions from the generated file
hello, solved the issue. it was, quite expectedly, a u64/unsigned problem in parsing, not codegen. no need to refactor this function. I will close this, thanks for the feedback and sorry for the hassle
Note that getNumInits() itself is returning "unsigned". (Looks easy to fix, though.)