[llvm-dev] Understand the meaning of preds = %0

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] Understand the meaning of preds = %0

Shawn Webb via llvm-dev
Hi all,
I have seen in multiple cases that, usually at the beginning of the function. if a BranchInst is encountered the next block might have %0 indicated as predecessor. I think it is a way to say "no predecessors found". Am I correct?

Few examples just for clarifying what I mean:

define noalias %struct.png_struct_def* @png_create_read_struct_2(i8* %user_png_ver, i8* %error_ptr, void (%struct.png_struct_def*, i8*)* %error_fn, void (%struct.png_struct_def*, i8*)* %warn_fn, i8* %mem_ptr, i8* (%struct.png_struct_def*, i64)* %malloc_fn, void (%struct.png_struct_def*, i8*)* %free_fn) #5 {
  %1 = tail call noalias %struct.png_struct_def* @png_create_png_struct(i8* %user_png_ver, i8* %error_ptr, void (%struct.png_struct_def*, i8*)* %error_fn, void (%struct.png_struct_def*, i8*)* %warn_fn, i8* %mem_ptr, i8* (%struct.png_struct_def*, i64)* %malloc_fn, void (%struct.png_struct_def*, i8*)* %free_fn) #15
  %2 = icmp eq %struct.png_struct_def* %1, null
  br i1 %2, label %9, label %3

; <label>:3:                                      ; preds = %0
  %4 = getelementptr inbounds %struct.png_struct_def, %struct.png_struct_def* %1, i64 0, i32 15
...
}

define noalias %struct.png_struct_def* @png_create_read_struct(i8* %user_png_ver, i8* %error_ptr, void (%struct.png_struct_def*, i8*)* %error_fn, void (%struct.png_struct_def*, i8*)* %warn_fn) #5 {
  %1 = tail call noalias %struct.png_struct_def* @png_create_png_struct(i8* %user_png_ver, i8* %error_ptr, void (%struct.png_struct_def*, i8*)* %error_fn, void (%struct.png_struct_def*, i8*)* %warn_fn, i8* null, i8* (%struct.png_struct_def*, i64)* null, void (%struct.png_struct_def*, i8*)* null) #15
  %2 = icmp eq %struct.png_struct_def* %1, null
  br i1 %2, label %png_create_read_struct_2.exit, label %3

; <label>:3:                                      ; preds = %0
  %4 = getelementptr inbounds %struct.png_struct_def, %struct.png_struct_def* %1, i64 0, i32 15
 ...
}

Thanks

_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Understand the meaning of preds = %0

Shawn Webb via llvm-dev
I think %0, in that context, means entry block
So I guess it’s incorrect to say the BB, '<label>3’, has no predecessor

Bekket

On Apr 26, 2019, at 10:49 PM, Alberto Barbaro via llvm-dev <[hidden email]> wrote:

Hi all,
I have seen in multiple cases that, usually at the beginning of the function. if a BranchInst is encountered the next block might have %0 indicated as predecessor. I think it is a way to say "no predecessors found". Am I correct?

Few examples just for clarifying what I mean:

define noalias %struct.png_struct_def* @png_create_read_struct_2(i8* %user_png_ver, i8* %error_ptr, void (%struct.png_struct_def*, i8*)* %error_fn, void (%struct.png_struct_def*, i8*)* %warn_fn, i8* %mem_ptr, i8* (%struct.png_struct_def*, i64)* %malloc_fn, void (%struct.png_struct_def*, i8*)* %free_fn) #5 {
  %1 = tail call noalias %struct.png_struct_def* @png_create_png_struct(i8* %user_png_ver, i8* %error_ptr, void (%struct.png_struct_def*, i8*)* %error_fn, void (%struct.png_struct_def*, i8*)* %warn_fn, i8* %mem_ptr, i8* (%struct.png_struct_def*, i64)* %malloc_fn, void (%struct.png_struct_def*, i8*)* %free_fn) #15
  %2 = icmp eq %struct.png_struct_def* %1, null
  br i1 %2, label %9, label %3

