; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; Test that the printf library call simplifier works correctly. ; ; RUN: opt < %s -passes=instcombine -S | FileCheck %s target 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-G200" @hello_world = addrspace(200) constant [13 x i8] c"hello world\0A\00" @percent_s = addrspace(200) constant [4 x i8] c"%s\0A\00" declare i32 @printf(ptr addrspace(200) , ...) declare i32 @puts(ptr addrspace(200)) ; Check printf("foo\n") -> puts("foo"). define void @test_simplify1() { ; CHECK-LABEL: @test_simplify1( ; CHECK-NEXT: [[PUTS:%.*]] = call i32 @puts(ptr addrspace(200) @str) ; CHECK-NEXT: ret void ; call i32 (ptr addrspace(200) , ...) @printf(ptr addrspace(200) @hello_world) ret void } ; Check printf("%s\n", str) -> puts(str). define void @test_simplify2() { ; CHECK-LABEL: @test_simplify2( ; CHECK-NEXT: [[PUTS:%.*]] = call i32 @puts(ptr addrspace(200) @hello_world) ; CHECK-NEXT: ret void ; call i32 (ptr addrspace(200) , ...) @printf(ptr addrspace(200) @percent_s, ptr addrspace(200) @hello_world) ret void }