xref: /llvm-project/llvm/test/Transforms/InstCombine/osx-names.ll (revision 4ab40eca080965c65802710e39adbb78c4ce7bde)
1; RUN: opt < %s -passes=instcombine -S | FileCheck %s
2; <rdar://problem/9815881>
3; On OSX x86-32, fwrite and fputs aren't called fwrite and fputs.
4; Make sure we use the correct names.
5
6target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32-S128"
7target triple = "i386-apple-macosx10.7.2"
8
9%struct.__sFILE = type { ptr, i32, i32, i16, i16, %struct.__sbuf, i32, ptr, ptr, ptr, ptr, ptr, %struct.__sbuf, ptr, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i64 }
10%struct.__sbuf = type { ptr, i32 }
11%struct.__sFILEX = type opaque
12
13@.str = private unnamed_addr constant [13 x i8] c"Hello world\0A\00", align 1
14@.str2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
15
16define void @test1(ptr %stream) nounwind {
17; CHECK-LABEL: define void @test1(
18; CHECK: call i32 @"fwrite$UNIX2003"
19  %call = tail call i32 (ptr, ptr, ...) @fprintf(ptr %stream, ptr @.str) nounwind
20  ret void
21}
22
23define void @test2(ptr %stream, ptr %str) nounwind ssp {
24; CHECK-LABEL: define void @test2(
25; CHECK: call i32 @"fputs$UNIX2003"
26  %call = tail call i32 (ptr, ptr, ...) @fprintf(ptr %stream, ptr @.str2, ptr %str) nounwind
27  ret void
28}
29
30declare i32 @fprintf(ptr, ptr, ...) nounwind
31