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

Ehsan Akhgari ehsan.akhgari at gmail.com
Mon Sep 29 13:51:40 PDT 2014

>>! In D5515#6, @rnk wrote:
>>>! 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.

But ClangAsmParserCallback right now doesn't know whether the create vs use happens within the same asm block...  And it is invoked before we even create the corresponding MSAsmStmt, so I'm not sure where it would record this information.  Any pointers?

> 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
>     g();
>     __asm mov eax, foo
>   }
> I guess I'm OK with that. :)

That would be a bit unfortunate, since my current patch properly accepts that code.  But I guess I don't feel very strongly.


More information about the llvm-commits mailing list