Created a pass that gives correct output with debug build but wrong with release build

I have made a pass for finding anticipated expressions and tested it using debug build,everything works correctly.But with Release build,it gives incorrect output.

The “Clang Frontend” category isn’t really a good place to post a question about passes. In any case, you have not provided a lot of information to work with, so any answer will have to be very generic. The best I can come up with is this:

The main differences between Debug and Release builds are:

  • asserts are enabled in Debug but not Release, so don’t use any side-effecting expressions in an assertion
  • LLVM_DEBUG is enabled in Debug but not Release, so don’t do anything functional there either
  • IR instructions might be named in Debug but not in Release (e.g., %add.0 = add 1, 2 vs %1 = add 1, 2), so if you are depending on those names it won’t work
  • optimizations are enabled when building Release, so if your code unexpectedly has unspecified or undefined behavior the results might be very different

If these general points don’t lead you to your problem, then I suggest posting more details in a new thread under “IR & Optimizations.”