diff options
| author | Johannes Doerfert <jdoerfert@anl.gov> | 2019-10-13 04:14:15 +0000 |
|---|---|---|
| committer | Johannes Doerfert <jdoerfert@anl.gov> | 2019-10-13 04:14:15 +0000 |
| commit | af6e4797330b597b50469bbadd4a55ef26536ea9 (patch) | |
| tree | 1d4ee0dc8f7ebe82b56d88fc0897eee11a0b97b2 /llvm/lib/Transforms | |
| parent | d20f80780e053dfa3664858c9ac8be15951a035d (diff) | |
| download | bcm5719-llvm-af6e4797330b597b50469bbadd4a55ef26536ea9.tar.gz bcm5719-llvm-af6e4797330b597b50469bbadd4a55ef26536ea9.zip | |
[Attributor][FIX] Ensure h2s doesn't trigger on escaped pointers
We do not yet perform h2s because we know something is free'ed but we do
it because we know the pointer does not escape. Storing the pointer
allows it to escape so we have to prevent that.
llvm-svn: 374699
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/IPO/Attributor.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index 6db3f40b05f..ef6c82c00c8 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -3569,8 +3569,16 @@ ChangeStatus AAHeapToStackImpl::updateImpl(Attributor &A) { auto *UserI = U->getUser(); - if (isa<LoadInst>(UserI) || isa<StoreInst>(UserI)) + if (isa<LoadInst>(UserI)) continue; + if (auto *SI = dyn_cast<StoreInst>(UserI)) { + if (SI->getValueOperand() == U->get()) { + LLVM_DEBUG(dbgs() << "[H2S] escaping store to memory: " << *UserI << "\n"); + return false; + } + // A store into the malloc'ed memory is fine. + continue; + } // NOTE: Right now, if a function that has malloc pointer as an argument // frees memory, we assume that the malloc pointer is freed. |

