llvm/lib/Analysis/MemorySSAUpdater.cpp:366: void llvm::MemorySSAUpdater::fixupDefs(const llvm::SmallVectorImpl<llvm::MemoryAccess*>&): Assertion `MSSA->dominates(NewDef, FirstDef) && "Should have dominated the new access"' failed.
| Bugzilla Link | 37808 |
| Resolution | FIXED |
| Resolved on | Jul 17, 2018 07:16 |
| Version | trunk |
| OS | Linux |
| Attachments | Error message, Input IR file (tarred) to reproduce the issue |
| CC | @fhahn |
Extended Description
Bug Description:
Facing the below assertion failure with the latest version:
-- opt: /home/amd/JENKINS/workspace/CPUPC_Mirror_Branch/llvm/lib/Analysis/MemorySSAUpdater.cpp:366: void llvm::MemorySSAUpdater::fixupDefs(const llvm::SmallVectorImplllvm::MemoryAccess*&): Assertion `MSSA->dominates(NewDef, FirstDef) && "Should have dominated the new access"' failed. Stack dump:
This issue is faced with the fix given for Bug 36484.
Attached: input IR file and error message file
=========
Steps to reproduce:
- Download the attached file
- Extract the file using command "tar -xvf gvnhoist_issue_input.o.tar.xz"
- Execute the below with the recent version of llvm: opt -S -gvn-hoist -o gvnhoist_issue_output.o gvnhoist_issue_input.o
=========
Fixed by rL337149. Resolving.
Bug fix under review: https://reviews.llvm.org/D48372
Root cause: After debugging the issue it seems that problem is due to dangling references in MemorySSA. File: lvm\lib\Analysis\MemorySSAUpdater.cpp , Function: void MemorySSAUpdater::removeMemoryAccess(MemoryAccess *MA) , Line 489 Approx The following code removes some of the MemoryAccess MSSA->removeFromLookups(MA); MSSA->removeFromLists(MA);
But later up in the call stack function
void MemorySSAUpdater::insertDef(MemoryDef *MD, bool RenameUses) { InsertedPHIs.clear();
: :
SmallVector<MemoryAccess *, 8> FixupList(InsertedPHIs.begin(),
InsertedPHIs.end());
: : : }
There are accesses to some of already deleted MemoryAccess but noted in InsertedPHIs. This causes some of later accesses to acess stale data.