Remove the restrictions that preventing "asm goto" from returning non-void
values. The values returned by "asm goto" are only valid on the "fallthrough"
path.
Details
- Reviewers
jyknight nickdesaulniers hfinkel
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 41138 Build 41313: arc lint + arc unit
Event Timeline
Emit asm goto fallthrough early so that any value extracts will show up in the
fallthrough block and not directly after the callbr.
I think -Wuninitialized (UninitializedValues.cpp) should be taught how to detect the use of output variables in error blocks, at least for trivial cases.
Actually, for some reason -- it looks like the warning is failing the wrong way right now, and emits an uninitialized use warning even where there shouldn't be one.
E.g. this example should be okay:
int foo(int x) { int y; asm goto("# %0 %1 %2" : "=r"(y) : "r"(x) : : err); return y; err: return -1; }
But now warns:
$ clang -Wall -fsyntax-only foo.c foo.c:4:10: warning: variable 'y' is uninitialized when used here [-Wuninitialized] return y; ^ foo.c:2:8: note: initialize the variable 'y' to silence this warning int y; ^ = 0 1 warning generated.
I'd expect a warning only if the code was modified to say "return y" in the err block.
Also, since this means we are no longer simply implementing according to GCC's documentation, I think this means we'll need a brand new section in the Clang docs for its inline-asm support.
Analyze "asm goto" for initialized variables.
An "asm goto" statement is a terminator and thus doesn't indicate variable
assignments like normal inline assembly. Handle them specially.
I did, but the "arc" program pushed the wrong change. :-( Fixed.
When are we going to use GitHub's PRs?
Add blurb about asm goto with output constraints to the "language extensions"
documentation.
clang/lib/Analysis/UninitializedValues.cpp | ||
---|---|---|
831 | this is still not a range based for loop. Does: for (const auto &O : as->outputs()) if (const VarDecl *VD = findVar(O).getDecl()) vals[VD] = Initialized; not work? |
clang/lib/Analysis/UninitializedValues.cpp | ||
---|---|---|
831 | Done. |
clang/test/Analysis/uninit-asm-goto.cpp | ||
---|---|---|
10 | I have a follow-up patch that I'll upload soon that warns about uninitialized variable use on the indirect paths. I wanted to separate it to keep this patch size down. If you'd prefer I can just add it. |