-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Labels
debuginfollvm:GVNGVN and NewGVN stages (Global value numbering)GVN and NewGVN stages (Global value numbering)
Description
Please check this @SLTozer @dwblaikie
void func(int a, int *b) {
if (a) {
*b = 1;
} else {
*b = 1;
}
}
int main() {
int *b;
func(0, b);
return 0;
}
$ clang -g -S -emit-llvm -Xclang -disable-O0-optnone main.c -o main.ll
$ opt -S -passes=mem2reg,gvn-sink main.ll -o main-opt.ll
$ clang main-opt.ll -o a.out
$ mylldb a.out
(lldb) target create "a.out"
Current executable set to '/data1/llvm-test/GVNSink/a.out' (x86_64).
(lldb) b func
Breakpoint 1: where = a.out`func + 8 at gvnsink.c:2:9, address = 0x0000000000001138
(lldb) r
Process 2786226 launched: '/data1/llvm-test/GVNSink/a.out' (x86_64)
Process 2786226 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x0000555555555138 a.out`func(a=0, b=0x00007fffffffdac8) at gvnsink.c:2:9
1 void func(int a, int *b) {
-> 2 if (a) {
3 *b = 1;
4 } else {
5 *b = 1;
6 }
7 }
(lldb) s
Process 2786226 stopped
* thread #1, name = 'a.out', stop reason = step in
frame #0: 0x000055555555514f a.out`func(a=0, b=0x00007fffffffdac8) at gvnsink.c:3:12
1 void func(int a, int *b) {
2 if (a) {
-> 3 *b = 1;
4 } else {
5 *b = 1;
6 }
7 }
(lldb) v
(int) a = 0
(int *) b = 0x00007fffffffdac8
(lldb)
Metadata
Metadata
Assignees
Labels
debuginfollvm:GVNGVN and NewGVN stages (Global value numbering)GVN and NewGVN stages (Global value numbering)