This is an archive of the discontinued LLVM Phabricator instance.

Diagnose jumping from one MS inline assembly block to another.
AbandonedPublic

Authored by ehsan on Sep 28 2014, 6:53 PM.

Details

Reviewers
rnk
Summary

This addresses PR21035. For now, we are unable to represent the
possibility of jumping between asm IR blocks in LLVM, so these kinds of
jumps don't play well with the SSA model. This patch adds a diagnostic
that detect those kinds of jumps, based on the information that the LLVM
side patch exposes from MC.

Note that we currently lose the SourceLocation for the branch statement
and the label definition statement, so the diagnostic is at inline
assembly block granularity. This issue will be addressed in a
follow-up.

Diff Detail

Event Timeline

ehsan updated this revision to Diff 14152.Sep 28 2014, 6:53 PM
ehsan retitled this revision from to Diagnose jumping from one MS inline assembly block to another..
ehsan updated this object.
ehsan edited the test plan for this revision. (Show Details)
ehsan added a reviewer: rnk.
ehsan added a subscriber: Unknown Object (MLST).
rnk added inline comments.Sep 29 2014, 10:51 AM
lib/Sema/JumpDiagnostics.cpp
496

At a high level, I feel like we shouldn't need this map. It basically reinvents the label name lookup that sema is already performing for us.

What if we changed LabelDecl to hold an MSAsmStmt*? Conceptually, we could make TheStmt be a Stmt* and getStmt() could be 'return dyn_cast_or_null<LabelStmt>(TheStmt);'.

ehsan added inline comments.Sep 29 2014, 11:00 AM
lib/Sema/JumpDiagnostics.cpp
496

How do we get the corresponding MSAsmStmt* though? LookupInlineAsmLabel doesn't have access to that information.

rnk added inline comments.Oct 7 2014, 5:09 PM
lib/Sema/JumpDiagnostics.cpp
496

Right, but it could record them in the ClangAsmParserCallback and forward it on to ActOnMSAsmStmt. At that point if there are any label decls that weren't provided by the current asm statement, we can diagnose them.

ehsan abandoned this revision.Oct 8 2014, 8:20 PM

http://reviews.llvm.org/D5694 provides a simpler version of rnk's suggestion.