When the function has musttail call - its cc is fixed to be equal to the
cc of the musttail callee. In such case (and in the case of the musttail
callee), GlobalOpt should not change the cc to fastcc as it will break
the invariant.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Won't this interfere with tail call optimization? From the language manual, I understood it only to be supported for fastcc. (+ the ghc and HiPE calling conventions, which are already not considered here) If we can change the CC of the whole chain, the invariant would still hold. Would that be a valid alternative?
PS: Please upload full context diffs next time :-)
lib/Transforms/IPO/GlobalOpt.cpp | ||
---|---|---|
2137 ↗ | (On Diff #136228) | Wouldn't it be cheaper to check the CC first, do an early return and only check for musttail calls/callees later? |
Address inline comments.
As far as I can see it, the documentation doesn't say anything about musttail in particular. It says that tail calls require fastcc to be optimized, but even this seems to be rather stale.
Changing CC for the whole chain is totally a valid alternative. Would it make sense to you if I'll add a FIXME comment there?
Added FIXME, as requested.
I'd appreciate if you could land this for me, as I don't have the commit bit yet.
The test case seems to fail for me locally. Can you see if you can reproduce this?
******************** TEST 'LLVM :: Transforms/GlobalOpt/musttail_cc.ll' FAILED ******************** Script: -- /Users/jonas/llvm/git-svn/build/bin/opt < /Users/jonas/llvm/git-svn/llvm/test/Transforms/GlobalOpt/musttail_cc.ll -globalopt -S | /Users/jonas/llvm/git-svn/build/bin/FileCheck /Users/jonas/llvm/git-svn/llvm/test/Transforms/GlobalOpt/musttail_cc.ll -- Exit Code: 1 Command Output (stderr): -- /Users/jonas/llvm/git-svn/llvm/test/Transforms/GlobalOpt/musttail_cc.ll:31:16: error: expected string not found in input ; CHECK-LABEL: define internal i32 @foo2(i32 %a) ^ <stdin>:18:35: note: scanning from here define internal i32 @foo1(i32 %a) unnamed_addr { ^ <stdin>:19:11: note: possible intended match here %ca = musttail call i32 @foo2(i32 %a) ^ --
Fix test.
Sorry, looks like I forgot to add internal to the foo2 (or removed it by mistake when rebasing).