[llvm] 3198406 - llvm-diff: Avoid crash with complex expressions

Dominic Chen via llvm-commits llvm-commits at lists.llvm.org
Thu May 21 14:44:33 PDT 2020


Author: Dominic Chen
Date: 2020-05-21T17:43:47-04:00
New Revision: 31984063678ef523b940160ac9d49fcb87c1e2ac

URL: https://github.com/llvm/llvm-project/commit/31984063678ef523b940160ac9d49fcb87c1e2ac
DIFF: https://github.com/llvm/llvm-project/commit/31984063678ef523b940160ac9d49fcb87c1e2ac.diff

LOG: llvm-diff: Avoid crash with complex expressions

Summary: With complex IR, the difference engine can enter an inconsistent state where the instruction and block difference engines return different results. Prevent a crash by refusing to pop beyond the end of the vector.

Reviewers: rjmccall

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D80351

Added: 
    

Modified: 
    llvm/tools/llvm-diff/DifferenceEngine.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-
diff /DifferenceEngine.cpp b/llvm/tools/llvm-
diff /DifferenceEngine.cpp
index e54217917e5b..2cf1afbc6af5 100644
--- a/llvm/tools/llvm-
diff /DifferenceEngine.cpp
+++ b/llvm/tools/llvm-
diff /DifferenceEngine.cpp
@@ -577,7 +577,7 @@ void FunctionDifferenceEngine::runBlockDiff(BasicBlock::iterator LStart,
   DiffLogBuilder Diff(Engine.getConsumer());
 
   // Drop trailing matches.
-  while (Path.back() == DC_match)
+  while (Path.size() && Path.back() == DC_match)
     Path.pop_back();
 
   // Skip leading matches.


        


More information about the llvm-commits mailing list