File: inline-builtin-asm-name.c

package info (click to toggle)
swiftlang 6.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,604 kB
  • sloc: cpp: 9,901,740; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (32 lines) | stat: -rw-r--r-- 1,203 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -o - %s -disable-llvm-optzns | FileCheck %s

// CHECK: call i32 @"\01_asm_func_name.inline"

// CHECK: declare dso_local i32 @"\01_asm_func_name"(ptr noundef, i32 noundef, ptr noundef, ptr noundef)

// CHECK: define internal i32 @"\01_asm_func_name.inline"

// CHECK: call i32 @__mingw_vsnprintf

// CHECK: declare dso_local i32 @__mingw_vsnprintf

typedef unsigned int size_t;

int __mingw_vsnprintf(char *_DstBuf, size_t _MaxCount, const char *_Format, __builtin_va_list _ArgList);

// For the real use case, "_asm_func_name" is actually "___mingw_vsnprintf", but it's renamed in the testcase for disambiguation.
int vsnprintf(char *__stream, size_t __n, const char *__format, __builtin_va_list __local_argv) __asm__("_asm_func_name");

extern __inline__ __attribute__((__always_inline__, __gnu_inline__))
int vsnprintf(char *__stream, size_t __n, const char *__format, __builtin_va_list __local_argv)
{
  return __mingw_vsnprintf(__stream, __n, __format, __local_argv);
}

void call(const char* fmt, ...) {
  char buf[200];
  __builtin_va_list ap;
  __builtin_va_start(ap, fmt);
  vsnprintf(buf, sizeof(buf), fmt, ap);
  __builtin_va_end(ap);
}