[PATCH] D47643: Rewrite JSON dispatcher loop using C IO (FILE*) instead of std::istream.
malaperle added a comment. In https://reviews.llvm.org/D47643#1119187, @sammccall wrote: > @malaperle: would you mind patching this in and checking whether attaching a > debugger still works on Mac (this was the reason for the EINTR loop, right?) > > I want to preserve this but now people other than me are complaining about > old clangds hanging around and eating all their CPU :-) I tried the patch but as soon as I attach the debugger I get "IO error: Interrupted system call" from Clangd's stderr. I didn't get to look into this further. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D47643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47694: [CUDA][HIP] Do not emit type info when compiling for device
yaxunl added a comment. In https://reviews.llvm.org/D47694#1120367, @rjmccall wrote: > Why not just have the driver disable RTTI in the frontend invocation? CUDA/HIP uses single source for device and host. The host code may depend on RTTI, e.g., an application may include some boost headers which will fail if RTTI is disabled, therefore RTTI cannot be disabled when compiling device code. https://reviews.llvm.org/D47694 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r333865 - [X86] Fix a couple places that were using macro arguments twice when of the usages could just be undefined.
Author: ctopper Date: Sun Jun 3 19:56:18 2018 New Revision: 333865 URL: http://llvm.org/viewvc/llvm-project?rev=333865=rev Log: [X86] Fix a couple places that were using macro arguments twice when of the usages could just be undefined. One of the arguments was being used when the passthru argument is unused due to the mask being all 1s. But in that case the actual value doesn't matter so we should use undef instead to avoid expanding the macro argument unnecessarily. Modified: cfe/trunk/lib/Headers/avx512fintrin.h Modified: cfe/trunk/lib/Headers/avx512fintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=333865=333864=333865=diff == --- cfe/trunk/lib/Headers/avx512fintrin.h (original) +++ cfe/trunk/lib/Headers/avx512fintrin.h Sun Jun 3 19:56:18 2018 @@ -2519,7 +2519,8 @@ _mm512_maskz_div_ps(__mmask16 __U, __m51 #define _mm512_roundscale_ps(A, B) \ (__m512)__builtin_ia32_rndscaleps_mask((__v16sf)(__m512)(A), (int)(B), \ - (__v16sf)(__m512)(A), (__mmask16)-1, \ + (__v16sf)_mm512_undefined_ps(), \ + (__mmask16)-1, \ _MM_FROUND_CUR_DIRECTION) #define _mm512_mask_roundscale_ps(A, B, C, imm) \ @@ -2550,7 +2551,8 @@ _mm512_maskz_div_ps(__mmask16 __U, __m51 #define _mm512_roundscale_pd(A, B) \ (__m512d)__builtin_ia32_rndscalepd_mask((__v8df)(__m512d)(A), (int)(B), \ - (__v8df)(__m512d)(A), (__mmask8)-1, \ + (__v8df)_mm512_undefined_pd(), \ + (__mmask8)-1, \ _MM_FROUND_CUR_DIRECTION) #define _mm512_mask_roundscale_pd(A, B, C, imm) \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46805: If some platforms do not support an attribute, we should exclude the platform
HLJ2009 updated this revision to Diff 149665. HLJ2009 added a comment. update test case. Repository: rC Clang https://reviews.llvm.org/D46805 Files: include/clang/Basic/Attr.td test/Sema/attr-alias-has.c test/Sema/attr-alias.c Index: test/Sema/attr-alias.c === --- test/Sema/attr-alias.c +++ test/Sema/attr-alias.c @@ -2,4 +2,4 @@ void g() {} -void f() __attribute__((alias("g"))); //expected-error {{aliases are not supported on darwin}} +void f() __attribute__((alias("g"))); //expected-warning {{unknown attribute 'alias' ignored}} Index: test/Sema/attr-alias-has.c === --- /dev/null +++ test/Sema/attr-alias-has.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple wasm64-unknown-unknown -fsyntax-only -verify %s + +void g() {} +#if !__has_attribute(alias) +void f() __attribute__((alias("g"))); // expected-warning {{unknown attribute 'alias' ignored}} +#else +void f() __attribute__((alias("g"))); // expected-no-diagnostics +#endif \ No newline at end of file Index: include/clang/Basic/Attr.td === --- include/clang/Basic/Attr.td +++ include/clang/Basic/Attr.td @@ -318,6 +318,9 @@ def TargetELF : TargetSpec { let ObjectFormats = ["ELF"]; } +def TargetSupportsAlias : TargetSpec { + let ObjectFormats = ["COFF", "ELF", "Wasm"]; +} // Attribute subject match rules that are used for #pragma clang attribute. // @@ -554,7 +557,7 @@ let Documentation = [Undocumented]; } -def Alias : Attr { +def Alias : Attr, TargetSpecificAttr { let Spellings = [GCC<"alias">]; let Args = [StringArgument<"Aliasee">]; let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>; Index: test/Sema/attr-alias.c === --- test/Sema/attr-alias.c +++ test/Sema/attr-alias.c @@ -2,4 +2,4 @@ void g() {} -void f() __attribute__((alias("g"))); //expected-error {{aliases are not supported on darwin}} +void f() __attribute__((alias("g"))); //expected-warning {{unknown attribute 'alias' ignored}} Index: test/Sema/attr-alias-has.c === --- /dev/null +++ test/Sema/attr-alias-has.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple wasm64-unknown-unknown -fsyntax-only -verify %s + +void g() {} +#if !__has_attribute(alias) +void f() __attribute__((alias("g"))); // expected-warning {{unknown attribute 'alias' ignored}} +#else +void f() __attribute__((alias("g"))); // expected-no-diagnostics +#endif \ No newline at end of file Index: include/clang/Basic/Attr.td === --- include/clang/Basic/Attr.td +++ include/clang/Basic/Attr.td @@ -318,6 +318,9 @@ def TargetELF : TargetSpec { let ObjectFormats = ["ELF"]; } +def TargetSupportsAlias : TargetSpec { + let ObjectFormats = ["COFF", "ELF", "Wasm"]; +} // Attribute subject match rules that are used for #pragma clang attribute. // @@ -554,7 +557,7 @@ let Documentation = [Undocumented]; } -def Alias : Attr { +def Alias : Attr, TargetSpecificAttr { let Spellings = [GCC<"alias">]; let Args = [StringArgument<"Aliasee">]; let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47694: [CUDA][HIP] Do not emit type info when compiling for device
rjmccall added a comment. Why not just have the driver disable RTTI in the frontend invocation? https://reviews.llvm.org/D47694 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45517: [analyzer] False positive refutation with Z3
mikhail.ramalho updated this revision to Diff 149664. mikhail.ramalho edited the summary of this revision. mikhail.ramalho added a comment. Fix naming issue. https://reviews.llvm.org/D45517 Files: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h lib/StaticAnalyzer/Core/AnalyzerOptions.cpp lib/StaticAnalyzer/Core/BugReporter.cpp lib/StaticAnalyzer/Core/BugReporterVisitors.cpp test/Analysis/z3-crosscheck.c Index: test/Analysis/z3-crosscheck.c === --- /dev/null +++ test/Analysis/z3-crosscheck.c @@ -0,0 +1,51 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -DNO_CROSSCHECK -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config crosscheck-with-z3=true -verify %s +// REQUIRES: z3 + +int foo(int x) +{ + int *z = 0; + if ((x & 1) && ((x & 1) ^ 1)) +#ifdef NO_CROSSCHECK + return *z; // expected-warning {{Dereference of null pointer (loaded from variable 'z')}} +#else + return *z; // no-warning +#endif + return 0; +} + +void g(int d); + +void f(int *a, int *b) { + int c = 5; + if ((a - b) == 0) +c = 0; + if (a != b) +#ifdef NO_CROSSCHECK +g(3 / c); // expected-warning {{Division by zero}} +#else +g(3 / c); // no-warning +#endif +} + +_Bool nondet_bool(); + +void h(int d) { + int x, y, k, z = 1; +#ifdef NO_CROSSCHECK + while (z < k) { // expected-warning {{The right operand of '<' is a garbage value}} +#else + while (z < k) { // expected-warning {{The right operand of '<' is a garbage value}} +#endif +z = 2 * z; + } +} + +void i() { + _Bool c = nondet_bool(); + if (c) { +h(1); + } else { +h(2); + } +} Index: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp === --- lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -44,6 +44,7 @@ #include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/None.h" #include "llvm/ADT/Optional.h" @@ -2354,3 +2355,46 @@ return std::make_shared(L, "Taint originated here"); } + +static bool +areConstraintsUnfeasible(BugReporterContext , + const llvm::SmallVector ) { + // Create a refutation manager + std::unique_ptr RefutationMgr = CreateZ3ConstraintManager( + BRC.getStateManager(), BRC.getStateManager().getOwningEngine()); + + SMTConstraintManager *SMTRefutationMgr = + static_cast(RefutationMgr.get()); + + // Add constraints to the solver + for (const auto : Cs) +SMTRefutationMgr->addRangeConstraints(C); + + // And check for satisfiability + return SMTRefutationMgr->isModelFeasible().isConstrainedFalse(); +} + +std::shared_ptr +FalsePositiveRefutationBRVisitor::VisitNode(const ExplodedNode *N, +const ExplodedNode *PrevN, +BugReporterContext , +BugReport ) { + // Collect the constraint for the current state + const ConstraintRangeTy = N->getState()->get(); + Constraints.push_back(CR); + + // If there are no predecessor, we reached the root node. In this point, + // a new refutation manager will be created and the path will be checked + // for reachability + if (PrevN->pred_size() == 0 && areConstraintsUnfeasible(BRC, Constraints)) { +BR.markInvalid("Infeasible constraints", N->getLocationContext()); + } + + return nullptr; +} + +void FalsePositiveRefutationBRVisitor::Profile( +llvm::FoldingSetNodeID ) const { + static int Tag = 0; + ID.AddPointer(); +} Index: lib/StaticAnalyzer/Core/BugReporter.cpp === --- lib/StaticAnalyzer/Core/BugReporter.cpp +++ lib/StaticAnalyzer/Core/BugReporter.cpp @@ -3143,10 +3143,15 @@ PathDiagnosticBuilder PDB(*this, R, ErrorGraph.BackMap, ); const ExplodedNode *N = ErrorGraph.ErrorNode; +// Register refutation visitors first, if they mark the bug invalid no +// further analysis is required +R->addVisitor(llvm::make_unique()); +if (getAnalyzerOptions().shouldCrosscheckWithZ3()) + R->addVisitor(llvm::make_unique()); + // Register additional node visitors. R->addVisitor(llvm::make_unique()); R->addVisitor(llvm::make_unique()); -R->addVisitor(llvm::make_unique()); R->addVisitor(llvm::make_unique()); BugReport::VisitorList visitors; Index: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp === ---
[PATCH] D47640: Moved RangedConstraintManager header to the StaticAnalyser include dir
This revision was automatically updated to reflect the committed changes. Closed by commit rC333862: Moved RangedConstraintManager header to the StaticAnalyser include dir (authored by mramalho, committed by ). Herald added a subscriber: cfe-commits. Changed prior to commit: https://reviews.llvm.org/D47640?vs=149650=149662#toc Repository: rC Clang https://reviews.llvm.org/D47640 Files: include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h lib/StaticAnalyzer/Core/RangeConstraintManager.cpp lib/StaticAnalyzer/Core/RangedConstraintManager.cpp lib/StaticAnalyzer/Core/RangedConstraintManager.h Index: include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h @@ -0,0 +1,214 @@ +//== RangedConstraintManager.h --*- C++ -*--==// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +// +// Ranged constraint manager, built on SimpleConstraintManager. +// +//===--===// + +#ifndef LLVM_CLANG_LIB_STATICANALYZER_CORE_RANGEDCONSTRAINTMANAGER_H +#define LLVM_CLANG_LIB_STATICANALYZER_CORE_RANGEDCONSTRAINTMANAGER_H + +#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h" + +namespace clang { + +namespace ento { + +/// A Range represents the closed range [from, to]. The caller must +/// guarantee that from <= to. Note that Range is immutable, so as not +/// to subvert RangeSet's immutability. +class Range : public std::pair { +public: + Range(const llvm::APSInt , const llvm::APSInt ) + : std::pair(, ) { +assert(from <= to); + } + bool Includes(const llvm::APSInt ) const { +return *first <= v && v <= *second; + } + const llvm::APSInt () const { return *first; } + const llvm::APSInt () const { return *second; } + const llvm::APSInt *getConcreteValue() const { +return () == () ? () : nullptr; + } + + void Profile(llvm::FoldingSetNodeID ) const { +ID.AddPointer(()); +ID.AddPointer(()); + } +}; + +class RangeTrait : public llvm::ImutContainerInfo { +public: + // When comparing if one Range is less than another, we should compare + // the actual APSInt values instead of their pointers. This keeps the order + // consistent (instead of comparing by pointer values) and can potentially + // be used to speed up some of the operations in RangeSet. + static inline bool isLess(key_type_ref lhs, key_type_ref rhs) { +return *lhs.first < *rhs.first || + (!(*rhs.first < *lhs.first) && *lhs.second < *rhs.second); + } +}; + +/// RangeSet contains a set of ranges. If the set is empty, then +/// there the value of a symbol is overly constrained and there are no +/// possible values for that symbol. +class RangeSet { + typedef llvm::ImmutableSet PrimRangeSet; + PrimRangeSet ranges; // no need to make const, since it is an + // ImmutableSet - this allows default operator= + // to work. +public: + typedef PrimRangeSet::Factory Factory; + typedef PrimRangeSet::iterator iterator; + + RangeSet(PrimRangeSet RS) : ranges(RS) {} + + /// Create a new set with all ranges of this set and RS. + /// Possible intersections are not checked here. + RangeSet addRange(Factory , const RangeSet ) { +PrimRangeSet Ranges(RS.ranges); +for (const auto : ranges) + Ranges = F.add(Ranges, range); +return RangeSet(Ranges); + } + + iterator begin() const { return ranges.begin(); } + iterator end() const { return ranges.end(); } + + bool isEmpty() const { return ranges.isEmpty(); } + + /// Construct a new RangeSet representing '{ [from, to] }'. + RangeSet(Factory , const llvm::APSInt , const llvm::APSInt ) + : ranges(F.add(F.getEmptySet(), Range(from, to))) {} + + /// Profile - Generates a hash profile of this RangeSet for use + /// by FoldingSet. + void Profile(llvm::FoldingSetNodeID ) const { ranges.Profile(ID); } + + /// getConcreteValue - If a symbol is contrained to equal a specific integer + /// constant then this method returns that value. Otherwise, it returns + /// NULL. + const llvm::APSInt *getConcreteValue() const { +return ranges.isSingleton() ? ranges.begin()->getConcreteValue() : nullptr; + } + +private: + void IntersectInRange(BasicValueFactory , Factory , +const llvm::APSInt , const llvm::APSInt , +PrimRangeSet ,
[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.
shuaiwang added a comment. Overestimated the work of supporting typeid and _Generic, done now. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.
shuaiwang updated this revision to Diff 149661. shuaiwang marked 4 inline comments as done. shuaiwang added a comment. Handle typeid and generic selection. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 Files: clang-tidy/utils/CMakeLists.txt clang-tidy/utils/ExprMutationAnalyzer.cpp clang-tidy/utils/ExprMutationAnalyzer.h unittests/clang-tidy/CMakeLists.txt unittests/clang-tidy/ExprMutationAnalyzerTest.cpp Index: unittests/clang-tidy/ExprMutationAnalyzerTest.cpp === --- /dev/null +++ unittests/clang-tidy/ExprMutationAnalyzerTest.cpp @@ -0,0 +1,608 @@ +//===-- ExprMutationAnalyzerTest.cpp - clang-tidy -===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "../clang-tidy/utils/ExprMutationAnalyzer.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/ASTMatchers/ASTMatchers.h" +#include "clang/Tooling/Tooling.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +namespace clang { +namespace tidy { +namespace test { + +using namespace clang::ast_matchers; +using ::testing::ElementsAre; +using ::testing::IsEmpty; +using ::testing::ResultOf; +using ::testing::StartsWith; +using ::testing::Values; + +namespace { + +using ExprMatcher = internal::Matcher; +using StmtMatcher = internal::Matcher; + +ExprMatcher declRefTo(StringRef Name) { + return declRefExpr(to(namedDecl(hasName(Name; +} + +StmtMatcher withEnclosingCompound(ExprMatcher Matcher) { + return expr(Matcher, hasAncestor(compoundStmt().bind("stmt"))).bind("expr"); +} + +bool isMutated(const SmallVectorImpl , ASTUnit *AST) { + const auto *const S = selectFirst("stmt", Results); + const auto *const E = selectFirst("expr", Results); + return utils::ExprMutationAnalyzer(S, >getASTContext()).isMutated(E); +} + +SmallVector +mutatedBy(const SmallVectorImpl , ASTUnit *AST) { + const auto *const S = selectFirst("stmt", Results); + SmallVector Chain; + utils::ExprMutationAnalyzer Analyzer(S, >getASTContext()); + for (const auto *E = selectFirst("expr", Results); E != nullptr;) { +const Stmt *By = Analyzer.findMutation(E); +std::string buffer; +llvm::raw_string_ostream stream(buffer); +By->printPretty(stream, nullptr, AST->getASTContext().getPrintingPolicy()); +Chain.push_back(StringRef(stream.str()).trim().str()); +E = dyn_cast(By); + } + return Chain; +} + +std::string removeSpace(std::string s) { + s.erase(std::remove_if(s.begin(), s.end(), + [](char c) { return std::isspace(c); }), + s.end()); + return s; +} + +} // namespace + +TEST(ExprMutationAnalyzerTest, Trivial) { + const auto AST = tooling::buildASTFromCode("void f() { int x; x; }"); + const auto Results = + match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); + EXPECT_FALSE(isMutated(Results, AST.get())); +} + +class AssignmentTest : public ::testing::TestWithParam {}; + +TEST_P(AssignmentTest, AssignmentModifies) { + const std::string ModExpr = "x " + GetParam() + " 10"; + const auto AST = + tooling::buildASTFromCode("void f() { int x; " + ModExpr + "; }"); + const auto Results = + match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); + EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr)); +} + +INSTANTIATE_TEST_CASE_P(AllAssignmentOperators, AssignmentTest, +Values("=", "+=", "-=", "*=", "/=", "%=", "&=", "|=", + "^=", "<<=", ">>="), ); + +class IncDecTest : public ::testing::TestWithParam {}; + +TEST_P(IncDecTest, IncDecModifies) { + const std::string ModExpr = GetParam(); + const auto AST = + tooling::buildASTFromCode("void f() { int x; " + ModExpr + "; }"); + const auto Results = + match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); + EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr)); +} + +INSTANTIATE_TEST_CASE_P(AllIncDecOperators, IncDecTest, +Values("++x", "--x", "x++", "x--"), ); + +TEST(ExprMutationAnalyzerTest, NonConstMemberFunc) { + const auto AST = tooling::buildASTFromCode( + "void f() { struct Foo { void mf(); }; Foo x; x.mf(); }"); + const auto Results = + match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); + EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()")); +} + +TEST(ExprMutationAnalyzerTest, ConstMemberFunc) { + const auto AST = tooling::buildASTFromCode( + "void f() { struct Foo { void mf() const; }; Foo x; x.mf(); }"); + const auto Results = + match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); + EXPECT_FALSE(isMutated(Results, AST.get())); +} + +TEST(ExprMutationAnalyzerTest,
[PATCH] D47376: [CUDA][HIP] Do not offload for -M
yaxunl added a comment. ping https://reviews.llvm.org/D47376 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47694: [CUDA][HIP] Do not emit type info when compiling for device
yaxunl created this revision. yaxunl added reviewers: rjmccall, tra. CUDA/HIP does not support RTTI on device side, therefore there is no point of emitting type info when compiling for device. Emitting type info for device not only clutters the IR with useless global variables, but also causes undefined symbol at linking since vtable for __cxxabiv1::__class_type_info has external linkage. https://reviews.llvm.org/D47694 Files: lib/CodeGen/CodeGenModule.cpp test/CodeGenCUDA/device-vtable.cu Index: test/CodeGenCUDA/device-vtable.cu === --- test/CodeGenCUDA/device-vtable.cu +++ test/CodeGenCUDA/device-vtable.cu @@ -19,15 +19,19 @@ //CHECK-HOST: @_ZTV1H = //CHECK-HOST-SAME: @_ZN1H6methodEv //CHECK-DEVICE-NOT: @_ZTV1H = - +//CHECK-DEVICE-NOT: @_ZTVN10__cxxabiv117__class_type_infoE +//CHECK-DEVICE-NOT: @_ZTS1H +//CHECK-DEVICE-NOT: @_ZTI1H struct D { __device__ virtual void method(); }; //CHECK-DEVICE: @_ZTV1D //CHECK-DEVICE-SAME: @_ZN1D6methodEv //CHECK-HOST-NOT: @_ZTV1D - +//CHECK-DEVICE-NOT: @_ZTVN10__cxxabiv117__class_type_infoE +//CHECK-DEVICE-NOT: @_ZTS1D +//CHECK-DEVICE-NOT: @_ZTI1D // This is the case with mixed host and device virtual methods. It's // impossible to emit a valid vtable in that case because only host or // only device methods would be available during host or device @@ -45,6 +49,9 @@ // CHECK-HOST-NOT: @_ZN2HD8d_methodEv // CHECK-HOST-SAME: null // CHECK-BOTH-SAME: ] +// CHECK-DEVICE-NOT: @_ZTVN10__cxxabiv117__class_type_infoE +// CHECK-DEVICE-NOT: @_ZTS2HD +// CHECK-DEVICE-NOT: @_ZTI2HD void H::method() {} //CHECK-HOST: define void @_ZN1H6methodEv Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -4899,7 +4899,8 @@ // Return a bogus pointer if RTTI is disabled, unless it's for EH. // FIXME: should we even be calling this method if RTTI is disabled // and it's not for EH? - if (!ForEH && !getLangOpts().RTTI) + if ((!ForEH && !getLangOpts().RTTI) || + (getLangOpts().CUDA && getLangOpts().CUDAIsDevice)) return llvm::Constant::getNullValue(Int8PtrTy); if (ForEH && Ty->isObjCObjectPointerType() && Index: test/CodeGenCUDA/device-vtable.cu === --- test/CodeGenCUDA/device-vtable.cu +++ test/CodeGenCUDA/device-vtable.cu @@ -19,15 +19,19 @@ //CHECK-HOST: @_ZTV1H = //CHECK-HOST-SAME: @_ZN1H6methodEv //CHECK-DEVICE-NOT: @_ZTV1H = - +//CHECK-DEVICE-NOT: @_ZTVN10__cxxabiv117__class_type_infoE +//CHECK-DEVICE-NOT: @_ZTS1H +//CHECK-DEVICE-NOT: @_ZTI1H struct D { __device__ virtual void method(); }; //CHECK-DEVICE: @_ZTV1D //CHECK-DEVICE-SAME: @_ZN1D6methodEv //CHECK-HOST-NOT: @_ZTV1D - +//CHECK-DEVICE-NOT: @_ZTVN10__cxxabiv117__class_type_infoE +//CHECK-DEVICE-NOT: @_ZTS1D +//CHECK-DEVICE-NOT: @_ZTI1D // This is the case with mixed host and device virtual methods. It's // impossible to emit a valid vtable in that case because only host or // only device methods would be available during host or device @@ -45,6 +49,9 @@ // CHECK-HOST-NOT: @_ZN2HD8d_methodEv // CHECK-HOST-SAME: null // CHECK-BOTH-SAME: ] +// CHECK-DEVICE-NOT: @_ZTVN10__cxxabiv117__class_type_infoE +// CHECK-DEVICE-NOT: @_ZTS2HD +// CHECK-DEVICE-NOT: @_ZTI2HD void H::method() {} //CHECK-HOST: define void @_ZN1H6methodEv Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -4899,7 +4899,8 @@ // Return a bogus pointer if RTTI is disabled, unless it's for EH. // FIXME: should we even be calling this method if RTTI is disabled // and it's not for EH? - if (!ForEH && !getLangOpts().RTTI) + if ((!ForEH && !getLangOpts().RTTI) || + (getLangOpts().CUDA && getLangOpts().CUDAIsDevice)) return llvm::Constant::getNullValue(Int8PtrTy); if (ForEH && Ty->isObjCObjectPointerType() && ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r333858 - [X86] Remove superfluous escaped new lines from intrinsic files.
Author: ctopper Date: Sun Jun 3 16:31:01 2018 New Revision: 333858 URL: http://llvm.org/viewvc/llvm-project?rev=333858=rev Log: [X86] Remove superfluous escaped new lines from intrinsic files. Modified: cfe/trunk/lib/Headers/avx512fintrin.h Modified: cfe/trunk/lib/Headers/avx512fintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=333858=333857=333858=diff == --- cfe/trunk/lib/Headers/avx512fintrin.h (original) +++ cfe/trunk/lib/Headers/avx512fintrin.h Sun Jun 3 16:31:01 2018 @@ -2915,7 +2915,7 @@ _mm512_mask_fmadd_ps(__m512 __A, __mmask __builtin_ia32_vfmaddps512 ((__v16sf) __A, (__v16sf) __B, (__v16sf) __C, -_MM_FROUND_CUR_DIRECTION), \ +_MM_FROUND_CUR_DIRECTION), (__v16sf) __A); } @@ -2926,7 +2926,7 @@ _mm512_mask3_fmadd_ps(__m512 __A, __m512 __builtin_ia32_vfmaddps512 ((__v16sf) __A, (__v16sf) __B, (__v16sf) __C, -_MM_FROUND_CUR_DIRECTION), \ +_MM_FROUND_CUR_DIRECTION), (__v16sf) __C); } @@ -3230,7 +3230,7 @@ _mm512_mask_fmaddsub_ps(__m512 __A, __mm __builtin_ia32_vfmaddsubps512 ((__v16sf) __A, (__v16sf) __B, (__v16sf) __C, - _MM_FROUND_CUR_DIRECTION), \ + _MM_FROUND_CUR_DIRECTION), (__v16sf) __A); } @@ -3241,7 +3241,7 @@ _mm512_mask3_fmaddsub_ps(__m512 __A, __m __builtin_ia32_vfmaddsubps512 ((__v16sf) __A, (__v16sf) __B, (__v16sf) __C, - _MM_FROUND_CUR_DIRECTION), \ + _MM_FROUND_CUR_DIRECTION), (__v16sf) __C); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.
shuaiwang added inline comments. Comment at: clang-tidy/utils/ExprMutationAnalyzer.cpp:34-38 +const ast_matchers::internal::VariadicDynCastAllOfMatcher +cxxTypeidExpr; + +const ast_matchers::internal::VariadicDynCastAllOfMatcher +cxxNoexceptExpr; aaron.ballman wrote: > I think these should be exposed as public AST matchers, as they're both > generally useful. It can be done in a follow-up patch, or done before landing > this patch, either is fine by me. Will leave as follow up patch. Comment at: clang-tidy/utils/ExprMutationAnalyzer.cpp:67 + +bool ExprMutationAnalyzer::isUnevaluated(const Expr *Exp) { + return selectFirst( aaron.ballman wrote: > What about other unevaluated expressions, like `typeof`, `_Generic`, etc? You > should search for `ExpressionEvaluationContext::Unevaluated` in Clang to see > where we set up an unevaluated expression evaluation context to find all of > the situations. I checked around and I think these are all we care about: - decltype/typeof - sizeof/alignof - noexcept - _Generic - typeid I've added TODO for _Generic and typeid for now because I think those need a bit more work to implement, while at the same time not supporting them for now only creates false positives from isMutated which is what we prefer over false negatives. Comment at: clang-tidy/utils/ExprMutationAnalyzer.cpp:72 + findAll(expr(equalsNode(Exp), + anyOf(hasAncestor(typeLoc()), +hasAncestor(expr(anyOf( aaron.ballman wrote: > What is this trying to match with the `typeLoc()` matcher? Added comment to explain. Comment at: clang-tidy/utils/ExprMutationAnalyzer.cpp:74-75 +hasAncestor(expr(anyOf( +unaryExprOrTypeTraitExpr(), +cxxTypeidExpr(), cxxNoexceptExpr()) + .bind("expr")), aaron.ballman wrote: > I think these are only approximations to testing whether it's unevaluated. > For instance, won't this match these expressions, despite them being > evaluated? > ``` > // C++ > #include > > struct B { > virtual ~B() = default; > }; > > struct D : B {}; > > B& get() { > static B *b = new D; > return *b; > } > > void f() { > (void)typeid(get()); // Evaluated, calls get() > } > > /* C99 and later */ > #include > > void f(size_t n) { > (void)sizeof(int[++n]); // Evaluated, increments n > } > ``` Fixed handling of sizeof(VLA) Added TODO for typeid Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.
shuaiwang updated this revision to Diff 149659. shuaiwang marked 5 inline comments as done. shuaiwang added a comment. Handle sizeof on VLA. Added test case for typeof() Added TODO for handling typeid and generic selection. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 Files: clang-tidy/utils/CMakeLists.txt clang-tidy/utils/ExprMutationAnalyzer.cpp clang-tidy/utils/ExprMutationAnalyzer.h unittests/clang-tidy/CMakeLists.txt unittests/clang-tidy/ExprMutationAnalyzerTest.cpp Index: unittests/clang-tidy/ExprMutationAnalyzerTest.cpp === --- /dev/null +++ unittests/clang-tidy/ExprMutationAnalyzerTest.cpp @@ -0,0 +1,591 @@ +//===-- ExprMutationAnalyzerTest.cpp - clang-tidy -===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "../clang-tidy/utils/ExprMutationAnalyzer.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/ASTMatchers/ASTMatchers.h" +#include "clang/Tooling/Tooling.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +namespace clang { +namespace tidy { +namespace test { + +using namespace clang::ast_matchers; +using ::testing::ElementsAre; +using ::testing::IsEmpty; +using ::testing::ResultOf; +using ::testing::StartsWith; +using ::testing::Values; + +namespace { + +using ExprMatcher = internal::Matcher; +using StmtMatcher = internal::Matcher; + +ExprMatcher declRefTo(StringRef Name) { + return declRefExpr(to(namedDecl(hasName(Name; +} + +StmtMatcher withEnclosingCompound(ExprMatcher Matcher) { + return expr(Matcher, hasAncestor(compoundStmt().bind("stmt"))).bind("expr"); +} + +bool isMutated(const SmallVectorImpl , ASTUnit *AST) { + const auto *const S = selectFirst("stmt", Results); + const auto *const E = selectFirst("expr", Results); + return utils::ExprMutationAnalyzer(S, >getASTContext()).isMutated(E); +} + +SmallVector +mutatedBy(const SmallVectorImpl , ASTUnit *AST) { + const auto *const S = selectFirst("stmt", Results); + SmallVector Chain; + utils::ExprMutationAnalyzer Analyzer(S, >getASTContext()); + for (const auto *E = selectFirst("expr", Results); E != nullptr;) { +const Stmt *By = Analyzer.findMutation(E); +std::string buffer; +llvm::raw_string_ostream stream(buffer); +By->printPretty(stream, nullptr, AST->getASTContext().getPrintingPolicy()); +Chain.push_back(StringRef(stream.str()).trim().str()); +E = dyn_cast(By); + } + return Chain; +} + +std::string removeSpace(std::string s) { + s.erase(std::remove_if(s.begin(), s.end(), + [](char c) { return std::isspace(c); }), + s.end()); + return s; +} + +} // namespace + +TEST(ExprMutationAnalyzerTest, Trivial) { + const auto AST = tooling::buildASTFromCode("void f() { int x; x; }"); + const auto Results = + match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); + EXPECT_FALSE(isMutated(Results, AST.get())); +} + +class AssignmentTest : public ::testing::TestWithParam {}; + +TEST_P(AssignmentTest, AssignmentModifies) { + const std::string ModExpr = "x " + GetParam() + " 10"; + const auto AST = + tooling::buildASTFromCode("void f() { int x; " + ModExpr + "; }"); + const auto Results = + match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); + EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr)); +} + +INSTANTIATE_TEST_CASE_P(AllAssignmentOperators, AssignmentTest, +Values("=", "+=", "-=", "*=", "/=", "%=", "&=", "|=", + "^=", "<<=", ">>="), ); + +class IncDecTest : public ::testing::TestWithParam {}; + +TEST_P(IncDecTest, IncDecModifies) { + const std::string ModExpr = GetParam(); + const auto AST = + tooling::buildASTFromCode("void f() { int x; " + ModExpr + "; }"); + const auto Results = + match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); + EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr)); +} + +INSTANTIATE_TEST_CASE_P(AllIncDecOperators, IncDecTest, +Values("++x", "--x", "x++", "x--"), ); + +TEST(ExprMutationAnalyzerTest, NonConstMemberFunc) { + const auto AST = tooling::buildASTFromCode( + "void f() { struct Foo { void mf(); }; Foo x; x.mf(); }"); + const auto Results = + match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); + EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()")); +} + +TEST(ExprMutationAnalyzerTest, ConstMemberFunc) { + const auto AST = tooling::buildASTFromCode( + "void f() { struct Foo { void mf() const; }; Foo x; x.mf(); }"); + const auto Results = + match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); +
[PATCH] D45517: [analyzer] False positive refutation with Z3
george.karpenkov added a comment. > I pretty sure it was not related to the optimizations, I removed them days ago (in the previous version of this patch) and the bug was still there. OK so any idea what the change could have been? Clearly the bug was there but not now. Anyway, should be OK to commit now. > I update my repo every other day and it's been happening for the past two/three weeks :/ If it happens with your patch reverted as well, then it's unrelated, and we should just commit. https://reviews.llvm.org/D45517 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47693: [X86] Use target independent masked expandload and compressstore intrinsics to implement expandload/compressstore builtins.
craig.topper created this revision. craig.topper added reviewers: RKSimon, delena, spatel, GBuella. Herald added a subscriber: cfe-commits. We've had these target independent intrinsics for at least a year and a half. Looks like they do exactly what we need here and the backend already supports them. Repository: rC Clang https://reviews.llvm.org/D47693 Files: lib/CodeGen/CGBuiltin.cpp test/CodeGen/avx512f-builtins.c test/CodeGen/avx512vbmi2-builtins.c test/CodeGen/avx512vl-builtins.c test/CodeGen/avx512vlvbmi2-builtins.c Index: test/CodeGen/avx512vlvbmi2-builtins.c === --- test/CodeGen/avx512vlvbmi2-builtins.c +++ test/CodeGen/avx512vlvbmi2-builtins.c @@ -28,13 +28,13 @@ void test_mm_mask_compressstoreu_epi16(void *__P, __mmask8 __U, __m128i __D) { // CHECK-LABEL: @test_mm_mask_compressstoreu_epi16 - // CHECK: @llvm.x86.avx512.mask.compress.store.w.128 + // CHECK: @llvm.masked.compressstore.v8i16(<8 x i16> %{{.*}}, i16* %{{.*}}, <8 x i1> %{{.*}}) _mm_mask_compressstoreu_epi16(__P, __U, __D); } void test_mm_mask_compressstoreu_epi8(void *__P, __mmask16 __U, __m128i __D) { // CHECK-LABEL: @test_mm_mask_compressstoreu_epi8 - // CHECK: @llvm.x86.avx512.mask.compress.store.b.128 + // CHECK: @llvm.masked.compressstore.v16i8(<16 x i8> %{{.*}}, i8* %{{.*}}, <16 x i1> %{{.*}}) _mm_mask_compressstoreu_epi8(__P, __U, __D); } @@ -64,25 +64,25 @@ __m128i test_mm_mask_expandloadu_epi16(__m128i __S, __mmask8 __U, void const* __P) { // CHECK-LABEL: @test_mm_mask_expandloadu_epi16 - // CHECK: @llvm.x86.avx512.mask.expand.load.w.128 + // CHECK: @llvm.masked.expandload.v8i16(i16* %{{.*}}, <8 x i1> %{{.*}}, <8 x i16> %{{.*}}) return _mm_mask_expandloadu_epi16(__S, __U, __P); } __m128i test_mm_maskz_expandloadu_epi16(__mmask8 __U, void const* __P) { // CHECK-LABEL: @test_mm_maskz_expandloadu_epi16 - // CHECK: @llvm.x86.avx512.mask.expand.load.w.128 + // CHECK: @llvm.masked.expandload.v8i16(i16* %{{.*}}, <8 x i1> %{{.*}}, <8 x i16> %{{.*}}) return _mm_maskz_expandloadu_epi16(__U, __P); } __m128i test_mm_mask_expandloadu_epi8(__m128i __S, __mmask16 __U, void const* __P) { // CHECK-LABEL: @test_mm_mask_expandloadu_epi8 - // CHECK: @llvm.x86.avx512.mask.expand.load.b.128 + // CHECK: @llvm.masked.expandload.v16i8(i8* %{{.*}}, <16 x i1> %{{.*}}, <16 x i8> %{{.*}}) return _mm_mask_expandloadu_epi8(__S, __U, __P); } __m128i test_mm_maskz_expandloadu_epi8(__mmask16 __U, void const* __P) { // CHECK-LABEL: @test_mm_maskz_expandloadu_epi8 - // CHECK: @llvm.x86.avx512.mask.expand.load.b.128 + // CHECK: @llvm.masked.expandload.v16i8(i8* %{{.*}}, <16 x i1> %{{.*}}, <16 x i8> %{{.*}}) return _mm_maskz_expandloadu_epi8(__U, __P); } @@ -112,13 +112,13 @@ void test_mm256_mask_compressstoreu_epi16(void *__P, __mmask16 __U, __m256i __D) { // CHECK-LABEL: @test_mm256_mask_compressstoreu_epi16 - // CHECK: @llvm.x86.avx512.mask.compress.store.w.256 + // CHECK: @llvm.masked.compressstore.v16i16(<16 x i16> %{{.*}}, i16* %{{.*}}, <16 x i1> %{{.*}}) _mm256_mask_compressstoreu_epi16(__P, __U, __D); } void test_mm256_mask_compressstoreu_epi8(void *__P, __mmask32 __U, __m256i __D) { // CHECK-LABEL: @test_mm256_mask_compressstoreu_epi8 - // CHECK: @llvm.x86.avx512.mask.compress.store.b.256 + // CHECK: @llvm.masked.compressstore.v32i8(<32 x i8> %{{.*}}, i8* %{{.*}}, <32 x i1> %{{.*}}) _mm256_mask_compressstoreu_epi8(__P, __U, __D); } @@ -148,25 +148,25 @@ __m256i test_mm256_mask_expandloadu_epi16(__m256i __S, __mmask16 __U, void const* __P) { // CHECK-LABEL: @test_mm256_mask_expandloadu_epi16 - // CHECK: @llvm.x86.avx512.mask.expand.load.w.256 + // CHECK: @llvm.masked.expandload.v16i16(i16* %{{.*}}, <16 x i1> %{{.*}}, <16 x i16> %{{.*}}) return _mm256_mask_expandloadu_epi16(__S, __U, __P); } __m256i test_mm256_maskz_expandloadu_epi16(__mmask16 __U, void const* __P) { // CHECK-LABEL: @test_mm256_maskz_expandloadu_epi16 - // CHECK: @llvm.x86.avx512.mask.expand.load.w.256 + // CHECK: @llvm.masked.expandload.v16i16(i16* %{{.*}}, <16 x i1> %{{.*}}, <16 x i16> %{{.*}}) return _mm256_maskz_expandloadu_epi16(__U, __P); } __m256i test_mm256_mask_expandloadu_epi8(__m256i __S, __mmask32 __U, void const* __P) { // CHECK-LABEL: @test_mm256_mask_expandloadu_epi8 - // CHECK: @llvm.x86.avx512.mask.expand.load.b.256 + // CHECK: @llvm.masked.expandload.v32i8(i8* %{{.*}}, <32 x i1> %{{.*}}, <32 x i8> %{{.*}}) return _mm256_mask_expandloadu_epi8(__S, __U, __P); } __m256i test_mm256_maskz_expandloadu_epi8(__mmask32 __U, void const* __P) { // CHECK-LABEL: @test_mm256_maskz_expandloadu_epi8 - // CHECK: @llvm.x86.avx512.mask.expand.load.b.256 + // CHECK: @llvm.masked.expandload.v32i8(i8* %{{.*}}, <32 x i1> %{{.*}}, <32 x i8> %{{.*}}) return _mm256_maskz_expandloadu_epi8(__U, __P); } Index: test/CodeGen/avx512vl-builtins.c
[PATCH] D45517: [analyzer] False positive refutation with Z3
mikhail.ramalho added a subscriber: rnkovacs. mikhail.ramalho added a comment. > Awesome! Does it mean that the optimization for adding less constraints > was in fact buggy? I pretty sure it was not related to the optimizations, I removed them days ago (in the previous version of this patch) and the bug was still there. > > > 2. Could it be something unrelated to your changes? Any given trunk version > can be buggy, but usually those are resolved very fast, so if you update now > the issue can go away. > > Watching cfe-commits mailing list might be helpful there. I update my repo every other day and it's been happening for the past two/three weeks :/ The compiler shows the following error: posix_spawn failed: Argument list too long There are some discussions in several places about it. https://reviews.llvm.org/D45517 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r333855 - [X86] Explicitly make the arguments to __slwpcb intrinsic 'void'.
Author: ctopper Date: Sun Jun 3 15:05:19 2018 New Revision: 333855 URL: http://llvm.org/viewvc/llvm-project?rev=333855=rev Log: [X86] Explicitly make the arguments to __slwpcb intrinsic 'void'. This is the correct way to say it takes no arguments in C. Modified: cfe/trunk/lib/Headers/lwpintrin.h Modified: cfe/trunk/lib/Headers/lwpintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/lwpintrin.h?rev=333855=333854=333855=diff == --- cfe/trunk/lib/Headers/lwpintrin.h (original) +++ cfe/trunk/lib/Headers/lwpintrin.h Sun Jun 3 15:05:19 2018 @@ -58,7 +58,7 @@ __llwpcb (void *__addr) ///Address to the current Lightweight Profiling Control Block (LWPCB). ///If LWP is not currently enabled, returns NULL. static __inline__ void* __DEFAULT_FN_ATTRS -__slwpcb () +__slwpcb (void) { return __builtin_ia32_slwpcb(); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45517: [analyzer] False positive refutation with Z3
george.karpenkov requested changes to this revision. george.karpenkov added a comment. This revision now requires changes to proceed. > I updated the test case as the cross check is not marking the true bug as > invalid anymore. Awesome! Does it mean that the optimization for adding less constraints was in fact buggy? > My make clang-test is still failing Driver/response-file.c whenever I compile > clang with Z3. I'll update the patch as soon as I find the reason why. 1. You shouldn't use `make`, use `ninja` (also make sure you use `gold` linker, default linker takes forever on Linux) 2. Could it be something unrelated to your changes? Any given trunk version can be buggy, but usually those are resolved very fast, so if you update now the issue can go away. Watching cfe-commits mailing list might be helpful there. Otherwise looks good apart from minor naming nit! I guess we could figure out the casting issue later. Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:2360 +static bool +check_constraints(BugReporterContext , + const llvm::SmallVector ) { we would need a more descriptive name, e.g. `isUnfeasible` or similar. from `bool check_constraints` it's unclear when `false` is returned. Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:2366 + + SMTConstraintManager *SMTRefutationMgr = + static_cast(RefutationMgr.get()); mikhail.ramalho wrote: > I'm not happy about this cast. Suggestions are welcome. well yeah, `CreateZ3ConstraintManager` should return an `SMTConstraintManager`. I don't fully understand the problem there, I'll try to take a look. https://reviews.llvm.org/D45517 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r333853 - [X86] Replace __builtin_ia32_vbroadcastf128_pd256 and __builtin_ia32_vbroadcastf128_ps256 with an unaligned load intrinsics and a __builtin_shufflevector call.
Author: ctopper Date: Sun Jun 3 12:42:59 2018 New Revision: 333853 URL: http://llvm.org/viewvc/llvm-project?rev=333853=rev Log: [X86] Replace __builtin_ia32_vbroadcastf128_pd256 and __builtin_ia32_vbroadcastf128_ps256 with an unaligned load intrinsics and a __builtin_shufflevector call. Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/Headers/avxintrin.h cfe/trunk/test/CodeGen/builtins-x86.c Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=333853=333852=333853=diff == --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sun Jun 3 12:42:59 2018 @@ -510,8 +510,6 @@ TARGET_BUILTIN(__builtin_ia32_movmskpd25 TARGET_BUILTIN(__builtin_ia32_movmskps256, "iV8f", "nc", "avx") TARGET_BUILTIN(__builtin_ia32_vzeroall, "v", "n", "avx") TARGET_BUILTIN(__builtin_ia32_vzeroupper, "v", "n", "avx") -TARGET_BUILTIN(__builtin_ia32_vbroadcastf128_pd256, "V4dV2dC*", "n", "avx") -TARGET_BUILTIN(__builtin_ia32_vbroadcastf128_ps256, "V8fV4fC*", "n", "avx") TARGET_BUILTIN(__builtin_ia32_lddqu256, "V32ccC*", "n", "avx") TARGET_BUILTIN(__builtin_ia32_maskloadpd, "V2dV2dC*V2LLi", "n", "avx") TARGET_BUILTIN(__builtin_ia32_maskloadps, "V4fV4fC*V4i", "n", "avx") Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=333853=333852=333853=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sun Jun 3 12:42:59 2018 @@ -8300,26 +8300,6 @@ static Value *EmitX86MaskLogic(CodeGenFu CGF.Builder.getIntNTy(std::max(NumElts, 8U))); } -static Value *EmitX86SubVectorBroadcast(CodeGenFunction , -ArrayRef Ops, -llvm::Type *DstTy, -unsigned SrcSizeInBits, -unsigned Align) { - // Load the subvector. - Value *SubVec = CGF.Builder.CreateAlignedLoad(Ops[0], Align); - - // Create broadcast mask. - unsigned NumDstElts = DstTy->getVectorNumElements(); - unsigned NumSrcElts = SrcSizeInBits / DstTy->getScalarSizeInBits(); - - SmallVector Mask; - for (unsigned i = 0; i != NumDstElts; i += NumSrcElts) -for (unsigned j = 0; j != NumSrcElts; ++j) - Mask.push_back(j); - - return CGF.Builder.CreateShuffleVector(SubVec, SubVec, Mask, "subvecbcst"); -} - static Value *EmitX86Select(CodeGenFunction , Value *Mask, Value *Op0, Value *Op1) { @@ -8959,12 +8939,6 @@ Value *CodeGenFunction::EmitX86BuiltinEx case X86::BI__builtin_ia32_movdqa64load512_mask: return EmitX86MaskedLoad(*this, Ops, 64); - case X86::BI__builtin_ia32_vbroadcastf128_pd256: - case X86::BI__builtin_ia32_vbroadcastf128_ps256: { -llvm::Type *DstTy = ConvertType(E->getType()); -return EmitX86SubVectorBroadcast(*this, Ops, DstTy, 128, 1); - } - case X86::BI__builtin_ia32_storehps: case X86::BI__builtin_ia32_storelps: { llvm::Type *PtrTy = llvm::PointerType::getUnqual(Int64Ty); Modified: cfe/trunk/lib/Headers/avxintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avxintrin.h?rev=333853=333852=333853=diff == --- cfe/trunk/lib/Headers/avxintrin.h (original) +++ cfe/trunk/lib/Headers/avxintrin.h Sun Jun 3 12:42:59 2018 @@ -3111,7 +3111,9 @@ _mm256_broadcast_ss(float const *__a) static __inline __m256d __DEFAULT_FN_ATTRS _mm256_broadcast_pd(__m128d const *__a) { - return (__m256d)__builtin_ia32_vbroadcastf128_pd256((__v2df const *)__a); + __m128d __b = _mm_loadu_pd((const double *)__a); + return (__m256d)__builtin_shufflevector((__v2df)__b, (__v2df)__b, + 0, 1, 0, 1); } /// Loads the data from a 128-bit vector of [4 x float] from the @@ -3129,7 +3131,9 @@ _mm256_broadcast_pd(__m128d const *__a) static __inline __m256 __DEFAULT_FN_ATTRS _mm256_broadcast_ps(__m128 const *__a) { - return (__m256)__builtin_ia32_vbroadcastf128_ps256((__v4sf const *)__a); + __m128 __b = _mm_loadu_ps((const float *)__a); + return (__m256)__builtin_shufflevector((__v4sf)__b, (__v4sf)__b, + 0, 1, 2, 3, 0, 1, 2, 3); } /* SIMD load ops */ Modified: cfe/trunk/test/CodeGen/builtins-x86.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-x86.c?rev=333853=333852=333853=diff == --- cfe/trunk/test/CodeGen/builtins-x86.c (original) +++ cfe/trunk/test/CodeGen/builtins-x86.c
[PATCH] D47070: [CUDA] Upgrade linked bitcode to enable inlining
Hahnfeld abandoned this revision. Hahnfeld added a comment. Superseded by https://reviews.llvm.org/D47691 Repository: rC Clang https://reviews.llvm.org/D47070 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r333851 - [X86] Pass ArrayRef instead of SmallVectorImpl& to the X86 builtin helper functions. NFC
Author: ctopper Date: Sun Jun 3 12:02:57 2018 New Revision: 333851 URL: http://llvm.org/viewvc/llvm-project?rev=333851=rev Log: [X86] Pass ArrayRef instead of SmallVectorImpl& to the X86 builtin helper functions. NFC Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=333851=333850=333851=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sun Jun 3 12:02:57 2018 @@ -8263,32 +8263,32 @@ static Value *getMaskVecValue(CodeGenFun } static Value *EmitX86MaskedStore(CodeGenFunction , - SmallVectorImpl , + ArrayRef Ops, unsigned Align) { // Cast the pointer to right type. - Ops[0] = CGF.Builder.CreateBitCast(Ops[0], + Value *Ptr = CGF.Builder.CreateBitCast(Ops[0], llvm::PointerType::getUnqual(Ops[1]->getType())); Value *MaskVec = getMaskVecValue(CGF, Ops[2], Ops[1]->getType()->getVectorNumElements()); - return CGF.Builder.CreateMaskedStore(Ops[1], Ops[0], Align, MaskVec); + return CGF.Builder.CreateMaskedStore(Ops[1], Ptr, Align, MaskVec); } static Value *EmitX86MaskedLoad(CodeGenFunction , -SmallVectorImpl , unsigned Align) { +ArrayRef Ops, unsigned Align) { // Cast the pointer to right type. - Ops[0] = CGF.Builder.CreateBitCast(Ops[0], + Value *Ptr = CGF.Builder.CreateBitCast(Ops[0], llvm::PointerType::getUnqual(Ops[1]->getType())); Value *MaskVec = getMaskVecValue(CGF, Ops[2], Ops[1]->getType()->getVectorNumElements()); - return CGF.Builder.CreateMaskedLoad(Ops[0], Align, MaskVec, Ops[1]); + return CGF.Builder.CreateMaskedLoad(Ptr, Align, MaskVec, Ops[1]); } static Value *EmitX86MaskLogic(CodeGenFunction , Instruction::BinaryOps Opc, - unsigned NumElts, SmallVectorImpl , + unsigned NumElts, ArrayRef Ops, bool InvertLHS = false) { Value *LHS = getMaskVecValue(CGF, Ops[0], NumElts); Value *RHS = getMaskVecValue(CGF, Ops[1], NumElts); @@ -8301,12 +8301,12 @@ static Value *EmitX86MaskLogic(CodeGenFu } static Value *EmitX86SubVectorBroadcast(CodeGenFunction , -SmallVectorImpl , +ArrayRef Ops, llvm::Type *DstTy, unsigned SrcSizeInBits, unsigned Align) { // Load the subvector. - Ops[0] = CGF.Builder.CreateAlignedLoad(Ops[0], Align); + Value *SubVec = CGF.Builder.CreateAlignedLoad(Ops[0], Align); // Create broadcast mask. unsigned NumDstElts = DstTy->getVectorNumElements(); @@ -8317,7 +8317,7 @@ static Value *EmitX86SubVectorBroadcast( for (unsigned j = 0; j != NumSrcElts; ++j) Mask.push_back(j); - return CGF.Builder.CreateShuffleVector(Ops[0], Ops[0], Mask, "subvecbcst"); + return CGF.Builder.CreateShuffleVector(SubVec, SubVec, Mask, "subvecbcst"); } static Value *EmitX86Select(CodeGenFunction , ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r333850 - Revert r333848 "[X86] Pass ArrayRef instead of SmallVectorImpl& to the X86 builtin helper functions. NFC"
Author: ctopper Date: Sun Jun 3 11:41:22 2018 New Revision: 333850 URL: http://llvm.org/viewvc/llvm-project?rev=333850=rev Log: Revert r333848 "[X86] Pass ArrayRef instead of SmallVectorImpl& to the X86 builtin helper functions. NFC" Looks like I missed some changes to make this work. Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=333850=333849=333850=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sun Jun 3 11:41:22 2018 @@ -8263,32 +8263,32 @@ static Value *getMaskVecValue(CodeGenFun } static Value *EmitX86MaskedStore(CodeGenFunction , - ArrayRef Ops, + SmallVectorImpl , unsigned Align) { // Cast the pointer to right type. - Value *Ptr = CGF.Builder.CreateBitCast(Ops[0], + Ops[0] = CGF.Builder.CreateBitCast(Ops[0], llvm::PointerType::getUnqual(Ops[1]->getType())); Value *MaskVec = getMaskVecValue(CGF, Ops[2], Ops[1]->getType()->getVectorNumElements()); - return CGF.Builder.CreateMaskedStore(Ops[1], Ptr, Align, MaskVec); + return CGF.Builder.CreateMaskedStore(Ops[1], Ops[0], Align, MaskVec); } static Value *EmitX86MaskedLoad(CodeGenFunction , -ArrayRef Ops, unsigned Align) { +SmallVectorImpl , unsigned Align) { // Cast the pointer to right type. - Value *Ptr = CGF.Builder.CreateBitCast(Ops[0], + Ops[0] = CGF.Builder.CreateBitCast(Ops[0], llvm::PointerType::getUnqual(Ops[1]->getType())); Value *MaskVec = getMaskVecValue(CGF, Ops[2], Ops[1]->getType()->getVectorNumElements()); - return CGF.Builder.CreateMaskedLoad(Ptr, Align, MaskVec, Ops[1]); + return CGF.Builder.CreateMaskedLoad(Ops[0], Align, MaskVec, Ops[1]); } static Value *EmitX86MaskLogic(CodeGenFunction , Instruction::BinaryOps Opc, - unsigned NumElts, ArrayRef Ops, + unsigned NumElts, SmallVectorImpl , bool InvertLHS = false) { Value *LHS = getMaskVecValue(CGF, Ops[0], NumElts); Value *RHS = getMaskVecValue(CGF, Ops[1], NumElts); @@ -8301,7 +8301,7 @@ static Value *EmitX86MaskLogic(CodeGenFu } static Value *EmitX86SubVectorBroadcast(CodeGenFunction , -ArrayRef Ops, +SmallVectorImpl , llvm::Type *DstTy, unsigned SrcSizeInBits, unsigned Align) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r333848 - [X86] Pass ArrayRef instead of SmallVectorImpl& to the X86 builtin helper functions. NFC
Author: ctopper Date: Sun Jun 3 11:08:37 2018 New Revision: 333848 URL: http://llvm.org/viewvc/llvm-project?rev=333848=rev Log: [X86] Pass ArrayRef instead of SmallVectorImpl& to the X86 builtin helper functions. NFC Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=333848=333847=333848=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sun Jun 3 11:08:37 2018 @@ -8263,32 +8263,32 @@ static Value *getMaskVecValue(CodeGenFun } static Value *EmitX86MaskedStore(CodeGenFunction , - SmallVectorImpl , + ArrayRef Ops, unsigned Align) { // Cast the pointer to right type. - Ops[0] = CGF.Builder.CreateBitCast(Ops[0], + Value *Ptr = CGF.Builder.CreateBitCast(Ops[0], llvm::PointerType::getUnqual(Ops[1]->getType())); Value *MaskVec = getMaskVecValue(CGF, Ops[2], Ops[1]->getType()->getVectorNumElements()); - return CGF.Builder.CreateMaskedStore(Ops[1], Ops[0], Align, MaskVec); + return CGF.Builder.CreateMaskedStore(Ops[1], Ptr, Align, MaskVec); } static Value *EmitX86MaskedLoad(CodeGenFunction , -SmallVectorImpl , unsigned Align) { +ArrayRef Ops, unsigned Align) { // Cast the pointer to right type. - Ops[0] = CGF.Builder.CreateBitCast(Ops[0], + Value *Ptr = CGF.Builder.CreateBitCast(Ops[0], llvm::PointerType::getUnqual(Ops[1]->getType())); Value *MaskVec = getMaskVecValue(CGF, Ops[2], Ops[1]->getType()->getVectorNumElements()); - return CGF.Builder.CreateMaskedLoad(Ops[0], Align, MaskVec, Ops[1]); + return CGF.Builder.CreateMaskedLoad(Ptr, Align, MaskVec, Ops[1]); } static Value *EmitX86MaskLogic(CodeGenFunction , Instruction::BinaryOps Opc, - unsigned NumElts, SmallVectorImpl , + unsigned NumElts, ArrayRef Ops, bool InvertLHS = false) { Value *LHS = getMaskVecValue(CGF, Ops[0], NumElts); Value *RHS = getMaskVecValue(CGF, Ops[1], NumElts); @@ -8301,7 +8301,7 @@ static Value *EmitX86MaskLogic(CodeGenFu } static Value *EmitX86SubVectorBroadcast(CodeGenFunction , -SmallVectorImpl , +ArrayRef Ops, llvm::Type *DstTy, unsigned SrcSizeInBits, unsigned Align) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r333846 - [X86] Mark the pointer arguments to expandload builtins as const consistently.
Author: ctopper Date: Sun Jun 3 11:08:34 2018 New Revision: 333846 URL: http://llvm.org/viewvc/llvm-project?rev=333846=rev Log: [X86] Mark the pointer arguments to expandload builtins as const consistently. Some of them had it and some didn't. This should make them consistent. Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=333846=333845=333846=diff == --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sun Jun 3 11:08:34 2018 @@ -1094,20 +1094,20 @@ TARGET_BUILTIN(__builtin_ia32_expandhi25 TARGET_BUILTIN(__builtin_ia32_expandqi128_mask, "V16cV16cV16cUs", "nc", "avx512vl,avx512vbmi2") TARGET_BUILTIN(__builtin_ia32_expandqi256_mask, "V32cV32cV32cUi", "nc", "avx512vl,avx512vbmi2") -TARGET_BUILTIN(__builtin_ia32_expandloaddf128_mask, "V2dV2d*V2dUc", "n", "avx512vl") -TARGET_BUILTIN(__builtin_ia32_expandloaddf256_mask, "V4dV4d*V4dUc", "n", "avx512vl") -TARGET_BUILTIN(__builtin_ia32_expandloaddi128_mask, "V4iV2LLi*V2LLiUc", "n", "avx512vl") -TARGET_BUILTIN(__builtin_ia32_expandloaddi256_mask, "V4LLiV4LLi*V4LLiUc", "n", "avx512vl") +TARGET_BUILTIN(__builtin_ia32_expandloaddf128_mask, "V2dV2dC*V2dUc", "n", "avx512vl") +TARGET_BUILTIN(__builtin_ia32_expandloaddf256_mask, "V4dV4dC*V4dUc", "n", "avx512vl") +TARGET_BUILTIN(__builtin_ia32_expandloaddi128_mask, "V4iV2LLiC*V2LLiUc", "n", "avx512vl") +TARGET_BUILTIN(__builtin_ia32_expandloaddi256_mask, "V4LLiV4LLiC*V4LLiUc", "n", "avx512vl") TARGET_BUILTIN(__builtin_ia32_expandloadhi128_mask, "V8sV8sC*V8sUc", "n", "avx512vl,avx512vbmi2") TARGET_BUILTIN(__builtin_ia32_expandloadhi256_mask, "V16sV16sC*V16sUs", "n", "avx512vl,avx512vbmi2") TARGET_BUILTIN(__builtin_ia32_expandloadqi128_mask, "V16cV16cC*V16cUs", "n", "avx512vl,avx512vbmi2") TARGET_BUILTIN(__builtin_ia32_expandloadqi256_mask, "V32cV32cC*V32cUi", "n", "avx512vl,avx512vbmi2") -TARGET_BUILTIN(__builtin_ia32_expandloadsf128_mask, "V4fV4f*V4fUc", "n", "avx512vl") -TARGET_BUILTIN(__builtin_ia32_expandloadsf256_mask, "V8fV8f*V8fUc", "n", "avx512vl") -TARGET_BUILTIN(__builtin_ia32_expandloadsi128_mask, "V4iV4i*V4iUc", "n", "avx512vl") -TARGET_BUILTIN(__builtin_ia32_expandloadsi256_mask, "V8iV8i*V8iUc", "n", "avx512vl") +TARGET_BUILTIN(__builtin_ia32_expandloadsf128_mask, "V4fV4fC*V4fUc", "n", "avx512vl") +TARGET_BUILTIN(__builtin_ia32_expandloadsf256_mask, "V8fV8fC*V8fUc", "n", "avx512vl") +TARGET_BUILTIN(__builtin_ia32_expandloadsi128_mask, "V4iV4iC*V4iUc", "n", "avx512vl") +TARGET_BUILTIN(__builtin_ia32_expandloadsi256_mask, "V8iV8iC*V8iUc", "n", "avx512vl") TARGET_BUILTIN(__builtin_ia32_expandsf128_mask, "V4fV4fV4fUc", "nc", "avx512vl") TARGET_BUILTIN(__builtin_ia32_expandsf256_mask, "V8fV8fV8fUc", "nc", "avx512vl") TARGET_BUILTIN(__builtin_ia32_expandsi128_mask, "V4iV4iV4iUc", "nc", "avx512vl") ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r333847 - [X86] When emitting masked loads/stores don't check for all ones mask.
Author: ctopper Date: Sun Jun 3 11:08:36 2018 New Revision: 333847 URL: http://llvm.org/viewvc/llvm-project?rev=333847=rev Log: [X86] When emitting masked loads/stores don't check for all ones mask. This seems like a premature optimization. It's unlikely a user would pass something the frontend can tell is all ones to the masked load/store intrinsics. We do this optimization for emitting select for masking because we have builtin calls in header files that pass an all ones mask in. Though at this point we may not longer have any builtins that emit some IR and a select. We may only have the select builtins so maybe we can remove that optimization too. Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=333847=333846=333847=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sun Jun 3 11:08:36 2018 @@ -8269,11 +8269,6 @@ static Value *EmitX86MaskedStore(CodeGen Ops[0] = CGF.Builder.CreateBitCast(Ops[0], llvm::PointerType::getUnqual(Ops[1]->getType())); - // If the mask is all ones just emit a regular store. - if (const auto *C = dyn_cast(Ops[2])) -if (C->isAllOnesValue()) - return CGF.Builder.CreateAlignedStore(Ops[1], Ops[0], Align); - Value *MaskVec = getMaskVecValue(CGF, Ops[2], Ops[1]->getType()->getVectorNumElements()); @@ -8286,11 +8281,6 @@ static Value *EmitX86MaskedLoad(CodeGenF Ops[0] = CGF.Builder.CreateBitCast(Ops[0], llvm::PointerType::getUnqual(Ops[1]->getType())); - // If the mask is all ones just emit a regular store. - if (const auto *C = dyn_cast(Ops[2])) -if (C->isAllOnesValue()) - return CGF.Builder.CreateAlignedLoad(Ops[0], Align); - Value *MaskVec = getMaskVecValue(CGF, Ops[2], Ops[1]->getType()->getVectorNumElements()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47394: [OpenMP][Clang][NVPTX] Replace bundling with partial linking for the OpenMP NVPTX device offloading toolchain
Hahnfeld added a comment. In https://reviews.llvm.org/D47394#1119489, @gtbercea wrote: > In https://reviews.llvm.org/D47394#1119056, @Hahnfeld wrote: > > > Hmm, maybe the scope is much larger: I just tried linking an executable > > that references a `declare target` function in a shared library. My > > assumption was that this already works, given that `libomptarget`'s > > registration functions can be called multiple times. Am I doing something > > wrong? > > > I believe this is a limitation coming from the Cuda toolchain. Not even nvcc > supports this case: > https://stackoverflow.com/questions/35897002/cuda-nvcc-building-chain-of-libraries You are absolutely right, thanks for the link. Maybe we should also document somewhere that we don't support that either for OpenMP offloading to NVPTX? I think this basically renders my approach useless as I meant to compile each device object file for offloading targets directly to a shared library. Those could have been put together at runtime by just loading (and registering) them in the right order. That way we would have been able to keep `clang-offload-bundler` in its current target agnostic form and didn't need to appease proprietary tools such as `nvlink`. With that knowledge I see no other way than what this patch proposes. (I still don't particularly like it because it requires each toolchain to implement their own magic.) Sorry for the delay and my disagreement based on wrong assumptions that I wasn't able to verify as soon as I'd have liked to. Repository: rC Clang https://reviews.llvm.org/D47394 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45517: [analyzer] False positive refutation with Z3
mikhail.ramalho added inline comments. Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:2366 + + SMTConstraintManager *SMTRefutationMgr = + static_cast(RefutationMgr.get()); I'm not happy about this cast. Suggestions are welcome. https://reviews.llvm.org/D45517 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45517: [analyzer] False positive refutation with Z3
mikhail.ramalho updated this revision to Diff 149653. mikhail.ramalho added a comment. Update patch based on https://reviews.llvm.org/D47640 and https://reviews.llvm.org/D47689. I updated the test case as the cross check is not marking the true bug as invalid anymore. My `make clang-test` is still failing `Driver/response-file.c` whenever I compile clang with Z3. I'll update the patch as soon as I find the reason why. https://reviews.llvm.org/D45517 Files: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h lib/StaticAnalyzer/Core/AnalyzerOptions.cpp lib/StaticAnalyzer/Core/BugReporter.cpp lib/StaticAnalyzer/Core/BugReporterVisitors.cpp test/Analysis/z3-crosscheck.c Index: test/Analysis/z3-crosscheck.c === --- /dev/null +++ test/Analysis/z3-crosscheck.c @@ -0,0 +1,51 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -DNO_CROSSCHECK -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config crosscheck-with-z3=true -verify %s +// REQUIRES: z3 + +int foo(int x) +{ + int *z = 0; + if ((x & 1) && ((x & 1) ^ 1)) +#ifdef NO_CROSSCHECK + return *z; // expected-warning {{Dereference of null pointer (loaded from variable 'z')}} +#else + return *z; // no-warning +#endif + return 0; +} + +void g(int d); + +void f(int *a, int *b) { + int c = 5; + if ((a - b) == 0) +c = 0; + if (a != b) +#ifdef NO_CROSSCHECK +g(3 / c); // expected-warning {{Division by zero}} +#else +g(3 / c); // no-warning +#endif +} + +_Bool nondet_bool(); + +void h(int d) { + int x, y, k, z = 1; +#ifdef NO_CROSSCHECK + while (z < k) { // expected-warning {{The right operand of '<' is a garbage value}} +#else + while (z < k) { // expected-warning {{The right operand of '<' is a garbage value}} +#endif +z = 2 * z; + } +} + +void i() { + _Bool c = nondet_bool(); + if (c) { +h(1); + } else { +h(2); + } +} Index: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp === --- lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -44,6 +44,7 @@ #include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/None.h" #include "llvm/ADT/Optional.h" @@ -2354,3 +2355,46 @@ return std::make_shared(L, "Taint originated here"); } + +static bool +check_constraints(BugReporterContext , + const llvm::SmallVector ) { + // Create a refutation manager + std::unique_ptr RefutationMgr = CreateZ3ConstraintManager( + BRC.getStateManager(), BRC.getStateManager().getOwningEngine()); + + SMTConstraintManager *SMTRefutationMgr = + static_cast(RefutationMgr.get()); + + // Add constraints to the solver + for (const auto : Cs) +SMTRefutationMgr->addRangeConstraints(C); + + // And check for satisfiability + return SMTRefutationMgr->isModelFeasible().isConstrainedFalse(); +} + +std::shared_ptr +FalsePositiveRefutationBRVisitor::VisitNode(const ExplodedNode *N, +const ExplodedNode *PrevN, +BugReporterContext , +BugReport ) { + // Collect the constraint for the current state + const ConstraintRangeTy = N->getState()->get(); + Constraints.push_back(CR); + + // If there are no predecessor, we reached the root node. In this point, + // a new refutation manager will be created and the path will be checked + // for reachability + if (PrevN->pred_size() == 0 && check_constraints(BRC, Constraints)) { +BR.markInvalid("Infeasible constraints", N->getLocationContext()); + } + + return nullptr; +} + +void FalsePositiveRefutationBRVisitor::Profile( +llvm::FoldingSetNodeID ) const { + static int Tag = 0; + ID.AddPointer(); +} Index: lib/StaticAnalyzer/Core/BugReporter.cpp === --- lib/StaticAnalyzer/Core/BugReporter.cpp +++ lib/StaticAnalyzer/Core/BugReporter.cpp @@ -3143,10 +3143,15 @@ PathDiagnosticBuilder PDB(*this, R, ErrorGraph.BackMap, ); const ExplodedNode *N = ErrorGraph.ErrorNode; +// Register refutation visitors first, if they mark the bug invalid no +// further analysis is required +R->addVisitor(llvm::make_unique()); +if (getAnalyzerOptions().shouldCrosscheckWithZ3()) + R->addVisitor(llvm::make_unique()); + // Register additional node visitors. R->addVisitor(llvm::make_unique()); R->addVisitor(llvm::make_unique()); -
[PATCH] D47687: fix: [Bug 18971] - Missing -Wparentheses warning
Higuoxing added a comment. In https://reviews.llvm.org/D47687#1120226, @lebedev.ri wrote: > In https://reviews.llvm.org/D47687#1120213, @Higuoxing wrote: > > > As for some test cases, > > > The tests need to be within the patch itself, in this case > i guess that should go into `clang/test/Sema/`. > See other tests in there on how to write them. > And they will be run via `$ ninja check-clang` / `$ ninja check-clang-sema`. Hi, Thanks for your reviewing :D I am trying to write the test cases ... Thanks :D Repository: rC Clang https://reviews.llvm.org/D47687 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47687: fix: [Bug 18971] - Missing -Wparentheses warning
lebedev.ri added a comment. In https://reviews.llvm.org/D47687#1120213, @Higuoxing wrote: > As for some test cases, The tests need to be within the patch itself, in this case i guess that should go into `clang/test/Sema/`. See other tests in there on how to write them. And they will be run via `$ ninja check-clang` / `$ ninja check-clang-sema`. Repository: rC Clang https://reviews.llvm.org/D47687 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47687: fix: [Bug 18971] - Missing -Wparentheses warning
lebedev.ri added reviewers: rsmith, aaron.ballman. lebedev.ri added a comment. Tests? Repository: rC Clang https://reviews.llvm.org/D47687 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47687: fix: [Bug 18971] - Missing -Wparentheses warning
Higuoxing added a comment. As for some test cases, $ cat a.cc #include #include #define bar(x) \ ( \ ( std::cout << x ) \ ) bool x; int val; void foo(bool b) { std::cout << b << std::endl; } int main () { foo(x && val == 4 || (!x && val == 5)); bar(x && val == 4 || (!x && val == 5)); assert(x && val == 4 || (!x && val == 5)); assert(x || val == 4 && "test"); return 0; } And clang will emits a.cc:20:9: warning: '&&' within '||' [-Wlogical-op-parentheses] foo(x && val == 4 || (!x && val == 5)); ~~^~~ ~~ a.cc:20:9: note: place parentheses around the '&&' expression to silence this warning foo(x && val == 4 || (!x && val == 5)); ^ () a.cc:21:9: warning: '&&' within '||' [-Wlogical-op-parentheses] bar(x && val == 4 || (!x && val == 5)); ~~^~~~ a.cc:7:20: note: expanded from macro 'bar' ( std::cout << x ) \ ~^ a.cc:21:9: note: place parentheses around the '&&' expression to silence this warning bar(x && val == 4 || (!x && val == 5)); ~~^~~~ a.cc:7:20: note: expanded from macro 'bar' ( std::cout << x ) \ ~^ a.cc:22:12: warning: '&&' within '||' [-Wlogical-op-parentheses] assert(x && val == 4 || (!x && val == 5)); ~~^~~ ~~ /usr/include/assert.h:93:25: note: expanded from macro 'assert' (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0) ^ a.cc:22:12: note: place parentheses around the '&&' expression to silence this warning assert(x && val == 4 || (!x && val == 5)); ~~^~~ /usr/include/assert.h:93:25: note: expanded from macro 'assert' (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0) ^ 3 warnings generated. Repository: rC Clang https://reviews.llvm.org/D47687 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47687: fix: [Bug 18971] - Missing -Wparentheses warning
Higuoxing created this revision. Herald added a subscriber: cfe-commits. Higuoxing edited the summary of this revision. Hi, As you see, to avoid some expression like assert(x || y && "some messages"); clang will skip all the parentheses check if the expression is in `macro`; and this rule is a little bit loose, if a function which takes boolean variables defined in `macros`, clang will not check parentheses for these functions; So, in this patch I add a string type checking, if and only if a function defined in macro and the RHS of boolean expression is a string, then skip the parentheses checking :) Thanks for reviewing :) Repository: rC Clang https://reviews.llvm.org/D47687 Files: lib/Sema/SemaExpr.cpp Index: lib/Sema/SemaExpr.cpp === --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -12310,7 +12310,14 @@ // Warn about arg1 || arg2 && arg3, as GCC 4.3+ does. // We don't warn for 'assert(a || b && "bad")' since this is safe. - if (Opc == BO_LOr && !OpLoc.isMacroID()/* Don't warn in macros. */) { + StringLiteral* diagnoseRHSToBeString += dyn_cast(RHSExpr->IgnoreImpCasts()); + if (Opc == BO_LOr && + !(OpLoc.isMacroID() && + diagnoseRHSToBeString) +/* Don't warn in macros, + if and only if RHS could be + evaluated as string */) { DiagnoseLogicalAndInLogicalOrLHS(Self, OpLoc, LHSExpr, RHSExpr); DiagnoseLogicalAndInLogicalOrRHS(Self, OpLoc, LHSExpr, RHSExpr); } Index: lib/Sema/SemaExpr.cpp === --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -12310,7 +12310,14 @@ // Warn about arg1 || arg2 && arg3, as GCC 4.3+ does. // We don't warn for 'assert(a || b && "bad")' since this is safe. - if (Opc == BO_LOr && !OpLoc.isMacroID()/* Don't warn in macros. */) { + StringLiteral* diagnoseRHSToBeString += dyn_cast(RHSExpr->IgnoreImpCasts()); + if (Opc == BO_LOr && + !(OpLoc.isMacroID() && + diagnoseRHSToBeString) +/* Don't warn in macros, + if and only if RHS could be + evaluated as string */) { DiagnoseLogicalAndInLogicalOrLHS(Self, OpLoc, LHSExpr, RHSExpr); DiagnoseLogicalAndInLogicalOrRHS(Self, OpLoc, LHSExpr, RHSExpr); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen
whisperity requested changes to this revision. whisperity added a comment. This revision now requires changes to proceed. In general, make sure the documentation page renders well in a browser. Mostly style and phrasing stuff inline: Comment at: clang-tidy/bugprone/NotNullTerminatedResultCheck.h:34-36 + // If non-zero the target version implements _s suffixed memory and character + // handler functions which is safer than older versions (e.g. 'memcpy_s()'). + const int IsSafeFunctionsAreAvailable; More of a language or phrasing thing, but the singular/plural wording is anything but matched in this case: handler functions which **are** safer. What is a "target version" in this case? Shouldn't it be something like "target environment" or "target standard" or just simply "target"? The variable name is also problematic. `AreSafeFunctionsAvailable` would be better. Comment at: docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst:20-21 +the passed third argument, which is ``size_t length``. The proper length is +``strlen(src) + 1`` because the null terminator need an extra space. The result +is badly not null-terminated: + //badly?// Also, perhaps a half sentence of explanation would be nice here: need an extra space, thus the result is not null-terminated, which can result in undefined behaviour when the string is read. Comment at: docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst:39 + +Otherwise fix-it will rewrite it to a safer function, that born before ``_s`` +suffixed functions: That //existed//. Comment at: docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst:105 + + An integer non-zero value specifying if the target version implements ``_s`` + suffixed memory and character handler functions which is safer than older Why is this an integer, rather than a bool? https://reviews.llvm.org/D45050 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41168: [X86] Lowering X86 avx512 sqrt intrinsics to IR
RKSimon added inline comments. Comment at: test/CodeGen/sse2-builtins.c:1199 // CHECK-LABEL: test_mm_sqrt_sd - // CHECK: call <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double> %{{.*}}) - // CHECK: extractelement <2 x double> %{{.*}}, i32 0 - // CHECK: insertelement <2 x double> undef, double %{{.*}}, i32 0 - // CHECK: extractelement <2 x double> %{{.*}}, i32 1 - // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 1 + // CHECK-NOT: call <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double> %{{.*}}) + // CHECK: extractelement <2 x double> %{{.*}}, i64 0 You've added CHECK-NOT to some (scalar only?) tests but not others - please be consistent. Repository: rC Clang https://reviews.llvm.org/D41168 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44609: [Clang-Format] New option BreakBeforeLambdaBody to manage lambda line break inside function parameter call
mephi42 added a comment. This change is very useful for me (I even rebuilt my clang-format with it), but there were no updates for quite some time - do you still intend to integrate it? Apologies in advance if Phabricator is not the right place for such discussions. Repository: rC Clang https://reviews.llvm.org/D44609 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r333836 - clang-interpreter: Add missing LLVM component Object
Author: maskray Date: Sun Jun 3 01:12:15 2018 New Revision: 333836 URL: http://llvm.org/viewvc/llvm-project?rev=333836=rev Log: clang-interpreter: Add missing LLVM component Object Modified: cfe/trunk/examples/clang-interpreter/CMakeLists.txt Modified: cfe/trunk/examples/clang-interpreter/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/CMakeLists.txt?rev=333836=333835=333836=diff == --- cfe/trunk/examples/clang-interpreter/CMakeLists.txt (original) +++ cfe/trunk/examples/clang-interpreter/CMakeLists.txt Sun Jun 3 01:12:15 2018 @@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS ExecutionEngine MC MCJIT + Object OrcJit Option RuntimeDyld ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits