[LLVMdev] Reproducible testcase for r100044

José Fonseca jfonseca at vmware.com
Tue Oct 26 12:03:01 PDT 2010


Attached is a .ll with a reproducible test case for the bug addressed by r100044  -- "Fix a nasty dangling-pointer heisenbug that could generate wrong code pretty much anywhere AFAICT."

Doing 

  llvm-as < sunkaddr.ll | llc

which a llc after r100044 will generate


.LBB1_2:                                                    # %if-false-block
	movl	$1, 16(%rdi)
	movl	120(%rdi), %eax
	ret

while one before will generate:

.LBB1_2:                                                    # %if-false-block
	movl	$1, 16(%rdi)
	movl	$1, %eax
	ret

There are some FileCheck directives to verify this.

There is also a main function which will print (and return an exit code)
of 0 on success, and 1 on failure.

Jose
-------------- next part --------------
; RUN: llvm-as < %s | llc -march=x86-64 | FileCheck %s
; r100044

%texture = type { i32, i32, i32, i32, [13 x i32], [13 x i32], [13 x i32] }

define i32 @fs5_variant0_whole(%texture* noalias %texture, i32 %lod) noinline {
entry:
  %texture.row_stride = getelementptr %texture* %texture, i32 0, i32 4
  %texture.data_ptr = getelementptr %texture* %texture, i32 0, i32 6
  %x140 = icmp sge i32 %lod, 0
  br i1 %x140, label %if-true-block, label %if-false-block

if-true-block:
  ret i32 0

if-false-block:

  ; Commenting the following two lines will avoid the bug
  %x198 = getelementptr [13 x i32]* %texture.row_stride, i32 0, i32 0
  store i32 1, i32* %x198

  %x204 = getelementptr [13 x i32]* %texture.data_ptr, i32 0, i32 0
  %x205 = load i32* %x204
  ret i32 %x205
  ; CHECK: # %if-false-block
  ; CHECK-NEXT: movl $1, 16([[REGISTER:%[a-z]+]])
  ; CHECK-NEXT: movl 120([[REGISTER]]), %eax
  ; CHECK-NEXT: ret
}

;; Optional main function, to used with bugpoint
;
;declare i32 @printf(i8*, ...)
;
;@fmt_str = internal constant [10 x i8] c"ret = %d\0A\00"
;
;define i32 @main(i32 %argc.1, i8** %argv.1) {
;  %texture = alloca %texture
;  store %texture zeroinitializer, %texture* %texture
;  %ret = call i32 @fs5_variant0_whole(%texture* %texture, i32 -1)
;  %fmt_str = getelementptr [10 x i8]* @fmt_str, i64 0, i64 0
;  call i32 (i8*, ...)* @printf(i8* %fmt_str, i32 %ret)
;  ret i32 %ret
;}


More information about the llvm-dev mailing list