summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-diff
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2018-09-24 04:42:13 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2018-09-24 04:42:13 +0000
commitce5f2034151d053640a8ca3dd2be5ab5af0dd510 (patch)
treebd0f6170c1a443259c03c343ffe2827e0e24fb35 /llvm/tools/llvm-diff
parent5bef27e808ed0eb2f2510b467cfe2d3eb4d7ec8a (diff)
downloadbcm5719-llvm-ce5f2034151d053640a8ca3dd2be5ab5af0dd510.tar.gz
bcm5719-llvm-ce5f2034151d053640a8ca3dd2be5ab5af0dd510.zip
llvm-diff: Fix crash on anonymous functions
Not sure what the correct behavior is for this. Skip them and report how many there were. llvm-svn: 342857
Diffstat (limited to 'llvm/tools/llvm-diff')
-rw-r--r--llvm/tools/llvm-diff/DifferenceEngine.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/llvm/tools/llvm-diff/DifferenceEngine.cpp b/llvm/tools/llvm-diff/DifferenceEngine.cpp
index af0a055ea21..5be533d9af3 100644
--- a/llvm/tools/llvm-diff/DifferenceEngine.cpp
+++ b/llvm/tools/llvm-diff/DifferenceEngine.cpp
@@ -686,9 +686,18 @@ void DifferenceEngine::diff(Module *L, Module *R) {
StringSet<> LNames;
SmallVector<std::pair<Function*,Function*>, 20> Queue;
+ unsigned LeftAnonCount = 0;
+ unsigned RightAnonCount = 0;
+
for (Module::iterator I = L->begin(), E = L->end(); I != E; ++I) {
Function *LFn = &*I;
- LNames.insert(LFn->getName());
+ StringRef Name = LFn->getName();
+ if (Name.empty()) {
+ ++LeftAnonCount;
+ continue;
+ }
+
+ LNames.insert(Name);
if (Function *RFn = R->getFunction(LFn->getName()))
Queue.push_back(std::make_pair(LFn, RFn));
@@ -698,10 +707,25 @@ void DifferenceEngine::diff(Module *L, Module *R) {
for (Module::iterator I = R->begin(), E = R->end(); I != E; ++I) {
Function *RFn = &*I;
- if (!LNames.count(RFn->getName()))
+ StringRef Name = RFn->getName();
+ if (Name.empty()) {
+ ++RightAnonCount;
+ continue;
+ }
+
+ if (!LNames.count(Name))
logf("function %r exists only in right module") << RFn;
}
+
+ if (LeftAnonCount != 0 || RightAnonCount != 0) {
+ SmallString<32> Tmp;
+ Twine Message = "not comparing " + Twine(LeftAnonCount) +
+ " anonymous functions in the left module and " + Twine(RightAnonCount) +
+ " in the right module";
+ logf(Message.toStringRef(Tmp));
+ }
+
for (SmallVectorImpl<std::pair<Function*,Function*> >::iterator
I = Queue.begin(), E = Queue.end(); I != E; ++I)
diff(I->first, I->second);
OpenPOWER on IntegriCloud