(This patch will cause some inline_asm test check failed, let first discuss the corretness of this patch, then I'll decide modify the related tests or not. )
Currently Clang generate "function call in inline asm" with indirect address access "*m"
but the call instruction directly use the address of the function not the context in the address.
So I think we should change the address constrain from "*m" to 'm'
For example : (use Clang -fams-blocks -fpic -S -emit-llvm inline_asm_blocks_call.c to reproduce)
__asm{ call sincos_asm \n ret };
without this patch, the clang will generate follow IR:
call void asm sideeffect inteldialect "call qword ptr ${0:P}\0A\09ret", "*m,~{dirflag},~{fpsr},~{flags}"(void (...)* @sincos_asm) ^ indirectly access the call op of "void (...)* @sincos_asm" but for call, it directly read the point "void (...)* @sincos_asm"
So then the back end generate follow wrong asm for it:
movq sincos_asm@GOTPCREL(%rip), %rax #APP callq *(%rax) # we should directly read the function address in register %rax not mem (%rax) -- should be --> callq *%rax retq #NO_APP
Can we only handle for MS inline asm? Maybe need an bool type which passed from EmitAsmStmt: