SuccessChanges

Summary

  1. Reland "clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM" This patch contains the basic functionality for reporting potentially incorrect usage of __builtin_expect() by comparing the developer's annotation against a collected PGO profile. A more detailed proposal and discussion appears on the CFE-dev mailing list (http://lists.llvm.org/pipermail/cfe-dev/2019-July/062971.html) and a prototype of the initial frontend changes appear here in D65300 We revised the work in D65300 by moving the misexpect check into the LLVM backend, and adding support for IR and sampling based profiles, in addition to frontend instrumentation. We add new misexpect metadata tags to those instructions directly influenced by the llvm.expect intrinsic (branch, switch, and select) when lowering the intrinsics. The misexpect metadata contains information about the expected target of the intrinsic so that we can check against the correct PGO counter when emitting diagnostics, and the compiler's values for the LikelyBranchWeight and UnlikelyBranchWeight. We use these branch weight values to determine when to emit the diagnostic to the user. A future patch should address the comment at the top of LowerExpectIntrisic.cpp to hoist the LikelyBranchWeight and UnlikelyBranchWeight values into a shared space that can be accessed outside of the LowerExpectIntrinsic pass. Once that is done, the misexpect metadata can be updated to be smaller. In the long term, it is possible to reconstruct portions of the misexpect metadata from the existing profile data. However, we have avoided this to keep the code simple, and because some kind of metadata tag will be required to identify which branch/switch/select instructions are influenced by the use of llvm.expect Patch By: paulkirth Differential Revision: https://reviews.llvm.org/D66324
  2. Revert [InstCombine] Use SimplifyFMulInst to simplify multiply in fma. This introduces additional rounding error in some cases. See D67434. This reverts r371518 (git commit 18a1f0818b659cee13865b4fad2648d85984a4ed)
  3. [Clang][Bundler] Fix for a potential memory leak [NFC] Bundler leaks memory if it is called with -type=o but given input isn't an object file (though it has to have a known binary type like IR, archive, etc...). Memory leak is happening when binary object returned by the createBinary(...) call cannot be casted to an ObjectFile type. In this case returned BinaryOrErr object releases ownership of the binary, but no one is taking it (see line 626). Differential Revision: https://reviews.llvm.org/D67416
  4. [OPENMP] Update the diagnosis message for canonical loop form, by Chi Chun Chen. The previous patch (https://reviews.llvm.org/D54441) support the relational-op != very well for openmp canonical loop form, however, it didn't update the diagnosis message. So this patch is simply update the diagnosis message by adding !=, update the test related to it, and update the section number for canonical loop form for OpenMP 5.0 in comment. Differential Revision: https://reviews.llvm.org/D66559
  5. [InstSimplify] Pass SimplifyQuery into simplifyUnsignedRangeCheck() and use it for isKnownNonZero() This was actually the original intention in D67332, but i messed up and forgot about it. This patch was originally part of D67411, but precommitting this.
  6. [NFC][InstSimplify] Add extra test for D67411 with @llvm.assume
Revision 371635 by phosek:
Reland "clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM"

This patch contains the basic functionality for reporting potentially
incorrect usage of __builtin_expect() by comparing the developer's
annotation against a collected PGO profile. A more detailed proposal and
discussion appears on the CFE-dev mailing list
(http://lists.llvm.org/pipermail/cfe-dev/2019-July/062971.html) and a
prototype of the initial frontend changes appear here in D65300

We revised the work in D65300 by moving the misexpect check into the
LLVM backend, and adding support for IR and sampling based profiles, in
addition to frontend instrumentation.

We add new misexpect metadata tags to those instructions directly
influenced by the llvm.expect intrinsic (branch, switch, and select)
when lowering the intrinsics. The misexpect metadata contains
information about the expected target of the intrinsic so that we can
check against the correct PGO counter when emitting diagnostics, and the
compiler's values for the LikelyBranchWeight and UnlikelyBranchWeight.
We use these branch weight values to determine when to emit the
diagnostic to the user.

A future patch should address the comment at the top of
LowerExpectIntrisic.cpp to hoist the LikelyBranchWeight and
UnlikelyBranchWeight values into a shared space that can be accessed
outside of the LowerExpectIntrinsic pass. Once that is done, the
misexpect metadata can be updated to be smaller.

In the long term, it is possible to reconstruct portions of the
misexpect metadata from the existing profile data. However, we have
avoided this to keep the code simple, and because some kind of metadata
tag will be required to identify which branch/switch/select instructions
are influenced by the use of llvm.expect

Patch By: paulkirth
Differential Revision: https://reviews.llvm.org/D66324
Change TypePath in RepositoryPath in Workspace
The file was modified/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (diff)clang.src/include/clang/Basic/DiagnosticFrontendKinds.td
The file was modified/cfe/trunk/include/clang/Basic/DiagnosticGroups.td (diff)clang.src/include/clang/Basic/DiagnosticGroups.td
The file was modified/cfe/trunk/lib/CodeGen/CodeGenAction.cpp (diff)clang.src/lib/CodeGen/CodeGenAction.cpp
The file was modified/cfe/trunk/lib/Frontend/CompilerInvocation.cpp (diff)clang.src/lib/Frontend/CompilerInvocation.cpp
The file was added/cfe/trunk/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftextclang.src/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftext
The file was added/cfe/trunk/test/Profile/Inputs/misexpect-branch.proftextclang.src/test/Profile/Inputs/misexpect-branch.proftext
The file was added/cfe/trunk/test/Profile/Inputs/misexpect-switch-default-only.proftextclang.src/test/Profile/Inputs/misexpect-switch-default-only.proftext
The file was added/cfe/trunk/test/Profile/Inputs/misexpect-switch-default.proftextclang.src/test/Profile/Inputs/misexpect-switch-default.proftext
The file was added/cfe/trunk/test/Profile/Inputs/misexpect-switch-nonconst.proftextclang.src/test/Profile/Inputs/misexpect-switch-nonconst.proftext
The file was added/cfe/trunk/test/Profile/Inputs/misexpect-switch.proftextclang.src/test/Profile/Inputs/misexpect-switch.proftext
The file was added/cfe/trunk/test/Profile/misexpect-branch-cold.cclang.src/test/Profile/misexpect-branch-cold.c
The file was added/cfe/trunk/test/Profile/misexpect-branch-nonconst-expected-val.cclang.src/test/Profile/misexpect-branch-nonconst-expected-val.c
The file was added/cfe/trunk/test/Profile/misexpect-branch-unpredictable.cclang.src/test/Profile/misexpect-branch-unpredictable.c
The file was added/cfe/trunk/test/Profile/misexpect-branch.cclang.src/test/Profile/misexpect-branch.c
The file was added/cfe/trunk/test/Profile/misexpect-switch-default.cclang.src/test/Profile/misexpect-switch-default.c
The file was added/cfe/trunk/test/Profile/misexpect-switch-nonconst.cclang.src/test/Profile/misexpect-switch-nonconst.c
The file was added/cfe/trunk/test/Profile/misexpect-switch-only-default-case.cclang.src/test/Profile/misexpect-switch-only-default-case.c
The file was added/cfe/trunk/test/Profile/misexpect-switch.cclang.src/test/Profile/misexpect-switch.c
The file was modified/llvm/trunk/include/llvm/IR/DiagnosticInfo.h (diff)llvm.src/include/llvm/IR/DiagnosticInfo.h
The file was modified/llvm/trunk/include/llvm/IR/FixedMetadataKinds.def (diff)llvm.src/include/llvm/IR/FixedMetadataKinds.def
The file was modified/llvm/trunk/include/llvm/IR/MDBuilder.h (diff)llvm.src/include/llvm/IR/MDBuilder.h
The file was added/llvm/trunk/include/llvm/Transforms/Utils/MisExpect.hllvm.src/include/llvm/Transforms/Utils/MisExpect.h
The file was modified/llvm/trunk/lib/IR/DiagnosticInfo.cpp (diff)llvm.src/lib/IR/DiagnosticInfo.cpp
The file was modified/llvm/trunk/lib/IR/MDBuilder.cpp (diff)llvm.src/lib/IR/MDBuilder.cpp
The file was modified/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp (diff)llvm.src/lib/Transforms/IPO/SampleProfile.cpp
The file was modified/llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp (diff)llvm.src/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
The file was modified/llvm/trunk/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp (diff)llvm.src/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
The file was modified/llvm/trunk/lib/Transforms/Utils/CMakeLists.txt (diff)llvm.src/lib/Transforms/Utils/CMakeLists.txt
The file was added/llvm/trunk/lib/Transforms/Utils/MisExpect.cppllvm.src/lib/Transforms/Utils/MisExpect.cpp
The file was modified/llvm/trunk/test/ThinLTO/X86/lazyload_metadata.ll (diff)llvm.src/test/ThinLTO/X86/lazyload_metadata.ll
The file was modified/llvm/trunk/test/Transforms/LowerExpectIntrinsic/basic.ll (diff)llvm.src/test/Transforms/LowerExpectIntrinsic/basic.ll
The file was added/llvm/trunk/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftextllvm.src/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
The file was added/llvm/trunk/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftextllvm.src/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
The file was added/llvm/trunk/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftextllvm.src/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
The file was added/llvm/trunk/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftextllvm.src/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
The file was added/llvm/trunk/test/Transforms/PGOProfile/misexpect-branch-correct.llllvm.src/test/Transforms/PGOProfile/misexpect-branch-correct.ll
The file was added/llvm/trunk/test/Transforms/PGOProfile/misexpect-branch-stripped.llllvm.src/test/Transforms/PGOProfile/misexpect-branch-stripped.ll
The file was added/llvm/trunk/test/Transforms/PGOProfile/misexpect-branch-unpredictable.llllvm.src/test/Transforms/PGOProfile/misexpect-branch-unpredictable.ll
The file was added/llvm/trunk/test/Transforms/PGOProfile/misexpect-branch.llllvm.src/test/Transforms/PGOProfile/misexpect-branch.ll
The file was added/llvm/trunk/test/Transforms/PGOProfile/misexpect-switch-default.llllvm.src/test/Transforms/PGOProfile/misexpect-switch-default.ll
The file was added/llvm/trunk/test/Transforms/PGOProfile/misexpect-switch.llllvm.src/test/Transforms/PGOProfile/misexpect-switch.ll
Revision 371634 by fhahn:
Revert [InstCombine] Use SimplifyFMulInst to simplify multiply in fma.

This introduces additional rounding error in some cases. See D67434.

This reverts r371518 (git commit 18a1f0818b659cee13865b4fad2648d85984a4ed)
Change TypePath in RepositoryPath in Workspace
The file was modified/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (diff)llvm.src/lib/Transforms/InstCombine/InstCombineCalls.cpp
The file was modified/llvm/trunk/test/Transforms/InstCombine/fma.ll (diff)llvm.src/test/Transforms/InstCombine/fma.ll
Revision 371633 by sdmitriev:
[Clang][Bundler] Fix for a potential memory leak [NFC]

Bundler leaks memory if it is called with -type=o but given input isn't an object file (though it has to have a known binary type like IR, archive, etc...). Memory leak is happening when binary object returned by the createBinary(...) call cannot be casted to an ObjectFile type. In this case returned BinaryOrErr object releases ownership of the binary, but no one is taking it (see line 626).

Differential Revision: https://reviews.llvm.org/D67416
Change TypePath in RepositoryPath in Workspace
The file was modified/cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp (diff)clang.src/tools/clang-offload-bundler/ClangOffloadBundler.cpp
Revision 371631 by abataev:
[OPENMP] Update the diagnosis message for canonical loop form, by Chi
Chun Chen.

The previous patch (https://reviews.llvm.org/D54441) support the
relational-op != very well for openmp canonical loop form, however,
it didn't update the diagnosis message. So this patch is simply
update the diagnosis message by adding !=, update the test
related to it, and update the section number for canonical loop
form for OpenMP 5.0 in comment.

Differential Revision: https://reviews.llvm.org/D66559
Change TypePath in RepositoryPath in Workspace
The file was modified/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (diff)clang.src/include/clang/Basic/DiagnosticSemaKinds.td
The file was modified/cfe/trunk/lib/Sema/SemaOpenMP.cpp (diff)clang.src/lib/Sema/SemaOpenMP.cpp
The file was modified/cfe/trunk/test/OpenMP/distribute_parallel_for_simd_loop_messages.cpp (diff)clang.src/test/OpenMP/distribute_parallel_for_simd_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/distribute_simd_loop_messages.cpp (diff)clang.src/test/OpenMP/distribute_simd_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/for_loop_messages.cpp (diff)clang.src/test/OpenMP/for_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/for_simd_loop_messages.cpp (diff)clang.src/test/OpenMP/for_simd_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/parallel_for_ast_print.cpp (diff)clang.src/test/OpenMP/parallel_for_ast_print.cpp
The file was modified/cfe/trunk/test/OpenMP/parallel_for_codegen.cpp (diff)clang.src/test/OpenMP/parallel_for_codegen.cpp
The file was modified/cfe/trunk/test/OpenMP/parallel_for_loop_messages.cpp (diff)clang.src/test/OpenMP/parallel_for_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/parallel_for_simd_loop_messages.cpp (diff)clang.src/test/OpenMP/parallel_for_simd_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/simd_loop_messages.cpp (diff)clang.src/test/OpenMP/simd_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/target_parallel_for_loop_messages.cpp (diff)clang.src/test/OpenMP/target_parallel_for_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/target_parallel_for_simd_loop_messages.cpp (diff)clang.src/test/OpenMP/target_parallel_for_simd_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/target_simd_loop_messages.cpp (diff)clang.src/test/OpenMP/target_simd_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/target_teams_distribute_loop_messages.cpp (diff)clang.src/test/OpenMP/target_teams_distribute_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_loop_messages.cpp (diff)clang.src/test/OpenMP/target_teams_distribute_parallel_for_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_loop_messages.cpp (diff)clang.src/test/OpenMP/target_teams_distribute_parallel_for_simd_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/target_teams_distribute_simd_loop_messages.cpp (diff)clang.src/test/OpenMP/target_teams_distribute_simd_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/taskloop_loop_messages.cpp (diff)clang.src/test/OpenMP/taskloop_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/taskloop_simd_loop_messages.cpp (diff)clang.src/test/OpenMP/taskloop_simd_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/teams_distribute_loop_messages.cpp (diff)clang.src/test/OpenMP/teams_distribute_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp (diff)clang.src/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp (diff)clang.src/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
The file was modified/cfe/trunk/test/OpenMP/teams_distribute_simd_loop_messages.cpp (diff)clang.src/test/OpenMP/teams_distribute_simd_loop_messages.cpp
Revision 371630 by lebedevri:
[InstSimplify] Pass SimplifyQuery into simplifyUnsignedRangeCheck() and use it for isKnownNonZero()

This was actually the original intention in D67332,
but i messed up and forgot about it.
This patch was originally part of D67411, but precommitting this.
Change TypePath in RepositoryPath in Workspace
The file was modified/llvm/trunk/lib/Analysis/InstructionSimplify.cpp (diff)llvm.src/lib/Analysis/InstructionSimplify.cpp
The file was modified/llvm/trunk/test/Transforms/InstSimplify/redundant-null-check-in-uadd_with_overflow-of-nonnull-ptr.ll (diff)llvm.src/test/Transforms/InstSimplify/redundant-null-check-in-uadd_with_overflow-of-nonnull-ptr.ll
Revision 371629 by lebedevri:
[NFC][InstSimplify] Add extra test for D67411 with @llvm.assume
Change TypePath in RepositoryPath in Workspace
The file was modified/llvm/trunk/test/Transforms/InstSimplify/redundant-null-check-in-uadd_with_overflow-of-nonnull-ptr.ll (diff)llvm.src/test/Transforms/InstSimplify/redundant-null-check-in-uadd_with_overflow-of-nonnull-ptr.ll