This patch fixes PR36885: clang++ generates unaligned stub symbol
holding a pointer.
Details
- Reviewers
• espindola MatzeB
Diff Detail
- Repository
- rL LLVM
- Build Status
Buildable 16571 Build 16571: arc lint + arc unit
Event Timeline
There is a minimized testcase in the bug report: https://bugs.llvm.org/show_bug.cgi?id=36885
I'm not sure which repo the test should be added to (llvm or clang?).
Should the test be generating asm or ll file and check for alignment directive on the stub?
It'll be useful if you can point me to an existing test that does something similar for regular (non-stub) symbols.
Any guidance will be appreciated. This is my first llvm change.
You can add the test in llvm as an ll file. You can generate the ll as:
clang++ a.cpp -emit-llvm -S -o a.ll
Take a look at llvm/test/Object/ARM/symbol-addr.ll as an example to get started.
See also:
https://llvm.org/docs/CommandGuide/llc.html
https://llvm.org/docs/TestingGuide.html
test/Object/X86/align-stub.ll | ||
---|---|---|
1 ↗ | (On Diff #140024) | Please follow 80 char limit. Also -relocation-model=pic instead of --relocation-model=pic. |
2 ↗ | (On Diff #140024) | Remove the extraneous space after RUN: |
80-char line length limit, and use '-relocation-model=pic' instead of '--relocation-model=pic'.
test/Object/X86/align-stub.ll | ||
---|---|---|
2 ↗ | (On Diff #140024) | It's a continuation line now, so should the space stay, or would you like me to remove it? |
Moved EmitAlignment() out of the loop.
Remove '-filetype=obj' from test, checking for
alignment directive in assembly output instead.
test/Object/X86/align-stub.ll | ||
---|---|---|
12 ↗ | (On Diff #140318) | Code change LGTM, but can't you trim the test a bit? For example, why do you need two comdats to test a change on the exception table output? |
test/Object/X86/align-stub.ll | ||
---|---|---|
12 ↗ | (On Diff #140318) | The test file was generated by running "clang++ -fPIE -emit-llvm -S " on the testcase in PR36885. Frankly, it's not the greatest idea that we're adding compiler generated output as tests, instead of the original source which is far more compact and readable. |
test/Object/X86/align-stub.ll | ||
---|---|---|
12 ↗ | (On Diff #140318) | The fix is to reduce the .ll file :-) Simply remove everything you can as long the new file still shows the results you want. You can check https://llvm.org/docs/LangRef.html if you have any questions. You should also use named temporaries. You can do that by passing the .ll to "opt -instnamer". This will give you a testcase that is much simpler to reduce. |
test/Object/X86/align-stub.ll | ||
---|---|---|
12 ↗ | (On Diff #140318) | Probably not what you expected, but I've minimized the testcase aggressively :) |
Awesome :-)
LGTM.
test/CodeGen/X86/catch.ll | ||
---|---|---|
8 | Nit, the p2align is in another line, no? Could you use CHECK-NEXT? |
Thanks for the review.
If everything looks good, can you land it as well.
This is my first change. I don't have write permissions to the repo.
test/CodeGen/X86/catch.ll | ||
---|---|---|
8 | There were multiple .data directives in the original test, and I was trying to match the one preceding p2align. |
Do you need to align in every loop iteration?