; <label>:3:                                      ; preds = %0
  %4 = getelementptr inbounds %struct.png_struct_def, %struct.png_struct_def* %1, i64 0, i32 15
...
}

define noalias %struct.png_struct_def* @png_create_read_struct(i8* %user_png_ver, i8* %error_ptr, void (%struct.png_struct_def*, i8*)* %error_fn, void (%struct.png_struct_def*, i8*)* %warn_fn) #5 {
  %1 = tail call noalias %struct.png_struct_def* @png_create_png_struct(i8* %user_png_ver, i8* %error_ptr, void (%struct.png_struct_def*, i8*)* %error_fn, void (%struct.png_struct_def*, i8*)* %warn_fn, i8* null, i8* (%struct.png_struct_def*, i64)* null, void (%struct.png_struct_def*, i8*)* null) #15
  %2 = icmp eq %struct.png_struct_def* %1, null
  br i1 %2, label %png_create_read_struct_2.exit, label %3

; <label>:3:                                      ; preds = %0
  %4 = getelementptr inbounds %struct.png_struct_def, %struct.png_struct_def* %1, i64 0, i32 15
 ...
}

Thanks
_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Understand the meaning of preds = %0

Shawn Webb via llvm-dev
Hi Bekket,
yes I think you are right :)

Thanks again
Alberto

Il giorno sab 27 apr 2019 alle ore 07:19 Bekket McClane <[hidden email]> ha scritto:
I think %0, in that context, means entry block
So I guess it’s incorrect to say the BB, '<label>3’, has no predecessor

Bekket

On Apr 26, 2019, at 10:49 PM, Alberto Barbaro via llvm-dev <[hidden email]> wrote:

Hi all,
I have seen in multiple cases that, usually at the beginning of the function. if a BranchInst is encountered the next block might have %0 indicated as predecessor. I think it is a way to say "no predecessors found". Am I correct?

Few examples just for clarifying what I mean:

define noalias %struct.png_struct_def* @png_create_read_struct_2(i8* %user_png_ver, i8* %error_ptr, void (%struct.png_struct_def*, i8*)* %error_fn, void (%struct.png_struct_def*, i8*)* %warn_fn, i8* %mem_ptr, i8* (%struct.png_struct_def*, i64)* %malloc_fn, void (%struct.png_struct_def*, i8*)* %free_fn) #5 {
  %1 = tail call noalias %struct.png_struct_def* @png_create_png_struct(i8* %user_png_ver, i8* %error_ptr, void (%struct.png_struct_def*, i8*)* %error_fn, void (%struct.png_struct_def*, i8*)* %warn_fn, i8* %mem_ptr, i8* (%struct.png_struct_def*, i64)* %malloc_fn, void (%struct.png_struct_def*, i8*)* %free_fn) #15
  %2 = icmp eq %struct.png_struct_def* %1, null
  br i1 %2, label %9, label %3

; <label>:3:                                      ; preds = %0
  %4 = getelementptr inbounds %struct.png_struct_def, %struct.png_struct_def* %1, i64 0, i32 15
...
}

define noalias %struct.png_struct_def* @png_create_read_struct(i8* %user_png_ver, i8* %error_ptr, void (%struct.png_struct_def*, i8*)* %error_fn, void (%struct.png_struct_def*, i8*)* %warn_fn) #5 {
  %1 = tail call noalias %struct.png_struct_def* @png_create_png_struct(i8* %user_png_ver, i8* %error_ptr, void (%struct.png_struct_def*, i8*)* %error_fn, void (%struct.png_struct_def*, i8*)* %warn_fn, i8* null, i8* (%struct.png_struct_def*, i64)* null, void (%struct.png_struct_def*, i8*)* null) #15
  %2 = icmp eq %struct.png_struct_def* %1, null
  br i1 %2, label %png_create_read_struct_2.exit, label %3

; <label>:3:                                      ; preds = %0
  %4 = getelementptr inbounds %struct.png_struct_def, %struct.png_struct_def* %1, i64 0, i32 15
 ...
}

Thanks
_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev