From 954ec09aed4f2be04bb5f4e10dbb4ea8bd19ef9a Mon Sep 17 00:00:00 2001 From: Jennifer Yu Date: Thu, 30 May 2019 01:05:46 +0000 Subject: clang support gnu asm goto. Syntax: asm [volatile] goto ( AssemblerTemplate : : InputOperands : Clobbers : GotoLabels) https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html New llvm IR is "callbr" for inline asm goto instead "call" for inline asm For: asm goto("testl %0, %0; jne %l1;" :: "r"(cond)::label_true, loop); IR: callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,X,X,~{dirflag},~{fpsr},~{flags}"(i32 %0, i8* blockaddress(@foo, %label_true), i8* blockaddress(@foo, %loop)) #1 to label %asm.fallthrough [label %label_true, label %loop], !srcloc !3 asm.fallthrough: Compiler need to generate: 1> a dummy constarint 'X' for each label. 2> an unique fallthrough label for each asm goto stmt " asm.fallthrough%number". Diagnostic 1> duplicate asm operand name are used in output, input and label. 2> goto out of scope. llvm-svn: 362045 --- clang/test/Coverage/c-language-features.inc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'clang/test/Coverage') diff --git a/clang/test/Coverage/c-language-features.inc b/clang/test/Coverage/c-language-features.inc index 356687907d9..ea3b96f6005 100644 --- a/clang/test/Coverage/c-language-features.inc +++ b/clang/test/Coverage/c-language-features.inc @@ -71,7 +71,9 @@ theif: } asm ("nop"); - + int cond; + asm goto("testl %0, %0; jne %l1;" :: "r"(cond)::label_true); +label_true: return; } -- cgit v1.2.3