diff options
author | Vedant Kumar <vsk@apple.com> | 2020-03-23 15:09:38 -0700 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2020-03-23 22:36:09 -0700 |
commit | b7cd291c1542aee12c9e9fde6c411314a163a8ea (patch) | |
tree | 4e79e0f8804371f04455efb815ec34d7f8eedfef /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | bec785ab704b88ffec51eb54404daa5d4ebfc265 (diff) | |
download | llvm-b7cd291c1542aee12c9e9fde6c411314a163a8ea.zip llvm-b7cd291c1542aee12c9e9fde6c411314a163a8ea.tar.gz llvm-b7cd291c1542aee12c9e9fde6c411314a163a8ea.tar.bz2 |
[GlobalOpt] Treat null-check of loaded value as use of global (PR35760)
PR35760 shows an example program which, when compiled with `clang -O0`
or gcc at any optimization level, prints '0'. However, llvm transforms
the program in a way that causes it to print '1'.
Fix the issue by having `AllUsesOfValueWillTrapIfNull` return false when
analyzing a load from a global which is used by an `icmp`. This special
case was untested [0] so this is just deleting dead code.
An alternative fix might be to change the GlobalStatus analysis for the
global to report "Stored" instead of "StoredOnce". However, "StoredOnce"
is appropriate when only one value other than the initializer is stored
to the global.
[0]
http://lab.llvm.org:8080/coverage/coverage-reports/coverage/Users/buildslave/jenkins/workspace/coverage/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp.html#L662
Differential Revision: https://reviews.llvm.org/D76645
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions