diff options
author | Vedant Kumar <vsk@apple.com> | 2017-02-25 06:35:45 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2017-02-25 06:35:45 +0000 |
commit | 4f9b93abc8a8d41d7c89b3e6babeb48621b4d109 (patch) | |
tree | 6e0654e06aaeccfa2760af7aa3dd51395ff980e0 /lib/CodeGen/CodeGenPGO.h | |
parent | 31b3c535d98f1c16391a0f433f4a7aad251b2555 (diff) | |
download | clang-4f9b93abc8a8d41d7c89b3e6babeb48621b4d109.tar.gz |
Retry: [profiling] Fix profile counter increment when emitting selects (PR32019)
2nd attempt: the first was in r296231, but it had a use after lifetime
bug.
Clang has logic to lower certain conditional expressions directly into llvm
select instructions. However, it does not emit the correct profile counter
increment as it does this: it emits an unconditional increment of the counter
for the 'then branch', even if the value selected is from the 'else branch'
(this is PR32019).
That means, given the following snippet, we would report that "0" is selected
twice, and that "1" is never selected:
int f1(int x) {
return x ? 0 : 1;
^2 ^0
}
f1(0);
f1(1);
Fix the problem by using the instrprof_increment_step intrinsic to do the
proper increment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296245 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenPGO.h')
-rw-r--r-- | lib/CodeGen/CodeGenPGO.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGenPGO.h b/lib/CodeGen/CodeGenPGO.h index 4f229cde63..0026df570b 100644 --- a/lib/CodeGen/CodeGenPGO.h +++ b/lib/CodeGen/CodeGenPGO.h @@ -105,7 +105,8 @@ private: void emitCounterRegionMapping(const Decl *D); public: - void emitCounterIncrement(CGBuilderTy &Builder, const Stmt *S); + void emitCounterIncrement(CGBuilderTy &Builder, const Stmt *S, + llvm::Value *StepV); /// Return the region count for the counter at the given index. uint64_t getRegionCount(const Stmt *S) { |