mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-10-31 08:16:47 +00:00 
			
		
		
		
	TargetData to find the pointer size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79490 91177308-0d34-0410-b5e6-96231b3b80d8
		
			
				
	
	
		
			27 lines
		
	
	
		
			991 B
		
	
	
	
		
			LLVM
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			991 B
		
	
	
	
		
			LLVM
		
	
	
	
	
	
| ; Test that the StrChrOptimizer works correctly
 | |
| ; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
 | |
| ; RUN:   not grep {call.*@strchr}
 | |
| 
 | |
| ; This transformation requires the pointer size, as it assumes that size_t is
 | |
| ; the size of a pointer.
 | |
| target datalayout = "-p:64:64:64"
 | |
| 
 | |
| @hello = constant [14 x i8] c"hello world\5Cn\00"		; <[14 x i8]*> [#uses=1]
 | |
| @null = constant [1 x i8] zeroinitializer		; <[1 x i8]*> [#uses=1]
 | |
| 
 | |
| declare i8* @strchr(i8*, i32)
 | |
| 
 | |
| declare i32 @puts(i8*)
 | |
| 
 | |
| define i32 @main() {
 | |
| 	%hello_p = getelementptr [14 x i8]* @hello, i32 0, i32 0		; <i8*> [#uses=2]
 | |
| 	%null_p = getelementptr [1 x i8]* @null, i32 0, i32 0		; <i8*> [#uses=1]
 | |
| 	%world = call i8* @strchr( i8* %hello_p, i32 119 )		; <i8*> [#uses=1]
 | |
| 	%ignore = call i8* @strchr( i8* %null_p, i32 119 )		; <i8*> [#uses=0]
 | |
| 	%len = call i32 @puts( i8* %world )		; <i32> [#uses=1]
 | |
| 	%index = add i32 %len, 112		; <i32> [#uses=2]
 | |
| 	%result = call i8* @strchr( i8* %hello_p, i32 %index )		; <i8*> [#uses=0]
 | |
| 	ret i32 %index
 | |
| }
 | |
| 
 |