2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s
|
2009-02-21 07:09:27 +08:00
|
|
|
|
2011-02-16 06:23:51 +08:00
|
|
|
// CHECK: @foo
|
2009-02-21 07:09:27 +08:00
|
|
|
|
2009-10-29 00:31:34 +08:00
|
|
|
// Make sure we mangle overloadable, even in C system headers.
|
2009-02-21 07:09:27 +08:00
|
|
|
# 1 "somesystemheader.h" 1 3 4
|
2009-10-29 00:31:34 +08:00
|
|
|
// CHECK: @_Z2f0i
|
2009-02-21 07:09:27 +08:00
|
|
|
void __attribute__((__overloadable__)) f0(int a) {}
|
2009-10-29 00:31:34 +08:00
|
|
|
// CHECK: @_Z2f0l
|
2009-02-21 07:09:27 +08:00
|
|
|
void __attribute__((__overloadable__)) f0(long b) {}
|
2009-03-21 16:24:40 +08:00
|
|
|
|
2017-06-28 05:31:31 +08:00
|
|
|
// Unless it's unmarked.
|
|
|
|
// CHECK: @f0
|
|
|
|
void f0(float b) {}
|
|
|
|
|
2011-02-16 06:23:51 +08:00
|
|
|
// CHECK: @bar
|
2009-03-21 16:24:40 +08:00
|
|
|
|
|
|
|
// These should get merged.
|
|
|
|
void foo() __asm__("bar");
|
|
|
|
void foo2() __asm__("bar");
|
|
|
|
|
|
|
|
int nux __asm__("foo");
|
|
|
|
extern float nux2 __asm__("foo");
|
|
|
|
|
|
|
|
int test() {
|
|
|
|
foo();
|
|
|
|
foo2();
|
|
|
|
|
|
|
|
return nux + nux2;
|
|
|
|
}
|
2009-03-21 17:16:30 +08:00
|
|
|
|
|
|
|
|
|
|
|
// Function becomes a variable.
|
|
|
|
void foo3() __asm__("var");
|
|
|
|
|
|
|
|
void test2() {
|
|
|
|
foo3();
|
|
|
|
}
|
|
|
|
int foo4 __asm__("var") = 4;
|
|
|
|
|
2009-03-21 17:25:43 +08:00
|
|
|
|
|
|
|
// Variable becomes a function
|
|
|
|
extern int foo5 __asm__("var2");
|
|
|
|
|
|
|
|
void test3() {
|
|
|
|
foo5 = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void foo6() __asm__("var2");
|
|
|
|
void foo6() {
|
|
|
|
}
|
2009-04-01 06:37:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int foo7 __asm__("foo7") __attribute__((used));
|
|
|
|
float foo8 __asm__("foo7") = 42;
|
2009-10-29 00:31:34 +08:00
|
|
|
|
|
|
|
// PR4412
|
|
|
|
int func(void);
|
|
|
|
extern int func (void) __asm__ ("FUNC");
|
|
|
|
|
2011-02-16 06:23:51 +08:00
|
|
|
// CHECK: @FUNC
|
2009-10-29 00:31:34 +08:00
|
|
|
int func(void) {
|
|
|
|
return 42;
|
|
|
|
}
|
2010-03-26 15:18:04 +08:00
|
|
|
|
|
|
|
// CHECK: @_Z4foo9Dv4_f
|
|
|
|
typedef __attribute__(( vector_size(16) )) float float4;
|
|
|
|
void __attribute__((__overloadable__)) foo9(float4 f) {}
|
2011-04-06 20:29:09 +08:00
|
|
|
|
|
|
|
// Intrinsic calls.
|
|
|
|
extern int llvm_cas(volatile int*, int, int)
|
|
|
|
__asm__("llvm.atomic.cmp.swap.i32.p0i32");
|
|
|
|
|
|
|
|
int foo10(volatile int* add, int from, int to) {
|
|
|
|
// CHECK: call i32 @llvm.atomic.cmp.swap.i32.p0i32
|
|
|
|
return llvm_cas(add, from, to);
|
|
|
|
}
|