[PATCH] Provide the name for labels inside MS asm blocks to clang as the branch targets for each asm block

Reid Kleckner rnk at google.com
Mon Sep 29 13:35:40 PDT 2014

>>! In D5515#5, @ehsan wrote:
> Well, LookupInlineAsmLabel would not be able to associate a label name with an MSAsmStmt, which we later on need to use in order to check whether the branch target is defined inside another MSAsmStmt on the clang side.  Also, note that this patch provides two bits of information, the "labels defined" and the "branch targets".  The branch targets cannot be deciphered from LookupInlineAsmLabel, given the fact that you can do things such as `mov eax, LabelName` that are not branches.

I was imagining having ClangAsmParserCallback track a list of defined and used LabelDecls. The 'Create' parameter basically means "this label was defined" and could be renamed to reflect that.

I guess the one thing that is completely lost is the branch information. You only know what uses there are, not if the use is a branch. Is that OK? It means we need to reject this code:
  void g();
  void *f() {
    __asm foo: nop
    __asm mov eax, foo

I guess I'm OK with that. :)


More information about the llvm-commits mailing list