[llvm] r329957 - Let llvm-diff correctly deal with Undef/ConstantAggregateZero/ConstantVector/IndirectBr
Shoaib Meenai via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 12 14:36:02 PDT 2018
You should include an attribution of changes line in patches you're committing on behalf of others (a "Patch by XXX" in your commit message). See https://llvm.org/docs/DeveloperPolicy.html#attribution-of-changes
From: llvm-commits <llvm-commits-bounces at lists.llvm.org> on behalf of Brian Gesiak via llvm-commits <llvm-commits at lists.llvm.org>
Reply-To: Brian Gesiak <modocache at gmail.com>
Date: Thursday, April 12, 2018 at 2:31 PM
To: "llvm-commits at lists.llvm.org" <llvm-commits at lists.llvm.org>
Subject: [llvm] r329957 - Let llvm-diff correctly deal with Undef/ConstantAggregateZero/ConstantVector/IndirectBr
Author: modocache
Date: Thu Apr 12 14:28:04 2018
New Revision: 329957
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D329957-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=wNYVndKxHQubYOnSy9f7rflxF2ZHkyaHaeEgFtZIuDs&s=uIW8P7xd3cIHBHRLbTXEKYsQBzmsF-eEy8EUOesLgmA&e=
Log:
Let llvm-diff correctly deal with Undef/ConstantAggregateZero/ConstantVector/IndirectBr
Summary:
llvm-diff incorrectly reports that there's a diff when input IR contains undef/zeroinitializer/constantvector/indirectbr.
(This happens even if two identical files are given, e.g. `llvm-diff x.ll x.ll`)
This is fix to the bug report https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D33623&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=wNYVndKxHQubYOnSy9f7rflxF2ZHkyaHaeEgFtZIuDs&s=Aoo-zHNhe80PJ1WGDTQf8vYJfbX-kW0LJA-PEYm6qKQ&e= .
Reviewers: dexonsmith, rjmccall
Reviewed By: rjmccall
Subscribers: chenwj, mgrang, llvm-commits
Differential Revision: https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D34856&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=wNYVndKxHQubYOnSy9f7rflxF2ZHkyaHaeEgFtZIuDs&s=T5CfeAt2QQo5Uby8iNv8_amKog5zcj1HSCicTuumXnQ&e=
Added:
llvm/trunk/test/tools/llvm-diff/
llvm/trunk/test/tools/llvm-diff/constantvector.ll
llvm/trunk/test/tools/llvm-diff/indirectbr.ll
llvm/trunk/test/tools/llvm-diff/undef.ll
llvm/trunk/test/tools/llvm-diff/zeroinitializer.bc.ll
Modified:
llvm/trunk/tools/llvm-diff/DifferenceEngine.cpp
Added: llvm/trunk/test/tools/llvm-diff/constantvector.ll
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_test_tools_llvm-2Ddiff_constantvector.ll-3Frev-3D329957-26view-3Dauto&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=wNYVndKxHQubYOnSy9f7rflxF2ZHkyaHaeEgFtZIuDs&s=uh1DppEkmDRdtxWp0_m4XWM8Kps4r1eF9UZGgnYEM9M&e=
==============================================================================
--- llvm/trunk/test/tools/llvm-diff/constantvector.ll (added)
+++ llvm/trunk/test/tools/llvm-diff/constantvector.ll Thu Apr 12 14:28:04 2018
@@ -0,0 +1,16 @@
+; Bugzilla: https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D33623&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=wNYVndKxHQubYOnSy9f7rflxF2ZHkyaHaeEgFtZIuDs&s=Aoo-zHNhe80PJ1WGDTQf8vYJfbX-kW0LJA-PEYm6qKQ&e=
+; RUN: llvm-diff %s %s
+
+%struct.it = type { i64, i64* }
+
+ at a_vector = internal global [2 x i64] zeroinitializer, align 16
+
+define i32 @foo(%struct.it* %it) {
+
+entry:
+ %a = getelementptr inbounds %struct.it, %struct.it* %it, i64 0, i32 1
+ %tmp0 = bitcast i64** %a to <2 x i64*>*
+ store <2 x i64*> <i64* getelementptr inbounds ([2 x i64], [2 x i64]* @a_vector, i64 0, i64 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* @a_vector, i64 0, i64 0)>, <2 x i64*>* %tmp0, align 8
+
+ ret i32 0
+}
Added: llvm/trunk/test/tools/llvm-diff/indirectbr.ll
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_test_tools_llvm-2Ddiff_indirectbr.ll-3Frev-3D329957-26view-3Dauto&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=wNYVndKxHQubYOnSy9f7rflxF2ZHkyaHaeEgFtZIuDs&s=LVkk-YUk42A9z30xZcBiY3vz0U2teJWvxjqTRBMJWxo&e=
==============================================================================
--- llvm/trunk/test/tools/llvm-diff/indirectbr.ll (added)
+++ llvm/trunk/test/tools/llvm-diff/indirectbr.ll Thu Apr 12 14:28:04 2018
@@ -0,0 +1,11 @@
+; Bugzilla: https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D33623&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=wNYVndKxHQubYOnSy9f7rflxF2ZHkyaHaeEgFtZIuDs&s=Aoo-zHNhe80PJ1WGDTQf8vYJfbX-kW0LJA-PEYm6qKQ&e=
+; RUN: llvm-diff %s %s
+
+define i32 @foo(i8*) {
+entry:
+ indirectbr i8* %0, [label %A, label %B, label %entry]
+A:
+ ret i32 1
+B:
+ ret i32 2
+}
Added: llvm/trunk/test/tools/llvm-diff/undef.ll
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_test_tools_llvm-2Ddiff_undef.ll-3Frev-3D329957-26view-3Dauto&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=wNYVndKxHQubYOnSy9f7rflxF2ZHkyaHaeEgFtZIuDs&s=WJvvSv12OiOyJczI-AaiCfUWHDSU_G1SPJOunHZaOWo&e=
==============================================================================
--- llvm/trunk/test/tools/llvm-diff/undef.ll (added)
+++ llvm/trunk/test/tools/llvm-diff/undef.ll Thu Apr 12 14:28:04 2018
@@ -0,0 +1,11 @@
+; Bugzilla: https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D33623&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=wNYVndKxHQubYOnSy9f7rflxF2ZHkyaHaeEgFtZIuDs&s=Aoo-zHNhe80PJ1WGDTQf8vYJfbX-kW0LJA-PEYm6qKQ&e=
+; RUN: llvm-diff %s %s
+
+%A = type { i64, i64 }
+ at _gm_ = global <2 x %A*> zeroinitializer
+
+define void @f() {
+entry:
+ store <2 x %A*> undef, <2 x %A*>* @_gm_
+ ret void
+}
Added: llvm/trunk/test/tools/llvm-diff/zeroinitializer.bc.ll
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_test_tools_llvm-2Ddiff_zeroinitializer.bc.ll-3Frev-3D329957-26view-3Dauto&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=wNYVndKxHQubYOnSy9f7rflxF2ZHkyaHaeEgFtZIuDs&s=7jzitHYieHUW-i9Jyt30FT4aNzxuU96L_jThqZ10hNY&e=
==============================================================================
--- llvm/trunk/test/tools/llvm-diff/zeroinitializer.bc.ll (added)
+++ llvm/trunk/test/tools/llvm-diff/zeroinitializer.bc.ll Thu Apr 12 14:28:04 2018
@@ -0,0 +1,11 @@
+; Bugzilla: https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D33623&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=wNYVndKxHQubYOnSy9f7rflxF2ZHkyaHaeEgFtZIuDs&s=Aoo-zHNhe80PJ1WGDTQf8vYJfbX-kW0LJA-PEYm6qKQ&e=
+; RUN: llvm-diff %s %s
+
+%A = type { i64, i64 }
+ at _gm_ = global <2 x %A*> zeroinitializer
+
+define void @f() {
+entry:
+ store <2 x %A*> zeroinitializer, <2 x %A*>* @_gm_
+ ret void
+}
Modified: llvm/trunk/tools/llvm-diff/DifferenceEngine.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_tools_llvm-2Ddiff_DifferenceEngine.cpp-3Frev-3D329957-26r1-3D329956-26r2-3D329957-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=wNYVndKxHQubYOnSy9f7rflxF2ZHkyaHaeEgFtZIuDs&s=utT8HeI8_9GF8bQtOJHyh6Ck2zVxlTyW7rKxsADsdRU&e=
==============================================================================
--- llvm/trunk/tools/llvm-diff/DifferenceEngine.cpp (original)
+++ llvm/trunk/tools/llvm-diff/DifferenceEngine.cpp Thu Apr 12 14:28:04 2018
@@ -303,6 +303,26 @@ class FunctionDifferenceEngine {
if (TryUnify) tryUnify(LI->getSuccessor(0), RI->getSuccessor(0));
return false;
+ } else if (isa<IndirectBrInst>(L)) {
+ IndirectBrInst *LI = cast<IndirectBrInst>(L);
+ IndirectBrInst *RI = cast<IndirectBrInst>(R);
+ if (LI->getNumDestinations() != RI->getNumDestinations()) {
+ if (Complain) Engine.log("indirectbr # of destinations differ");
+ return true;
+ }
+
+ if (!equivalentAsOperands(LI->getAddress(), RI->getAddress())) {
+ if (Complain) Engine.log("indirectbr addresses differ");
+ return true;
+ }
+
+ if (TryUnify) {
+ for (unsigned i = 0; i < LI->getNumDestinations(); i++) {
+ tryUnify(LI->getDestination(i), RI->getDestination(i));
+ }
+ }
+ return false;
+
} else if (isa<SwitchInst>(L)) {
SwitchInst *LI = cast<SwitchInst>(L);
SwitchInst *RI = cast<SwitchInst>(R);
@@ -377,9 +397,9 @@ class FunctionDifferenceEngine {
return equivalentAsOperands(cast<ConstantExpr>(L),
cast<ConstantExpr>(R));
- // Nulls of the "same type" don't always actually have the same
+ // Constants of the "same type" don't always actually have the same
// type; I don't know why. Just white-list them.
- if (isa<ConstantPointerNull>(L))
+ if (isa<ConstantPointerNull>(L) || isa<UndefValue>(L) || isa<ConstantAggregateZero>(L))
return true;
// Block addresses only match if we've already encountered the
@@ -388,6 +408,19 @@ class FunctionDifferenceEngine {
return Blocks[cast<BlockAddress>(L)->getBasicBlock()]
== cast<BlockAddress>(R)->getBasicBlock();
+ // If L and R are ConstantVectors, compare each element
+ if (isa<ConstantVector>(L)) {
+ ConstantVector *CVL = cast<ConstantVector>(L);
+ ConstantVector *CVR = cast<ConstantVector>(R);
+ if (CVL->getType()->getNumElements() != CVR->getType()->getNumElements())
+ return false;
+ for (unsigned i = 0; i < CVL->getType()->getNumElements(); i++) {
+ if (!equivalentAsOperands(CVL->getOperand(i), CVR->getOperand(i)))
+ return false;
+ }
+ return true;
+ }
+
return false;
}
_______________________________________________
llvm-commits mailing list
llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=wNYVndKxHQubYOnSy9f7rflxF2ZHkyaHaeEgFtZIuDs&s=OWu954qQ6BuALMp7O4qNGcEcE7pHJ6d7E3RnhwaYM-U&e=
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180412/01212071/attachment.html>
More information about the llvm-commits
mailing list