| Issue |
176944
|
| Summary |
SimplifyCFGPass optimizes out necessary function call
|
| Labels |
|
| Assignees |
|
| Reporter |
Invisparent
|
Hello llvm developers.
I'm so sorry that I have to submit three separate source files here, because I can't further minimize the testcase, and bugpoint tool seems not working for me.
In main.c, line 25, we invoke ivs_rb_tree insert in rb_tree.c, line 497. At line 512, there's an if branch. If it evaluates false, we should go to line 515, invoking ivs_static_rb_tree_insert_at (defined at line 447), and then immediately print Invoked at line 457.
This program is expected to output a series of "Invoked\n". At -O0 it does, but at -O2 it does not. I've used OptBisect to determine what happened. When -opt-bisect-limit=726 everything works fine, but when -opt-bisect-limit=727 it's not. (See console_opt-bisect-limit=xxx)
I guess this pass:
> BISECT: running pass (727) SimplifyCFGPass on ivs_rb_tree_insert
optimized out the necessary call ivs_static_rb_tree_insert_at at line 515.
I've inspected the code as careful as I could, and I've compiled them using gcc-14.3.0. gcc will print "Invoke"s no matter it's -O0, -O2 or -O3. I do think that's llvm's issue. I'll say sorry if that's not a bug of llvm, bug some undefined behaviors in my code.
(ps. That's an implementation of rb_tree, using gcc I've tested it's about 30% slower than std::set, gcc works fine. But clang is not, and that's why I report this).
At last, thanks for all volunteers & developers that makes llvm better.
----------------
LLVM version:
C:\Users\Invisparent>clang -v
clang version 21.1.8
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\IVS\Apps\clang+llvm-21.1.8-x86_64-pc-windows-msvc\bin
(I downloaded this prebuilt binary from this repo.)
(Also I've tested on Ubuntu, clang 21.1.8, downloaded from apt.llvm.org. This bug still exists and has the same behavior as above.)
[llvm-report-20260120.zip](https://github.com/user-attachments/files/24741126/llvm-report-20260120.zip)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs