[clang] fd4a107 - [DDG] Data Dependence Graph - DOT printer
Author: Bardia Mahjour Date: 2020-12-14T16:41:14-05:00 New Revision: fd4a10732c8bd646ccc621c0a9af512be252f33a URL: https://github.com/llvm/llvm-project/commit/fd4a10732c8bd646ccc621c0a9af512be252f33a DIFF: https://github.com/llvm/llvm-project/commit/fd4a10732c8bd646ccc621c0a9af512be252f33a.diff LOG: [DDG] Data Dependence Graph - DOT printer This patch implements a DDG printer pass that generates a graph in the DOT description language, providing a more visually appealing representation of the DDG. Similar to the CFG DOT printer, this functionality is provided under an option called -dot-ddg and can be generated in a less verbose mode under -dot-ddg-only option. Differential Revision: https://reviews.llvm.org/D90159 Added: llvm/include/llvm/Analysis/DDGPrinter.h llvm/lib/Analysis/DDGPrinter.cpp Modified: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp llvm/include/llvm/Analysis/CFGPrinter.h llvm/include/llvm/Analysis/DDG.h llvm/include/llvm/Support/DOTGraphTraits.h llvm/include/llvm/Support/GraphWriter.h llvm/lib/Analysis/CFGPrinter.cpp llvm/lib/Analysis/CMakeLists.txt llvm/lib/Analysis/CallPrinter.cpp llvm/lib/CodeGen/MachineScheduler.cpp llvm/lib/CodeGen/ScheduleDAGPrinter.cpp llvm/lib/Passes/PassBuilder.cpp llvm/lib/Passes/PassRegistry.def Removed: diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 409741cdb6e4..f285b652c175 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -3149,7 +3149,7 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { if (Stop(N)) return true; - if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc())) + if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc(), nullptr)) break; PostCallback(N); @@ -3158,7 +3158,7 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { return false; } - static bool isNodeHidden(const ExplodedNode *N) { + static bool isNodeHidden(const ExplodedNode *N, const ExplodedGraph *G) { return N->isTrivial(); } diff --git a/llvm/include/llvm/Analysis/CFGPrinter.h b/llvm/include/llvm/Analysis/CFGPrinter.h index bc6a19f2e2b9..53700798b6b3 100644 --- a/llvm/include/llvm/Analysis/CFGPrinter.h +++ b/llvm/include/llvm/Analysis/CFGPrinter.h @@ -295,7 +295,7 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { " fillcolor=\"" + Color + "70\""; return Attrs; } - bool isNodeHidden(const BasicBlock *Node); + bool isNodeHidden(const BasicBlock *Node, const DOTFuncInfo *CFGInfo); void computeHiddenNodes(const Function *F); }; } // End llvm namespace diff --git a/llvm/include/llvm/Analysis/DDG.h b/llvm/include/llvm/Analysis/DDG.h index 9e2b7907eaec..8d225c155cd4 100644 --- a/llvm/include/llvm/Analysis/DDG.h +++ b/llvm/include/llvm/Analysis/DDG.h @@ -290,6 +290,12 @@ template class DependenceGraphInfo { bool getDependencies(const NodeType &Src, const NodeType &Dst, DependenceList &Deps) const; + /// Return a string representing the type of dependence that the dependence + /// analysis identified between the two given nodes. This function assumes + /// that there is a memory dependence between the given two nodes. + const std::string getDependenceString(const NodeType &Src, +const NodeType &Dst) const; + protected: // Name of the graph. std::string Name; @@ -463,6 +469,26 @@ bool DependenceGraphInfo::getDependencies( return !Deps.empty(); } +template +const std::string +DependenceGraphInfo::getDependenceString(const NodeType &Src, + const NodeType &Dst) const { + std::string Str; + raw_string_ostream OS(Str); + DependenceList Deps; + if (!getDependencies(Src, Dst, Deps)) +return OS.str(); + interleaveComma(Deps, OS, [&](const std::unique_ptr &D) { +D->dump(OS); +// Remove the extra new-line character printed by the dump +// method +if (OS.str().back() == '\n') + OS.str().pop_back(); + }); + + return OS.str(); +} + //======// // GraphTraits specializations for the DDG //======// diff --git a/llvm/include/llvm/Analysis/DDGPrinter.h b/llvm/include/llvm/Analysis/DDGPrinter.h new file mode 100644 index ..5cfe2ce33c99 --- /dev/null +++ b/llvm/include/llvm/Analysis/DDGPrinter.h @@ -0,0 +1,91 @@ +//===- llvm/Analysis/DDGPrinter.h ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2
[clang] a29ecca - Revert "[DDG] Data Dependence Graph - DOT printer"
Author: Bardia Mahjour Date: 2020-12-14T16:54:20-05:00 New Revision: a29ecca7819a6ed4250d3689b12b1f664bb790d7 URL: https://github.com/llvm/llvm-project/commit/a29ecca7819a6ed4250d3689b12b1f664bb790d7 DIFF: https://github.com/llvm/llvm-project/commit/a29ecca7819a6ed4250d3689b12b1f664bb790d7.diff LOG: Revert "[DDG] Data Dependence Graph - DOT printer" This reverts commit fd4a10732c8bd646ccc621c0a9af512be252f33a, to investigate the failure on windows: http://lab.llvm.org:8011/#/builders/127/builds/3274 Added: Modified: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp llvm/include/llvm/Analysis/CFGPrinter.h llvm/include/llvm/Analysis/DDG.h llvm/include/llvm/Support/DOTGraphTraits.h llvm/include/llvm/Support/GraphWriter.h llvm/lib/Analysis/CFGPrinter.cpp llvm/lib/Analysis/CMakeLists.txt llvm/lib/Analysis/CallPrinter.cpp llvm/lib/CodeGen/MachineScheduler.cpp llvm/lib/CodeGen/ScheduleDAGPrinter.cpp llvm/lib/Passes/PassBuilder.cpp llvm/lib/Passes/PassRegistry.def Removed: llvm/include/llvm/Analysis/DDGPrinter.h llvm/lib/Analysis/DDGPrinter.cpp diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index f285b652c175..409741cdb6e4 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -3149,7 +3149,7 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { if (Stop(N)) return true; - if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc(), nullptr)) + if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc())) break; PostCallback(N); @@ -3158,7 +3158,7 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { return false; } - static bool isNodeHidden(const ExplodedNode *N, const ExplodedGraph *G) { + static bool isNodeHidden(const ExplodedNode *N) { return N->isTrivial(); } diff --git a/llvm/include/llvm/Analysis/CFGPrinter.h b/llvm/include/llvm/Analysis/CFGPrinter.h index 53700798b6b3..bc6a19f2e2b9 100644 --- a/llvm/include/llvm/Analysis/CFGPrinter.h +++ b/llvm/include/llvm/Analysis/CFGPrinter.h @@ -295,7 +295,7 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { " fillcolor=\"" + Color + "70\""; return Attrs; } - bool isNodeHidden(const BasicBlock *Node, const DOTFuncInfo *CFGInfo); + bool isNodeHidden(const BasicBlock *Node); void computeHiddenNodes(const Function *F); }; } // End llvm namespace diff --git a/llvm/include/llvm/Analysis/DDG.h b/llvm/include/llvm/Analysis/DDG.h index 8d225c155cd4..9e2b7907eaec 100644 --- a/llvm/include/llvm/Analysis/DDG.h +++ b/llvm/include/llvm/Analysis/DDG.h @@ -290,12 +290,6 @@ template class DependenceGraphInfo { bool getDependencies(const NodeType &Src, const NodeType &Dst, DependenceList &Deps) const; - /// Return a string representing the type of dependence that the dependence - /// analysis identified between the two given nodes. This function assumes - /// that there is a memory dependence between the given two nodes. - const std::string getDependenceString(const NodeType &Src, -const NodeType &Dst) const; - protected: // Name of the graph. std::string Name; @@ -469,26 +463,6 @@ bool DependenceGraphInfo::getDependencies( return !Deps.empty(); } -template -const std::string -DependenceGraphInfo::getDependenceString(const NodeType &Src, - const NodeType &Dst) const { - std::string Str; - raw_string_ostream OS(Str); - DependenceList Deps; - if (!getDependencies(Src, Dst, Deps)) -return OS.str(); - interleaveComma(Deps, OS, [&](const std::unique_ptr &D) { -D->dump(OS); -// Remove the extra new-line character printed by the dump -// method -if (OS.str().back() == '\n') - OS.str().pop_back(); - }); - - return OS.str(); -} - //======// // GraphTraits specializations for the DDG //======// diff --git a/llvm/include/llvm/Analysis/DDGPrinter.h b/llvm/include/llvm/Analysis/DDGPrinter.h deleted file mode 100644 index 5cfe2ce33c99.. --- a/llvm/include/llvm/Analysis/DDGPrinter.h +++ /dev/null @@ -1,91 +0,0 @@ -//===- llvm/Analysis/DDGPrinter.h ---*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===--===// - -//===--===// -// -// This file defin
[clang] 6eff127 - [DDG] Data Dependence Graph - DOT printer - recommit
Author: Bardia Mahjour Date: 2020-12-16T12:37:36-05:00 New Revision: 6eff12788ee8d3f85f6e57809e757ca3250813d8 URL: https://github.com/llvm/llvm-project/commit/6eff12788ee8d3f85f6e57809e757ca3250813d8 DIFF: https://github.com/llvm/llvm-project/commit/6eff12788ee8d3f85f6e57809e757ca3250813d8.diff LOG: [DDG] Data Dependence Graph - DOT printer - recommit This is being recommitted to try and address the MSVC complaint. This patch implements a DDG printer pass that generates a graph in the DOT description language, providing a more visually appealing representation of the DDG. Similar to the CFG DOT printer, this functionality is provided under an option called -dot-ddg and can be generated in a less verbose mode under -dot-ddg-only option. Reviewed By: Meinersbur Differential Revision: https://reviews.llvm.org/D90159 Added: llvm/include/llvm/Analysis/DDGPrinter.h llvm/lib/Analysis/DDGPrinter.cpp Modified: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp llvm/include/llvm/Analysis/CFGPrinter.h llvm/include/llvm/Analysis/DDG.h llvm/include/llvm/Support/DOTGraphTraits.h llvm/include/llvm/Support/GraphWriter.h llvm/lib/Analysis/CFGPrinter.cpp llvm/lib/Analysis/CMakeLists.txt llvm/lib/Analysis/CallPrinter.cpp llvm/lib/CodeGen/MachineScheduler.cpp llvm/lib/CodeGen/ScheduleDAGPrinter.cpp llvm/lib/Passes/PassBuilder.cpp llvm/lib/Passes/PassRegistry.def Removed: diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 409741cdb6e4..f285b652c175 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -3149,7 +3149,7 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { if (Stop(N)) return true; - if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc())) + if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc(), nullptr)) break; PostCallback(N); @@ -3158,7 +3158,7 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { return false; } - static bool isNodeHidden(const ExplodedNode *N) { + static bool isNodeHidden(const ExplodedNode *N, const ExplodedGraph *G) { return N->isTrivial(); } diff --git a/llvm/include/llvm/Analysis/CFGPrinter.h b/llvm/include/llvm/Analysis/CFGPrinter.h index bc6a19f2e2b9..53700798b6b3 100644 --- a/llvm/include/llvm/Analysis/CFGPrinter.h +++ b/llvm/include/llvm/Analysis/CFGPrinter.h @@ -295,7 +295,7 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { " fillcolor=\"" + Color + "70\""; return Attrs; } - bool isNodeHidden(const BasicBlock *Node); + bool isNodeHidden(const BasicBlock *Node, const DOTFuncInfo *CFGInfo); void computeHiddenNodes(const Function *F); }; } // End llvm namespace diff --git a/llvm/include/llvm/Analysis/DDG.h b/llvm/include/llvm/Analysis/DDG.h index 9e2b7907eaec..8d225c155cd4 100644 --- a/llvm/include/llvm/Analysis/DDG.h +++ b/llvm/include/llvm/Analysis/DDG.h @@ -290,6 +290,12 @@ template class DependenceGraphInfo { bool getDependencies(const NodeType &Src, const NodeType &Dst, DependenceList &Deps) const; + /// Return a string representing the type of dependence that the dependence + /// analysis identified between the two given nodes. This function assumes + /// that there is a memory dependence between the given two nodes. + const std::string getDependenceString(const NodeType &Src, +const NodeType &Dst) const; + protected: // Name of the graph. std::string Name; @@ -463,6 +469,26 @@ bool DependenceGraphInfo::getDependencies( return !Deps.empty(); } +template +const std::string +DependenceGraphInfo::getDependenceString(const NodeType &Src, + const NodeType &Dst) const { + std::string Str; + raw_string_ostream OS(Str); + DependenceList Deps; + if (!getDependencies(Src, Dst, Deps)) +return OS.str(); + interleaveComma(Deps, OS, [&](const std::unique_ptr &D) { +D->dump(OS); +// Remove the extra new-line character printed by the dump +// method +if (OS.str().back() == '\n') + OS.str().pop_back(); + }); + + return OS.str(); +} + //======// // GraphTraits specializations for the DDG //======// diff --git a/llvm/include/llvm/Analysis/DDGPrinter.h b/llvm/include/llvm/Analysis/DDGPrinter.h new file mode 100644 index ..4477b387fe50 --- /dev/null +++ b/llvm/include/llvm/Analysis/DDGPrinter.h @@ -0,0 +1,91 @@ +//===- llvm/Analysis/DDGPrinter.h ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exception
[clang] 2071ce9 - [Altivec] Use signed comparison for vec_all_* and vec_any_* interfaces
Author: Bardia Mahjour Date: 2021-07-12T11:41:16-04:00 New Revision: 2071ce9d4559d444a065d78248a7381bf121b766 URL: https://github.com/llvm/llvm-project/commit/2071ce9d4559d444a065d78248a7381bf121b766 DIFF: https://github.com/llvm/llvm-project/commit/2071ce9d4559d444a065d78248a7381bf121b766.diff LOG: [Altivec] Use signed comparison for vec_all_* and vec_any_* interfaces We are currently being inconsistent in using signed vs unsigned comparisons for vec_all_* and vec_any_* interfaces that use vector bool types. For example we use signed comparison for vec_all_ge(vector signed char, vector bool char) but unsigned comparison for when the arguments are swapped. GCC and XL use signed comparison instead. This patch makes clang consistent with itself and with XL and GCC. Reviewed By: nemanjai Differential Revision: https://reviews.llvm.org/D105666 Added: Modified: clang/lib/Headers/altivec.h clang/test/CodeGen/builtins-ppc-altivec.c clang/test/CodeGen/builtins-ppc-vsx.c Removed: diff --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h index 35dde8203b7f..862ec290e1c9 100644 --- a/clang/lib/Headers/altivec.h +++ b/clang/lib/Headers/altivec.h @@ -14894,8 +14894,7 @@ static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned char __a, static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool char __a, vector signed char __b) { - return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__b, - (vector unsigned char)__a); + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, __b, (vector signed char)__a); } static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool char __a, @@ -14932,8 +14931,7 @@ static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned short __a, static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a, vector short __b) { - return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__b, - (vector unsigned short)__a); + return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, __b, (vector signed short)__a); } static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a, @@ -14969,8 +14967,7 @@ static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned int __a, static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a, vector int __b) { - return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__b, - (vector unsigned int)__a); + return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, __b, (vector signed int)__a); } static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a, @@ -15008,8 +15005,8 @@ static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned long long __a, static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool long long __a, vector signed long long __b) { - return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__b, - (vector unsigned long long)__a); + return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __b, + (vector signed long long)__a); } static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool long long __a, @@ -15077,8 +15074,7 @@ static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned char __a, static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool char __a, vector signed char __b) { - return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__a, - (vector unsigned char)__b); + return __builtin_altivec_vcmpgtsb_p(__CR6_LT, (vector signed char)__a, __b); } static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool char __a, @@ -15115,8 +15111,7 @@ static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned short __a, static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a, vector short __b) { - return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__a, - (vector unsigned short)__b); + return __builtin_altivec_vcmpgtsh_p(__CR6_LT, (vector signed short)__a, __b); } static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a, @@ -15152,8 +15147,7 @@ static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned int __a, static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool int __a, vector int __b) { - return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__a, - (vector unsigned int)__b); + return __builtin_altivec_vcmpgtsw_p(__CR6_LT, (vect