[LLVMdev] clang branching using label

ckathy clcheng at stanford.edu
Mon Jan 23 15:58:12 PST 2012


Hi,

Clang normally generates code that looks like 

....
; <label>:22                                      ; preds = %0
  %23 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([24 x i8]*
@.str, i32 0, i32 0))
  br label %24

; <label>:24                                      ; preds = %22, %0
  %25 = load i32* %tmphigh, align 4
  %26 = and i32 %25, 65535
  store i32 %26, i32* %high1, align 4
.....


If I insert some instructions before %25 so it will look like:
....
; <label>:22                                      ; preds = %0
  %23 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([24 x i8]*
@.str, i32 0, i32 0))
  br label %24

; <label>:24 
  %var = add i32 %7,   0          ; for testing                      
  %25 = load i32* %tmphigh, align 4
  %26 = and i32 %25, 65535
  store i32 %26, i32* %high1, align 4
..... 

Will %var get evaluated or it will be skipped?
How does the branching work since the label is commented out? Does it assume
%24 is the nop before %25?

How about the following case where a variable assignment does not occur?

....
  %37 = icmp sle i32 %33, %36
  br i1 %37, label %38, label %217

;38:
  store i32 0, i32* %j, align 4
  br label %39

..... 
which is changed to 

......
  %37 = icmp sle i32 %33, %36
  br i1 %37, label %38, label %217

;38:
  store i32 0, i32* %p, align 4
  store i32 0, i32* %j, align 4
  br label %39
..... 

Will both store instructions get executed?
Does the empty line before the commented out label number have any real
function?


Thanks,

Chris


-- 
View this message in context: http://old.nabble.com/clang-branching-using-label-tp33192112p33192112.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.




More information about the llvm-dev mailing list