[PATCH] D92827: [clang][cli] CompilerInvocationTest: split enum test into two

2020-12-09 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5afff86d2616: [clang][cli] CompilerInvocationTest: split 
enum test into two (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92827/new/

https://reviews.llvm.org/D92827

Files:
  clang/unittests/Frontend/CompilerInvocationTest.cpp


Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -17,9 +17,7 @@
 using namespace clang;
 
 using ::testing::Contains;
-using ::testing::Each;
 using ::testing::StrEq;
-using ::testing::StrNe;
 
 namespace {
 class CommandLineTest : public ::testing::Test {
@@ -117,27 +115,26 @@
   ASSERT_THAT(GeneratedArgs, Contains(StrEq(DefaultTriple.c_str(;
 }
 
-TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateEnum) {
-  const char *RelocationModelCStr = "static";
-  const char *Args[] = {"clang", "-xc++", "-mrelocation-model",
-RelocationModelCStr, "-"};
+TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateEnumNonDefault) {
+  const char *Args[] = {"clang", "-xc++", "-mrelocation-model", "static", "-"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  // Non default relocation model
-  ASSERT_THAT(GeneratedArgs, Contains(StrEq(RelocationModelCStr)));
-  GeneratedArgs.clear();
+  // Non default relocation model.
+  ASSERT_THAT(GeneratedArgs, Contains(StrEq("static")));
+}
+
+TEST_F(CommandLineTest, CanGenerateCC1COmmandLineSeparateEnumDefault) {
+  const char *Args[] = {"clang", "-xc++", "-mrelocation-model", "pic", "-"};
 
-  RelocationModelCStr = "pic";
-  Args[3] = RelocationModelCStr;
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
-  CompilerInvocation Invocation2;
-  CompilerInvocation::CreateFromArgs(Invocation2, Args, *Diags);
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  Invocation2.generateCC1CommandLine(GeneratedArgs, *this);
-  ASSERT_THAT(GeneratedArgs, Each(StrNe(RelocationModelCStr)));
+  // Default relocation model.
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("pic";
 }
 
 TEST_F(CommandLineTest, NotPresentNegativeFlagNotGenerated) {


Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -17,9 +17,7 @@
 using namespace clang;
 
 using ::testing::Contains;
-using ::testing::Each;
 using ::testing::StrEq;
-using ::testing::StrNe;
 
 namespace {
 class CommandLineTest : public ::testing::Test {
@@ -117,27 +115,26 @@
   ASSERT_THAT(GeneratedArgs, Contains(StrEq(DefaultTriple.c_str(;
 }
 
-TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateEnum) {
-  const char *RelocationModelCStr = "static";
-  const char *Args[] = {"clang", "-xc++", "-mrelocation-model",
-RelocationModelCStr, "-"};
+TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateEnumNonDefault) {
+  const char *Args[] = {"clang", "-xc++", "-mrelocation-model", "static", "-"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  // Non default relocation model
-  ASSERT_THAT(GeneratedArgs, Contains(StrEq(RelocationModelCStr)));
-  GeneratedArgs.clear();
+  // Non default relocation model.
+  ASSERT_THAT(GeneratedArgs, Contains(StrEq("static")));
+}
+
+TEST_F(CommandLineTest, CanGenerateCC1COmmandLineSeparateEnumDefault) {
+  const char *Args[] = {"clang", "-xc++", "-mrelocation-model", "pic", "-"};
 
-  RelocationModelCStr = "pic";
-  Args[3] = RelocationModelCStr;
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
-  CompilerInvocation Invocation2;
-  CompilerInvocation::CreateFromArgs(Invocation2, Args, *Diags);
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  Invocation2.generateCC1CommandLine(GeneratedArgs, *this);
-  ASSERT_THAT(GeneratedArgs, Each(StrNe(RelocationModelCStr)));
+  // Default relocation model.
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("pic";
 }
 
 TEST_F(CommandLineTest, NotPresentNegativeFlagNotGenerated) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92828: [clang][cli] CompilerInvocationTest: remove unnecessary command line arguments

2020-12-09 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4894e423e7b4: [clang][cli] CompilerInvocationTest: remove 
unnecessary command line arguments (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92828/new/

https://reviews.llvm.org/D92828

Files:
  clang/unittests/Frontend/CompilerInvocationTest.cpp

Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -36,7 +36,7 @@
 };
 
 TEST_F(CommandLineTest, OptIsInitializedWithCustomDefaultValue) {
-  const char *Args[] = {"clang", "-xc++"};
+  const char *Args[] = {""};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -44,7 +44,7 @@
 }
 
 TEST_F(CommandLineTest, OptOfNegativeFlagIsPopulatedWithFalse) {
-  const char *Args[] = {"clang", "-xc++", "-fno-temp-file"};
+  const char *Args[] = {"-fno-temp-file"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -52,7 +52,7 @@
 }
 
 TEST_F(CommandLineTest, OptsOfImpliedPositiveFlagArePopulatedWithTrue) {
-  const char *Args[] = {"clang", "-xc++", "-cl-unsafe-math-optimizations"};
+  const char *Args[] = {"-cl-unsafe-math-optimizations"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -68,7 +68,7 @@
 }
 
 TEST_F(CommandLineTest, CanGenerateCC1CommandLineFlag) {
-  const char *Args[] = {"clang", "-xc++", "-fmodules-strict-context-hash", "-"};
+  const char *Args[] = {"-fmodules-strict-context-hash"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -79,7 +79,7 @@
 
 TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparate) {
   const char *TripleCStr = "i686-apple-darwin9";
-  const char *Args[] = {"clang", "-xc++", "-triple", TripleCStr, "-"};
+  const char *Args[] = {"-triple", TripleCStr};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -91,8 +91,7 @@
 TEST_F(CommandLineTest,  CanGenerateCC1CommandLineSeparateRequiredPresent) {
   const std::string DefaultTriple =
   llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple());
-  const char *Args[] = {"clang", "-xc++", "-triple", DefaultTriple.c_str(),
-"-"};
+  const char *Args[] = {"-triple", DefaultTriple.c_str()};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -105,7 +104,7 @@
 TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateRequiredAbsent) {
   const std::string DefaultTriple =
   llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple());
-  const char *Args[] = {"clang", "-xc++", "-"};
+  const char *Args[] = {""};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -116,7 +115,7 @@
 }
 
 TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateEnumNonDefault) {
-  const char *Args[] = {"clang", "-xc++", "-mrelocation-model", "static", "-"};
+  const char *Args[] = {"-mrelocation-model", "static"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -127,7 +126,7 @@
 }
 
 TEST_F(CommandLineTest, CanGenerateCC1COmmandLineSeparateEnumDefault) {
-  const char *Args[] = {"clang", "-xc++", "-mrelocation-model", "pic", "-"};
+  const char *Args[] = {"-mrelocation-model", "pic"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -138,7 +137,7 @@
 }
 
 TEST_F(CommandLineTest, NotPresentNegativeFlagNotGenerated) {
-  const char *Args[] = {"clang", "-xc++"};
+  const char *Args[] = {""};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -148,7 +147,7 @@
 }
 
 TEST_F(CommandLineTest, PresentNegativeFlagGenerated) {
-  const char *Args[] = {"clang", "-xc++", "-fno-temp-file"};
+  const char *Args[] = {"-fno-temp-file"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -158,7 +157,7 @@
 }
 
 TEST_F(CommandLineTest, NotPresentAndNotImpliedNotGenerated) {
-  const char *Args[] = {"clang", "-xc++"};
+  const char *Args[] = {""};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -172,7 +171,7 @@
 }
 
 TEST_F(CommandLineTest, NotPresentAndImpliedNotGenerated) {
-  const char *Args[] = {"clang", "-xc++", "-cl-unsafe-math-optimizations"};
+  const char *Args[] = {"-cl-unsafe-math-optimizations"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -185,8 +184,8 @@
 }
 
 TEST_F(CommandLineTest, PresentAndImpliedNotGenerated) {
-  const char *Args[] = {"clang", "-xc++", "-cl-unsafe-math-optimizations",
-"-cl-mad-enable", "-menable-unsafe-fp-math"};
+  const char *Args[] = {"-cl-unsafe-math-optimizations", "-cl-mad-enable",
+"-menable-unsafe-fp-math"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -199,8 +198,7 @@
 }
 
 TEST_F(Comma

[PATCH] D92829: [clang][cli] CompilerInvocationTest: check arg parsing does not produce diagnostics

2020-12-09 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG03692bae1fc9: [clang][cli] CompilerInvocationTest: check arg 
parsing does not produce… (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92829/new/

https://reviews.llvm.org/D92829

Files:
  clang/unittests/Frontend/CompilerInvocationTest.cpp

Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -8,6 +8,7 @@
 
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/TextDiagnosticBuffer.h"
 #include "llvm/Support/Host.h"
 
 #include "gmock/gmock.h"
@@ -32,7 +33,9 @@
   }
 
   CommandLineTest()
-  : Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions())) {}
+  : Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions(),
+  new TextDiagnosticBuffer())) {
+  }
 };
 
 TEST_F(CommandLineTest, OptIsInitializedWithCustomDefaultValue) {
@@ -40,6 +43,8 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   ASSERT_TRUE(Invocation.getFrontendOpts().UseTemporary);
 }
 
@@ -48,6 +53,8 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   ASSERT_FALSE(Invocation.getFrontendOpts().UseTemporary);
 }
 
@@ -56,6 +63,8 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   // Explicitly provided flag.
   ASSERT_TRUE(Invocation.getLangOpts()->CLUnsafeMath);
 
@@ -72,6 +81,8 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fmodules-strict-context-hash")));
@@ -83,6 +94,8 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   ASSERT_THAT(GeneratedArgs, Contains(StrEq(TripleCStr)));
@@ -95,6 +108,8 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   // Triple should always be emitted even if it is the default
@@ -108,6 +123,8 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   // Triple should always be emitted even if it is the default
@@ -119,6 +136,8 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   // Non default relocation model.
@@ -130,6 +149,8 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   // Default relocation model.
@@ -141,6 +162,8 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-temp-file";
@@ -151,6 +174,8 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fno-temp-file")));
@@ -161,6 +186,8 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   // Missing options are not generated.
@@ -175,6 +202,8 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   // Missing options that were implied are not generated.
@@ -189,6 +218,8 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   // Present options that were also implied are not generated.
@@ -202,6 +233,8 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   // Present options that were not implied are generated.

[PATCH] D92830: [clang][cli] CompilerInvocationTest: join and add test cases

2020-12-09 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG216d43053b4e: [clang][cli] CompilerInvocationTest: join and 
add test cases (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92830/new/

https://reviews.llvm.org/D92830

Files:
  clang/unittests/Frontend/CompilerInvocationTest.cpp

Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -38,42 +38,43 @@
   }
 };
 
-TEST_F(CommandLineTest, OptIsInitializedWithCustomDefaultValue) {
+// Boolean option with a keypath that defaults to true.
+// The only flag with a negative spelling can set the keypath to false.
+
+TEST_F(CommandLineTest, BoolOptionDefaultTrueSingleFlagNotPresent) {
   const char *Args[] = {""};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
   ASSERT_FALSE(Diags->hasErrorOccurred());
-
   ASSERT_TRUE(Invocation.getFrontendOpts().UseTemporary);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-temp-file";
 }
 
-TEST_F(CommandLineTest, OptOfNegativeFlagIsPopulatedWithFalse) {
+TEST_F(CommandLineTest, BoolOptionDefaultTrueSingleFlagPresent) {
   const char *Args[] = {"-fno-temp-file"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
   ASSERT_FALSE(Diags->hasErrorOccurred());
-
   ASSERT_FALSE(Invocation.getFrontendOpts().UseTemporary);
-}
 
-TEST_F(CommandLineTest, OptsOfImpliedPositiveFlagArePopulatedWithTrue) {
-  const char *Args[] = {"-cl-unsafe-math-optimizations"};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fno-temp-file")));
+}
 
-  // Explicitly provided flag.
-  ASSERT_TRUE(Invocation.getLangOpts()->CLUnsafeMath);
+TEST_F(CommandLineTest, BoolOptionDefaultTrueSingleFlagUnknownPresent) {
+  const char *Args[] = {"-ftemp-file"};
 
-  // Flags directly implied by explicitly provided flag.
-  ASSERT_TRUE(Invocation.getCodeGenOpts().LessPreciseFPMAD);
-  ASSERT_TRUE(Invocation.getLangOpts()->UnsafeFPMath);
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
-  // Flag transitively implied by explicitly provided flag.
-  ASSERT_TRUE(Invocation.getLangOpts()->AllowRecip);
+  // Driver-only flag.
+  ASSERT_TRUE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Invocation.getFrontendOpts().UseTemporary);
 }
 
 TEST_F(CommandLineTest, CanGenerateCC1CommandLineFlag) {
@@ -157,75 +158,101 @@
   ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("pic";
 }
 
-TEST_F(CommandLineTest, NotPresentNegativeFlagNotGenerated) {
-  const char *Args[] = {""};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-
-  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
-
-  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-temp-file";
-}
-
-TEST_F(CommandLineTest, PresentNegativeFlagGenerated) {
-  const char *Args[] = {"-fno-temp-file"};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-
-  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
-
-  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fno-temp-file")));
-}
+// Tree of boolean options that can be (directly or transitively) implied by
+// their parent:
+//
+//   * -cl-unsafe-math-optimizations
+// * -cl-mad-enable
+// * -menable-unsafe-fp-math
+//   * -freciprocal-math
 
-TEST_F(CommandLineTest, NotPresentAndNotImpliedNotGenerated) {
+TEST_F(CommandLineTest, ImpliedBoolOptionsNoFlagPresent) {
   const char *Args[] = {""};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
   ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(Invocation.getLangOpts()->CLUnsafeMath);
+  ASSERT_FALSE(Invocation.getCodeGenOpts().LessPreciseFPMAD);
+  ASSERT_FALSE(Invocation.getLangOpts()->UnsafeFPMath);
+  ASSERT_FALSE(Invocation.getLangOpts()->AllowRecip);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  // Missing options are not generated.
+  // Not generated - missing.
   ASSERT_THAT(GeneratedArgs,
   Not(Contains(StrEq("-cl-unsafe-math-optimizations";
   ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-cl-mad-enable";
   ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-menable-unsafe-fp-math";
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-freciprocal-math";
 }
 
-TEST_F(CommandLineTest, NotPresentAndImpliedNotGenerated) {
+TEST_F(CommandLineTest, ImpliedBoolOptionsRootFlagPresent) {
   const char *Args[] = {"-cl-unsafe-math-optimizations"};
 
   CompilerInvoc

[PATCH] D92774: [clang][cli] CompilerInvocationTest: add tests for boolean options

2020-12-09 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG35621cc2e3b3: [clang][cli] CompilerInvocationTest: add tests 
for boolean options (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92774/new/

https://reviews.llvm.org/D92774

Files:
  clang/unittests/Frontend/CompilerInvocationTest.cpp

Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -77,6 +77,150 @@
   ASSERT_TRUE(Invocation.getFrontendOpts().UseTemporary);
 }
 
+// Boolean option with a keypath that defaults to true.
+// The flag with negative spelling can set the keypath to false.
+// The flag with positive spelling can reset the keypath to true.
+
+TEST_F(CommandLineTest, BoolOptionDefaultTruePresentNone) {
+  const char *Args[] = {""};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Invocation.getCodeGenOpts().Autolink);
+
+  // TODO: Test argument generation.
+}
+
+TEST_F(CommandLineTest, BoolOptionDefaultTruePresentNegChange) {
+  const char *Args[] = {"-fno-autolink"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(Invocation.getCodeGenOpts().Autolink);
+
+  // TODO: Test argument generation.
+}
+
+TEST_F(CommandLineTest, BoolOptionDefaultTruePresentPosReset) {
+  const char *Args[] = {"-fautolink"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  ASSERT_TRUE(Diags->hasErrorOccurred()); // Driver-only flag.
+  ASSERT_TRUE(Invocation.getCodeGenOpts().Autolink);
+}
+
+// Boolean option with a keypath that defaults to false.
+// The flag with negative spelling can set the keypath to true.
+// The flag with positive spelling can reset the keypath to false.
+
+TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNone) {
+  const char *Args[] = {""};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(Invocation.getCodeGenOpts().NoInlineLineTables);
+
+  // TODO: Test argument generation.
+}
+
+TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNegChange) {
+  const char *Args[] = {"-gno-inline-line-tables"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Invocation.getCodeGenOpts().NoInlineLineTables);
+
+  // TODO: Test argument generation.
+}
+
+TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentPosReset) {
+  const char *Args[] = {"-ginline-line-tables"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  ASSERT_TRUE(Diags->hasErrorOccurred()); // Driver-only flag.
+  ASSERT_FALSE(Invocation.getCodeGenOpts().NoInlineLineTables);
+}
+
+// Boolean option with a keypath that defaults to false.
+// The flag with positive spelling can set the keypath to true.
+// The flag with negative spelling can reset the keypath to false.
+
+TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNoneX) {
+  const char *Args[] = {""};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(Invocation.getCodeGenOpts().CodeViewGHash);
+
+  // TODO: Test argument generation.
+}
+
+TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentPosChange) {
+  const char *Args[] = {"-gcodeview-ghash"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Invocation.getCodeGenOpts().CodeViewGHash);
+
+  // TODO: Test argument generation.
+}
+
+TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNegReset) {
+  const char *Args[] = {"-gno-codeview-ghash"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  ASSERT_TRUE(Diags->hasErrorOccurred()); // Driver-only flag.
+  ASSERT_FALSE(Invocation.getCodeGenOpts().CodeViewGHash);
+}
+
+// Boolean option with a keypath that defaults to an arbitrary expression.
+// The flag with positive spelling can set the keypath to true.
+// The flag with negative spelling can set the keypath to false.
+
+// NOTE: The following tests need to be updated when we start enabling the new
+// pass manager by default.
+
+TEST_F(CommandLineTest, BoolOptionDefaultArbitraryTwoFlagsPresentNone) {
+  const char *Args = {""};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(Invocation.getCodeGenOpts().ExperimentalNewPassManager);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+  ASSERT_THAT(GeneratedArgs,
+  Not(Contains(StrEq("-fexperimental-new-pass-manager";
+}
+
+TEST_F(CommandLineTest, B

[PATCH] D92915: [Driver] Add -f[no-]new-pass-manager to supersede -f[no-]experimental-new-pass-manager

2020-12-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 310438.
MaskRay added a comment.

Improve tests


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92915/new/

https://reviews.llvm.org/D92915

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fnew-pass-manager.c
  clang/test/Driver/gold-lto-new-pass-man.c

Index: clang/test/Driver/gold-lto-new-pass-man.c
===
--- clang/test/Driver/gold-lto-new-pass-man.c
+++ /dev/null
@@ -1,7 +0,0 @@
-// RUN: touch %t.o
-//
-// RUN: %clang -target ppc64le-unknown-linux -### %t.o -flto 2>&1 \
-// RUN: -Wl,-plugin-opt=foo -O3 \
-// RUN: -fexperimental-new-pass-manager \
-// RUN: | FileCheck %s
-// CHECK: "-plugin-opt=new-pass-manager"
Index: clang/test/Driver/fnew-pass-manager.c
===
--- /dev/null
+++ clang/test/Driver/fnew-pass-manager.c
@@ -0,0 +1,26 @@
+// RUN: %clang -### -c -fno-new-pass-manager -fnew-pass-manager %s 2>&1 | FileCheck --check-prefixes=NOWARN,NEW %s
+// RUN: %clang -### -c -fnew-pass-manager -fno-new-pass-manager %s 2>&1 | FileCheck --check-prefixes=NOWARN,LEGACY %s
+
+/// -f[no-]experimental-new-pass-manager are legacy aliases when the new PM was still experimental.
+// RUN: %clang -### -c -fno-experimental-new-pass-manager -fexperimental-new-pass-manager %s 2>&1 | FileCheck --check-prefixes=NOWARN,NEW %s
+// RUN: %clang -### -c -fexperimental-new-pass-manager -fno-experimental-new-pass-manager %s 2>&1 | FileCheck --check-prefixes=NOWARN,LEGACY %s
+
+// NOWARN-NOT: warning: argument unused
+
+// NEW:-fnew-pass-manager
+// NEW-NOT:-fno-new-pass-manager
+
+// LEGACY: -fno-new-pass-manager
+// LEGACY-NOT: -fnew-pass-manager
+
+/// For full/Thin LTO, -fnew-pass-manager passes -plugin-opt=new-pass-manager to the linker (which may not be LLD).
+// RUN: %clang -### -target x86_64-linux -flto -fnew-pass-manager %s 2>&1 | FileCheck --check-prefix=LTO_NEW %s
+// RUN: %clang -### -target x86_64-linux -flto=thin -fexperimental-new-pass-manager %s 2>&1 | FileCheck --check-prefix=LTO_NEW %s
+
+// LTO_NEW:"-plugin-opt=new-pass-manager"
+
+/// TODO Add the negative option and pass it to the linker.
+// RUN: %clang -### -target x86_64-linux -flto -fno-new-pass-manager %s 2>&1 | FileCheck --check-prefix=LTO_LEGACY %s
+// RUN: %clang -### -target x86_64-linux -flto=thin -fno-experimental-new-pass-manager %s 2>&1 | FileCheck --check-prefix=LTO_LEGACY %s
+
+// LTO_LEGACY-NOT: "-plugin-opt=new-pass-manager"
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -469,10 +469,10 @@
 // RUN: %clang -### -fno-experimental-new-pass-manager -fexperimental-new-pass-manager %s 2>&1 | FileCheck --check-prefix=CHECK-PM --check-prefix=CHECK-NEW-PM %s
 // RUN: %clang -### -fexperimental-new-pass-manager -fno-experimental-new-pass-manager %s 2>&1 | FileCheck --check-prefix=CHECK-PM --check-prefix=CHECK-NO-NEW-PM %s
 // CHECK-PM-NOT: argument unused
-// CHECK-NEW-PM: -fexperimental-new-pass-manager
-// CHECK-NEW-PM-NOT: -fno-experimental-new-pass-manager
-// CHECK-NO-NEW-PM: -fno-experimental-new-pass-manager
-// CHECK-NO-NEW-PM-NOT: -fexperimental-new-pass-manager
+// CHECK-NEW-PM: -fnew-pass-manager
+// CHECK-NEW-PM-NOT: -fno-new-pass-manager
+// CHECK-NO-NEW-PM: -fno-new-pass-manager
+// CHECK-NO-NEW-PM-NOT: -fnew-pass-manager
 
 // RUN: %clang -### -S -fstrict-return %s 2>&1 | FileCheck -check-prefix=CHECK-STRICT-RETURN %s
 // RUN: %clang -### -S -fno-strict-return %s 2>&1 | FileCheck -check-prefix=CHECK-NO-STRICT-RETURN %s
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -596,8 +596,8 @@
   }
 
   // Need this flag to turn on new pass manager via Gold plugin.
-  if (Args.hasFlag(options::OPT_fexperimental_new_pass_manager,
-   options::OPT_fno_experimental_new_pass_manager,
+  if (Args.hasFlag(options::OPT_fnew_pass_manager,
+   options::OPT_fno_new_pass_manager,
/* Default */ LLVM_ENABLE_NEW_PASS_MANAGER)) {
 CmdArgs.push_back("-plugin-opt=new-pass-manager");
   }
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5835,8 +5835,8 @@
false))
 CmdArgs.push_back("-fmodules-debuginfo");
 
-  Args.AddLastArg(CmdArgs, options::OPT_fexperimental_new_pass_manager,
-  options::OPT_fno_experimental_new_pass_manager);
+  Args.AddLastArg(CmdAr

[PATCH] D92917: [Driver] Pass -plugin-opt=no-new-pass-manager to the linker

2020-12-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 310439.
MaskRay edited the summary of this revision.
MaskRay added a comment.

Improve


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92917/new/

https://reviews.llvm.org/D92917

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/fnew-pass-manager.c


Index: clang/test/Driver/fnew-pass-manager.c
===
--- clang/test/Driver/fnew-pass-manager.c
+++ clang/test/Driver/fnew-pass-manager.c
@@ -19,8 +19,12 @@
 
 // LTO_NEW:"-plugin-opt=new-pass-manager"
 
-/// TODO Add the negative option and pass it to the linker.
 // RUN: %clang -### -target x86_64-linux -flto -fno-new-pass-manager %s 2>&1 | 
FileCheck --check-prefix=LTO_LEGACY %s
 // RUN: %clang -### -target x86_64-linux -flto=thin 
-fno-experimental-new-pass-manager %s 2>&1 | FileCheck 
--check-prefix=LTO_LEGACY %s
 
-// LTO_LEGACY-NOT: "-plugin-opt=new-pass-manager"
+// LTO_LEGACY: "-plugin-opt=no-new-pass-manager"
+
+// RUN: %clang -### -target x86_64-linux -flto %s 2>&1 | FileCheck 
--check-prefix=DEFAULT %s
+
+// DEFAULT-NOT: "-plugin-opt=new-pass-manager"
+// DEFAULT-NOT: "-plugin-opt=no-new-pass-manager"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -595,11 +595,13 @@
  Path));
   }
 
-  // Need this flag to turn on new pass manager via Gold plugin.
-  if (Args.hasFlag(options::OPT_fnew_pass_manager,
-   options::OPT_fno_new_pass_manager,
-   /* Default */ LLVM_ENABLE_NEW_PASS_MANAGER)) {
-CmdArgs.push_back("-plugin-opt=new-pass-manager");
+  // Pass an option to enable/disable the new pass manager.
+  if (auto *A = Args.getLastArg(options::OPT_fnew_pass_manager,
+options::OPT_fno_new_pass_manager)) {
+if (A->getOption().matches(options::OPT_fnew_pass_manager))
+  CmdArgs.push_back("-plugin-opt=new-pass-manager");
+else
+  CmdArgs.push_back("-plugin-opt=no-new-pass-manager");
   }
 
   // Setup statistics file output.


Index: clang/test/Driver/fnew-pass-manager.c
===
--- clang/test/Driver/fnew-pass-manager.c
+++ clang/test/Driver/fnew-pass-manager.c
@@ -19,8 +19,12 @@
 
 // LTO_NEW:"-plugin-opt=new-pass-manager"
 
-/// TODO Add the negative option and pass it to the linker.
 // RUN: %clang -### -target x86_64-linux -flto -fno-new-pass-manager %s 2>&1 | FileCheck --check-prefix=LTO_LEGACY %s
 // RUN: %clang -### -target x86_64-linux -flto=thin -fno-experimental-new-pass-manager %s 2>&1 | FileCheck --check-prefix=LTO_LEGACY %s
 
-// LTO_LEGACY-NOT: "-plugin-opt=new-pass-manager"
+// LTO_LEGACY: "-plugin-opt=no-new-pass-manager"
+
+// RUN: %clang -### -target x86_64-linux -flto %s 2>&1 | FileCheck --check-prefix=DEFAULT %s
+
+// DEFAULT-NOT: "-plugin-opt=new-pass-manager"
+// DEFAULT-NOT: "-plugin-opt=no-new-pass-manager"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -595,11 +595,13 @@
  Path));
   }
 
-  // Need this flag to turn on new pass manager via Gold plugin.
-  if (Args.hasFlag(options::OPT_fnew_pass_manager,
-   options::OPT_fno_new_pass_manager,
-   /* Default */ LLVM_ENABLE_NEW_PASS_MANAGER)) {
-CmdArgs.push_back("-plugin-opt=new-pass-manager");
+  // Pass an option to enable/disable the new pass manager.
+  if (auto *A = Args.getLastArg(options::OPT_fnew_pass_manager,
+options::OPT_fno_new_pass_manager)) {
+if (A->getOption().matches(options::OPT_fnew_pass_manager))
+  CmdArgs.push_back("-plugin-opt=new-pass-manager");
+else
+  CmdArgs.push_back("-plugin-opt=no-new-pass-manager");
   }
 
   // Setup statistics file output.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92039: [-Wcalled-once-parameter] Introduce 'called_once' attribute

2020-12-09 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

@aaron.ballman Can you please take a look at the attribute side of this?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92039/new/

https://reviews.llvm.org/D92039

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92854: [flang][driver] Add support for `-fsyntax-only`

2020-12-09 Thread Kiran Chandramohan via Phabricator via cfe-commits
kiranchandramohan added a comment.

A few comments.




Comment at: clang/lib/Driver/ToolChains/Flang.cpp:43-44
   } else if (isa(JA) || isa(JA)) {
-CmdArgs.push_back("-triple");
-CmdArgs.push_back(Args.MakeArgString(TripleStr));
 if (JA.getType() == types::TY_Nothing) {

Why?



Comment at: flang/include/flang/Frontend/CompilerInstance.h:32
 
+  /// The stream for diagnostics from Semaantics
+  llvm::raw_ostream *semaOutputStream_ = &llvm::errs();

Nit: Semaantics -> Semantics



Comment at: flang/include/flang/Frontend/CompilerInstance.h:103-107
+  /// Replace the current stream for verbose output.
+  void set_semaOutputStream(llvm::raw_ostream &Value);
+
+  /// Replace the current stream for verbose output.
+  void set_semaOutputStream(std::unique_ptr Value);

What is the coding style of this file?



Comment at: flang/lib/Frontend/CMakeLists.txt:16
   FortranParser
+  FortranSemantics
+  FortranCommon

Is Evaluate needed?



Comment at: flang/lib/Frontend/FrontendActions.cpp:81
+  // Parse
+  ci.parsing().Parse(llvm::outs());
+  auto &parseTree{*ci.parsing().parseTree()};

What is the use of output stream here? 



Comment at: flang/lib/Frontend/FrontendActions.cpp:82
+  ci.parsing().Parse(llvm::outs());
+  auto &parseTree{*ci.parsing().parseTree()};
+

Will the Prescan step have happened before?



Comment at: flang/lib/Frontend/FrontendActions.cpp:84
+
+  // Prepare semantincs
+  Fortran::semantics::SemanticsContext semanticsContext{

Nit: semantincs -> semantics



Comment at: flang/test/Flang-Driver/syntax-only.f90:1
+! RUN: %flang-new -fc1 -fsyntax-only %s 2>&1 | FileCheck %s
+

should there be a test without fc1?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92854/new/

https://reviews.llvm.org/D92854

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92298: [AST][RecoveryAST] Preserve type for member call expr if argments are not matched.

2020-12-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 310450.
hokein added a comment.

address comments

- add a allowRecovery flag to avoid bad side-effect on other callsides;
- recover more cases;


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92298/new/

https://reviews.llvm.org/D92298

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/AST/ast-dump-recovery.cpp

Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -42,6 +42,9 @@
 // DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
 int ambig_call = ambig_func(123);
 
+class ForwardClass;
+ForwardClass createFwd();
+auto s = createFwd();
 // CHECK: VarDecl {{.*}} unresolved_call1
 // CHECK-NEXT:`-RecoveryExpr {{.*}} '' contains-errors
 // CHECK-NEXT:  `-UnresolvedLookupExpr {{.*}} 'bar'
@@ -121,6 +124,23 @@
   foo->func(x);
 }
 
+struct Foo2 {
+  double func();
+  class ForwardClass;
+  ForwardClass createFwd();
+};
+void test2(Foo2 f) {
+  // CHECK:  RecoveryExpr {{.*}} 'double'
+  // CHECK-NEXT:   |-MemberExpr {{.*}} ''
+  // CHECK-NEXT:   | `-DeclRefExpr {{.*}} 'f'
+  // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
+  f.func(1);
+  // CHECK:  RecoveryExpr {{.*}} 'Foo2::ForwardClass'
+  // CHECK-NEXT: `-MemberExpr {{.*}} '' .createFwd
+  // CHECK-NEXT:   `-DeclRefExpr {{.*}} 'f'
+  f.createFwd();
+}
+
 // CHECK: |-AlignedAttr {{.*}} alignas
 // CHECK-NEXT:| `-RecoveryExpr {{.*}} contains-errors
 // CHECK-NEXT:|   `-UnresolvedLookupExpr {{.*}} 'invalid'
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -14154,11 +14154,11 @@
 /// parameter). The caller needs to validate that the member
 /// expression refers to a non-static member function or an overloaded
 /// member function.
-ExprResult
-Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
-SourceLocation LParenLoc,
-MultiExprArg Args,
-SourceLocation RParenLoc) {
+ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
+   SourceLocation LParenLoc,
+   MultiExprArg Args,
+   SourceLocation RParenLoc,
+   bool allowRecovery) {
   assert(MemExprE->getType() == Context.BoundMemberTy ||
  MemExprE->getType() == Context.OverloadTy);
 
@@ -14215,6 +14215,14 @@
 return MaybeBindToTemporary(call);
   }
 
+  auto BuildRecoveryExpr = [&](QualType Type) {
+if (!allowRecovery)
+  return ExprError();
+std::vector SubExprs = {MemExprE};
+llvm::for_each(Args, [&SubExprs](Expr *E) { SubExprs.push_back(E); });
+return CreateRecoveryExpr(MemExprE->getBeginLoc(), RParenLoc, SubExprs,
+  Type);
+  };
   if (isa(NakedMemExpr))
 return CallExpr::Create(Context, MemExprE, Args, Context.VoidTy, VK_RValue,
 RParenLoc, CurFPFeatureOverrides());
@@ -14362,7 +14370,7 @@
   // Check for a valid return type.
   if (CheckCallReturnType(Method->getReturnType(), MemExpr->getMemberLoc(),
   TheCall, Method))
-return ExprError();
+return BuildRecoveryExpr(ResultType);
 
   // Convert the object argument (for a non-static member function call).
   // We only need to do this if there was actually an overload; otherwise
@@ -14379,7 +14387,7 @@
   // Convert the rest of the arguments
   if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args,
   RParenLoc))
-return ExprError();
+return BuildRecoveryExpr(ResultType);
 
   DiagnoseSentinelCalls(Method, LParenLoc, Args);
 
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6308,8 +6308,8 @@
 ExprResult Sema::ActOnCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
MultiExprArg ArgExprs, SourceLocation RParenLoc,
Expr *ExecConfig) {
-  ExprResult Call =
-  BuildCallExpr(Scope, Fn, LParenLoc, ArgExprs, RParenLoc, ExecConfig);
+  ExprResult Call = BuildCallExpr(Scope, Fn, LParenLoc, ArgExprs, RParenLoc,
+  ExecConfig, false, true);
   if (Call.isInvalid())
 return Call;
 
@@ -6337,7 +6337,8 @@
 /// locations.
 ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
MultiExprArg ArgExprs, SourceLocation RParenLoc,
-   Expr *ExecConfig, bool IsExecConfig) {
+   

[PATCH] D92494: [clangd] Bundle code completion items when the include paths differ, but resolve to the same file.

2020-12-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:187
+  if (auto Header = headerToInsertIfAllowed(Opts))
+if (auto HeaderFile = toHeaderFile(*Header, FileName))
+  if (auto Spelled =

(sorry for the late drive by comment)

if this returns an error it needs to be consumed to ensure we don't crash 
(destructor of `Expected` asserts)

but apart from that, this introduces lots of new string manipulations for every 
completion item, might have bad impact on latency especially when the include 
paths are long and require heap allocations. something to keep in mind once 
this hits production (and maybe we can choose to approximate or not do it at 
all if it turns out to be problematic)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92494/new/

https://reviews.llvm.org/D92494

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92298: [AST][RecoveryAST] Preserve type for member call expr if argments are not matched.

2020-12-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D92298#2439325 , @sammccall wrote:

> The thrust of this change is great, I'm just having trouble being sure there 
> are no bad side-effects.
>
> ---
>
> I almost left a comment here saying we might want to recover here... before 
> noticing that we recover all the way up at ParsePostfixExpressionSuffix().
>
> It may be worth a comment on the function implementation that RecoveryExpr 
> fallback is done at a higher level.
> But on this note, I think we have to consider the effect on *other* callsites.
> For example `Sema::tryExprAsCall` checks if the result is non-null in order 
> to produce "function must be callled, did you mean to call with no 
> arguments"... but now I think we're returning non-null even if args are 
> required. The fix there is to check containsErrors too.
>
> There are a bunch of "internal" uses to Sema::BuildCallExpr (which calls this 
> function), like coroutines, decomposition, pseudo-object etc that might need 
> to be checked.
>
> Finally BuildRecoveryCallExpr in SemaOverload itself calls BuildCallExpr, and 
> maybe we can end up with a RecoveryExpr wrapping a RecoveryExpr.
>
> ---
>
> I'm not sure what the most principled thing to do here is. Recovering (only) 
> at a higher level seems sensible, but then we lack a way to propagate the 
> type. Checking for containsErrors() where needed seems fragile. Adding a new 
> state to ExprResult (null/error/Expr/QualType) is a pretty big change that 
> may not be useful in general.
>
> I'm not opposed to this patch if we carefully audit all callers but this 
> doesn't feel great. Maybe an ugly "allowRecovery" flag to BuildCallExpr is 
> the right compromise, at least it forces us to be explicit.

This is a good point, thanks for raising it.

> Recovering (only) at a higher level seems sensible, but then we lack a way to 
> propagate the type.

This looks reasonable. Currently we already perform the recovery when a 
CallExpr node is failed to build (in ParseExpr.cpp), but the type is always 
dependent. We could add some heuristics there to propagate the type as the Fn 
is known (but we might end up with duplicated logics as those in 
`SemaOverload.cpp`)

so yeah, adding a flag to BuildCallExpr and other related methods seems like a 
right compromise, it doesn't hurt the existing diagnostics while allowing us to 
preserve the type, and https://reviews.llvm.org/D80109 also needs that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92298/new/

https://reviews.llvm.org/D92298

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92920: [clang-tidy] Add a diagnostic callback to parseConfiguration

2020-12-09 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: alexfh, aaron.ballman, gribozavr2.
Herald added a subscriber: xazax.hun.
njames93 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Currently errors detected when parsing the YAML for .clang-tidy files are 
always printed to errs.
For clang-tidy binary workflows this usually isn't an issue, but using 
clang-tidy as a library for integrations may want to handle displaying those 
errors in their own specific way.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92920

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h


Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -313,6 +313,11 @@
 /// error.
 llvm::ErrorOr parseConfiguration(llvm::StringRef Config);
 
+using DiagCallback = llvm::function_ref;
+
+llvm::ErrorOr
+parseConfigurationWithDiags(llvm::StringRef Config, DiagCallback Handler);
+
 /// Serializes configuration to a YAML-encoded string.
 std::string configurationAsText(const ClangTidyOptions &Options);
 
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -389,6 +389,22 @@
   return Options;
 }
 
+static void diagHandlerImpl(const llvm::SMDiagnostic &Diag, void *Ctx) {
+  (*reinterpret_cast(Ctx))(Diag);
+};
+
+llvm::ErrorOr
+parseConfigurationWithDiags(StringRef Config, DiagCallback Handler) {
+  if (!Handler)
+return parseConfiguration(Config);
+  llvm::yaml::Input Input(Config, nullptr, diagHandlerImpl, &Handler);
+  ClangTidyOptions Options;
+  Input >> Options;
+  if (Input.error())
+return Input.error();
+  return Options;
+}
+
 std::string configurationAsText(const ClangTidyOptions &Options) {
   std::string Text;
   llvm::raw_string_ostream Stream(Text);


Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -313,6 +313,11 @@
 /// error.
 llvm::ErrorOr parseConfiguration(llvm::StringRef Config);
 
+using DiagCallback = llvm::function_ref;
+
+llvm::ErrorOr
+parseConfigurationWithDiags(llvm::StringRef Config, DiagCallback Handler);
+
 /// Serializes configuration to a YAML-encoded string.
 std::string configurationAsText(const ClangTidyOptions &Options);
 
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -389,6 +389,22 @@
   return Options;
 }
 
+static void diagHandlerImpl(const llvm::SMDiagnostic &Diag, void *Ctx) {
+  (*reinterpret_cast(Ctx))(Diag);
+};
+
+llvm::ErrorOr
+parseConfigurationWithDiags(StringRef Config, DiagCallback Handler) {
+  if (!Handler)
+return parseConfiguration(Config);
+  llvm::yaml::Input Input(Config, nullptr, diagHandlerImpl, &Handler);
+  ClangTidyOptions Options;
+  Input >> Options;
+  if (Input.error())
+return Input.error();
+  return Options;
+}
+
 std::string configurationAsText(const ClangTidyOptions &Options) {
   std::string Text;
   llvm::raw_string_ostream Stream(Text);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 13e4e5e - Revert "[clang][cli] CompilerInvocationTest: add tests for boolean options"

2020-12-09 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2020-12-09T10:35:07+01:00
New Revision: 13e4e5ed59c92d81ee5fee55f20ecf1842ec8cf3

URL: 
https://github.com/llvm/llvm-project/commit/13e4e5ed59c92d81ee5fee55f20ecf1842ec8cf3
DIFF: 
https://github.com/llvm/llvm-project/commit/13e4e5ed59c92d81ee5fee55f20ecf1842ec8cf3.diff

LOG: Revert "[clang][cli] CompilerInvocationTest: add tests for boolean options"

Differential Revision of original patch: https://reviews.llvm.org/D92774

Added: 


Modified: 
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp 
b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index b0fe11dd8d5b..c3bdd6bff65c 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -77,150 +77,6 @@ TEST_F(CommandLineTest, 
BoolOptionDefaultTrueSingleFlagUnknownPresent) {
   ASSERT_TRUE(Invocation.getFrontendOpts().UseTemporary);
 }
 
-// Boolean option with a keypath that defaults to true.
-// The flag with negative spelling can set the keypath to false.
-// The flag with positive spelling can reset the keypath to true.
-
-TEST_F(CommandLineTest, BoolOptionDefaultTruePresentNone) {
-  const char *Args[] = {""};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_TRUE(Invocation.getCodeGenOpts().Autolink);
-
-  // TODO: Test argument generation.
-}
-
-TEST_F(CommandLineTest, BoolOptionDefaultTruePresentNegChange) {
-  const char *Args[] = {"-fno-autolink"};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_FALSE(Invocation.getCodeGenOpts().Autolink);
-
-  // TODO: Test argument generation.
-}
-
-TEST_F(CommandLineTest, BoolOptionDefaultTruePresentPosReset) {
-  const char *Args[] = {"-fautolink"};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_TRUE(Diags->hasErrorOccurred()); // Driver-only flag.
-  ASSERT_TRUE(Invocation.getCodeGenOpts().Autolink);
-}
-
-// Boolean option with a keypath that defaults to false.
-// The flag with negative spelling can set the keypath to true.
-// The flag with positive spelling can reset the keypath to false.
-
-TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNone) {
-  const char *Args[] = {""};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_FALSE(Invocation.getCodeGenOpts().NoInlineLineTables);
-
-  // TODO: Test argument generation.
-}
-
-TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNegChange) {
-  const char *Args[] = {"-gno-inline-line-tables"};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_TRUE(Invocation.getCodeGenOpts().NoInlineLineTables);
-
-  // TODO: Test argument generation.
-}
-
-TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentPosReset) {
-  const char *Args[] = {"-ginline-line-tables"};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_TRUE(Diags->hasErrorOccurred()); // Driver-only flag.
-  ASSERT_FALSE(Invocation.getCodeGenOpts().NoInlineLineTables);
-}
-
-// Boolean option with a keypath that defaults to false.
-// The flag with positive spelling can set the keypath to true.
-// The flag with negative spelling can reset the keypath to false.
-
-TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNoneX) {
-  const char *Args[] = {""};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_FALSE(Invocation.getCodeGenOpts().CodeViewGHash);
-
-  // TODO: Test argument generation.
-}
-
-TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentPosChange) {
-  const char *Args[] = {"-gcodeview-ghash"};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_TRUE(Invocation.getCodeGenOpts().CodeViewGHash);
-
-  // TODO: Test argument generation.
-}
-
-TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNegReset) {
-  const char *Args[] = {"-gno-codeview-ghash"};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_TRUE(Diags->hasErrorOccurred()); // Driver-only flag.
-  ASSERT_FALSE(Invocation.getCodeGenOpts().CodeViewGHash);
-}
-
-// Boolean option with a keypath that defaults to an arbitrary expression.
-// The flag with positive spelling can set the keypath to true.
-// The flag with negative spelling can set the keypath to false.
-
-// NOTE: The following tests need to be updated when we start enabling the new
-// pass manager by default.
-
-TEST_F(CommandLineTest, BoolOptionDefaultArbitraryTwoFlagsPresentNone) {
-  const char *Args = {""};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
-  ASSERT_FALSE(Diags->hasE

[PATCH] D92381: [clangd] Extract per-dir CDB cache to its own threadsafe class. NFC

2020-12-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!




Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:79
+  // Absolute canonical path that we're the cache for. (Not case-folded).
+  std::string Path;
+

nit: mark it const ?



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:117
+auto RequestBroadcast = llvm::make_scope_exit([&] {
+  if (ShouldBroadcast) {
+ShouldBroadcast = NeedsBroadcast;

nit: early exit



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:128
+
+load();
+CachePopulated = true;

nit: maybe stash modification of control signals to `load()` rather than having 
them split between `load()` and `get()` (or alternatively just change the 
`load` to return a `{shared,unique}_ptr` while making it a free function and 
then perform all the signal modifications inside `get`)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92381/new/

https://reviews.llvm.org/D92381

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92774: [clang][cli] CompilerInvocationTest: add tests for boolean options

2020-12-09 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

This patch was reverted as it broke a build: 
http://lab.llvm.org:8011/#/builders/14/builds/2986

The assertions will need to take into account the actual value of 
`LLVM_ENABLE_NEW_PASS_MANAGER`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92774/new/

https://reviews.llvm.org/D92774

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92922: [clang-format] PR42434 Remove preprocessor and pragma lines from ObjectiveC guess

2020-12-09 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: curdeius, krasimir, JakeMerdichAMD.
MyDeveloperDay added projects: clang, clang-format.
MyDeveloperDay requested review of this revision.

clang-format see the `disable:` in   __pragma(waring(disable:)) as ObjectiveC 
method call

Remove any line starting with `#` or __pragma line from being part of the 
ObjectiveC guess

https://bugs.llvm.org/show_bug.cgi?id=42434


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92922

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16713,6 +16713,13 @@
   guessLanguage("foo.h", "int(^foo[(kNumEntries + 10)])(char, float);"));
 }
 
+TEST_F(FormatTest, GuessLanguageWithPragmas) {
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "__pragma(warning(disable:))"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "#pragma(warning(disable:))"));
+}
+
 TEST_F(FormatTest, FormatsInlineAsmSymbolicNames) {
   // ASM symbolic names are identifiers that must be surrounded by [] without
   // space in between:
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2032,6 +2032,12 @@
 };
 
 for (auto Line : AnnotatedLines) {
+  if (Line->First) {
+if (Line->First->TokenText.startswith("#") ||
+Line->First->TokenText == "__pragma") {
+  continue;
+}
+  }
   for (const FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
 if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16713,6 +16713,13 @@
   guessLanguage("foo.h", "int(^foo[(kNumEntries + 10)])(char, float);"));
 }
 
+TEST_F(FormatTest, GuessLanguageWithPragmas) {
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "__pragma(warning(disable:))"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "#pragma(warning(disable:))"));
+}
+
 TEST_F(FormatTest, FormatsInlineAsmSymbolicNames) {
   // ASM symbolic names are identifiers that must be surrounded by [] without
   // space in between:
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2032,6 +2032,12 @@
 };
 
 for (auto Line : AnnotatedLines) {
+  if (Line->First) {
+if (Line->First->TokenText.startswith("#") ||
+Line->First->TokenText == "__pragma") {
+  continue;
+}
+  }
   for (const FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
 if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2020-12-09 Thread Hiral via Phabricator via cfe-commits
Hiralo added a comment.

We are dependent on this patch to exclude headers in regex while running 
clang-tidy.
Can we have this patch merged with upcoming GA versions? or
Can someone summarize what is pending in this review or what could be good 
alternative in v11 clang-tidy?
Thank you in advance.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D34654/new/

https://reviews.llvm.org/D34654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88393: [cfe][M68k] (Patch 7/8) Basic Clang support

2020-12-09 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/lib/Basic/Targets/M68k.h:14
+#ifndef M680X0_H_LTNCIPAD
+#define M680X0_H_LTNCIPAD
+

@myhsu This should probably be  LLVM_CLANG_LIB_BASIC_TARGETS_M68K_H


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88393/new/

https://reviews.llvm.org/D88393

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92852: [NFC] Reduce include files dependency and AA header cleanup (part 2).

2020-12-09 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

This patch is very busy with 3 different aims - maybe split into 3 patches? The 
constifications, the include cleanup and the getModRefInfo tweak


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92852/new/

https://reviews.llvm.org/D92852

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92920: [clang-tidy] Add a diagnostic callback to parseConfiguration

2020-12-09 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 310476.
njames93 added a comment.

Use MemoryBufferRef instead of StringRef so the Diagnostic can have a 
meaningful filename.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92920/new/

https://reviews.llvm.org/D92920

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h


Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -14,6 +14,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/MemoryBufferRef.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include 
 #include 
@@ -313,6 +314,11 @@
 /// error.
 llvm::ErrorOr parseConfiguration(llvm::StringRef Config);
 
+using DiagCallback = llvm::function_ref;
+
+llvm::ErrorOr
+parseConfigurationWithDiags(llvm::MemoryBufferRef Config, DiagCallback 
Handler);
+
 /// Serializes configuration to a YAML-encoded string.
 std::string configurationAsText(const ClangTidyOptions &Options);
 
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -13,6 +13,7 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBufferRef.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/YAMLTraits.h"
 #include "llvm/Support/raw_ostream.h"
@@ -389,6 +390,22 @@
   return Options;
 }
 
+static void diagHandlerImpl(const llvm::SMDiagnostic &Diag, void *Ctx) {
+  (*reinterpret_cast(Ctx))(Diag);
+};
+
+llvm::ErrorOr
+parseConfigurationWithDiags(llvm::MemoryBufferRef Config,
+DiagCallback Handler) {
+  llvm::yaml::Input Input(Config, nullptr, Handler ? diagHandlerImpl : nullptr,
+  &Handler);
+  ClangTidyOptions Options;
+  Input >> Options;
+  if (Input.error())
+return Input.error();
+  return Options;
+}
+
 std::string configurationAsText(const ClangTidyOptions &Options) {
   std::string Text;
   llvm::raw_string_ostream Stream(Text);


Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -14,6 +14,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/MemoryBufferRef.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include 
 #include 
@@ -313,6 +314,11 @@
 /// error.
 llvm::ErrorOr parseConfiguration(llvm::StringRef Config);
 
+using DiagCallback = llvm::function_ref;
+
+llvm::ErrorOr
+parseConfigurationWithDiags(llvm::MemoryBufferRef Config, DiagCallback Handler);
+
 /// Serializes configuration to a YAML-encoded string.
 std::string configurationAsText(const ClangTidyOptions &Options);
 
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -13,6 +13,7 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBufferRef.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/YAMLTraits.h"
 #include "llvm/Support/raw_ostream.h"
@@ -389,6 +390,22 @@
   return Options;
 }
 
+static void diagHandlerImpl(const llvm::SMDiagnostic &Diag, void *Ctx) {
+  (*reinterpret_cast(Ctx))(Diag);
+};
+
+llvm::ErrorOr
+parseConfigurationWithDiags(llvm::MemoryBufferRef Config,
+DiagCallback Handler) {
+  llvm::yaml::Input Input(Config, nullptr, Handler ? diagHandlerImpl : nullptr,
+  &Handler);
+  ClangTidyOptions Options;
+  Input >> Options;
+  if (Input.error())
+return Input.error();
+  return Options;
+}
+
 std::string configurationAsText(const ClangTidyOptions &Options) {
   std::string Text;
   llvm::raw_string_ostream Stream(Text);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92639: [analyzer] Add control flow arrows to the analyzer's HTML reports

2020-12-09 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 310481.
vsavchenko added a comment.

Replace let with const


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92639/new/

https://reviews.llvm.org/D92639

Files:
  clang/include/clang/Analysis/PathDiagnostic.h
  clang/lib/Rewrite/HTMLRewrite.cpp
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/test/Analysis/html_diagnostics/control-arrows.cpp

Index: clang/test/Analysis/html_diagnostics/control-arrows.cpp
===
--- /dev/null
+++ clang/test/Analysis/html_diagnostics/control-arrows.cpp
@@ -0,0 +1,27 @@
+// RUN: rm -fR %t
+// RUN: mkdir %t
+// RUN: %clang_analyze_cc1 -analyzer-checker=core \
+// RUN:-analyzer-output=html -o %t -verify %s
+// RUN: cat %t/report-*.html | FileCheck %s
+
+int dereference(int *x) {
+  return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
+}
+
+int foobar(bool cond, int *x) {
+  if (cond)
+x = 0;
+  return dereference(x);
+}
+
+// CHECK:  
+// CHECK-NOT:  
+// CHECK:
+// CHECK-NEXT: 
+//
+// Except for arrows we still want to have grey bubbles with control notes.
+// CHECK:  2
+// CHECK-SAME:   Taking true branch
Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -10,11 +10,11 @@
 //
 //===--===//
 
-#include "clang/Analysis/IssueHash.h"
-#include "clang/Analysis/PathDiagnostic.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/Stmt.h"
+#include "clang/Analysis/IssueHash.h"
+#include "clang/Analysis/PathDiagnostic.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
@@ -26,6 +26,7 @@
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Sequence.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator_range.h"
@@ -88,6 +89,10 @@
  const PathDiagnosticMacroPiece& P,
  unsigned num);
 
+  unsigned ProcessControlFlowPiece(Rewriter &R, FileID BugFileID,
+   const PathDiagnosticControlFlowPiece &P,
+   unsigned Number);
+
   void HandlePiece(Rewriter &R, FileID BugFileID, const PathDiagnosticPiece &P,
const std::vector &PopUpRanges, unsigned num,
unsigned max);
@@ -112,14 +117,22 @@
   // Rewrite the file specified by FID with HTML formatting.
   void RewriteFile(Rewriter &R, const PathPieces& path, FileID FID);
 
+  PathGenerationScheme getGenerationScheme() const override {
+return Everything;
+  }
 
 private:
+  void addArrowSVGs(Rewriter &R, FileID BugFileID, unsigned NumberOfArrows);
+
   /// \return Javascript for displaying shortcuts help;
   StringRef showHelpJavascript();
 
   /// \return Javascript for navigating the HTML report using j/k keys.
   StringRef generateKeyboardNavigationJavascript();
 
+  /// \return Javascript for drawing control-flow arrows.
+  StringRef generateArrowDrawingJavascript();
+
   /// \return JavaScript for an option to only show relevant lines.
   std::string showRelevantLinesJavascript(
 const PathDiagnostic &D, const PathPieces &path);
@@ -130,6 +143,17 @@
 llvm::raw_string_ostream &os);
 };
 
+bool isArrowPiece(const PathDiagnosticPiece &P) {
+  return isa(P) && P.getString().empty();
+}
+
+unsigned getPathSizeWithoutArrows(const PathPieces &Path) {
+  unsigned TotalPieces = Path.size();
+  unsigned TotalArrowPieces = llvm::count_if(
+  Path, [](const PathDiagnosticPieceRef &P) { return isArrowPiece(*P); });
+  return TotalPieces - TotalArrowPieces;
+}
+
 } // namespace
 
 void ento::createHTMLDiagnosticConsumer(
@@ -434,7 +458,7 @@
   if (event.key == "S") {
 var checked = document.getElementsByName("showCounterexample")[0].checked;
 filterCounterexample(!checked);
-document.getElementsByName("showCounterexample")[0].checked = !checked;
+document.getElementsByName("showCounterexample")[0].click();
   } else {
 return;
   }
@@ -454,6 +478,11 @@
 
Show only relevant lines
 
+
+
+   Show control flow arrows
+
 
 )<<<";
 
@@ -482,6 +511,9 @@
   R.InsertTextBefore(SMgr.getLocForStartOfFile(FID),
  generateKeyboardNavigationJavascript());
 
+  R.InsertTextBefore(SMgr.getLocForStartOfFile(FID),
+ generateArrowDrawingJavascript());
+
   // Checkbox and javascript for filtering the 

[PATCH] D92928: [analyzer] Highlight arrows for currently selected event

2020-12-09 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
Herald added subscribers: steakhal, ASDenysPetrov, martong, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
vsavchenko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In some cases, when the execution path of the diagnostic
goes back and forth, arrows can overlap and create a mess.
Dimming arrows that are not relevant at the moment, solves this issue.
They are still visible, but don't draw too much attention.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92928

Files:
  clang/lib/Rewrite/HTMLRewrite.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/test/Analysis/html_diagnostics/control-arrows.cpp

Index: clang/test/Analysis/html_diagnostics/control-arrows.cpp
===
--- clang/test/Analysis/html_diagnostics/control-arrows.cpp
+++ clang/test/Analysis/html_diagnostics/control-arrows.cpp
@@ -16,10 +16,13 @@
 
 // CHECK:  
-// CHECK-NOT:  
+// CHECK-COUNT-9:  
+// CHECK-NOT:  
 // CHECK:
 // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: const arrowIndices = [ 9,8,6,5,3,2,0 ]
+// CHECK-NEXT: 
 //
 // Except for arrows we still want to have grey bubbles with control notes.
 // CHECK:   {
+  using Base = std::vector;
+
+public:
+  ArrowMap(unsigned Size) : Base(Size, 0) {}
+  unsigned getTotalNumberOfArrows() const { return at(0); }
+};
+
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const ArrowMap &Indices) {
+  OS << "[ ";
+  llvm::interleave(Indices, OS, ",");
+  return OS << " ]";
+}
+
 } // namespace
 
 void ento::createHTMLDiagnosticConsumer(
@@ -744,6 +762,7 @@
   unsigned NumberOfArrows = 0;
   // Stores the count of the regular piece indices.
   std::map IndexMap;
+  ArrowMap ArrowIndices(TotalRegularPieces + 1);
 
   // Stores the different ranges where we have reported something.
   std::vector PopUpRanges;
@@ -762,13 +781,30 @@
 } else if (isArrowPiece(Piece)) {
   NumberOfArrows = ProcessControlFlowPiece(
   R, FID, cast(Piece), NumberOfArrows);
+  ArrowIndices[NumRegularPieces] = NumberOfArrows;
 
 } else {
   HandlePiece(R, FID, Piece, PopUpRanges, NumRegularPieces,
   TotalRegularPieces);
   --NumRegularPieces;
+  ArrowIndices[NumRegularPieces] = ArrowIndices[NumRegularPieces + 1];
 }
   }
+  ArrowIndices[0] = NumberOfArrows;
+
+  // At this point ArrowIndices represent the following data structure:
+  //   [a_0, a_1, ..., a_N]
+  // where N is the number of events in the path.
+  //
+  // Then for every event with index i \in [0, N - 1], we can say that
+  // arrows with indices \in [a_(i+1), a_i) correspond to that event.
+  // We can say that because arrows with these indices appeared in the
+  // path in between the i-th and the (i+1)-th events.
+  assert(ArrowIndices.back() == 0 &&
+ "No arrows should be after the last event");
+  // This assertion also guarantees that all indices in are <= NumberOfArrows.
+  assert(llvm::is_sorted(ArrowIndices, std::greater()) &&
+ "Incorrect arrow indices map");
 
   // Secondary indexing if we are having multiple pop-ups between two notes.
   // (e.g. [(13) 'a' is 'true'];  [(13.1) 'b' is 'false'];  [(13.2) 'c' is...)
@@ -802,7 +838,7 @@
   html::EscapeText(R, FID);
   html::AddLineNumbers(R, FID);
 
-  addArrowSVGs(R, FID, NumberOfArrows);
+  addArrowSVGs(R, FID, ArrowIndices);
 
   // If we have a preprocessor, relex the file and syntax highlight.
   // We might not have a preprocessor if we come from a deserialized AST file,
@@ -1071,7 +1107,7 @@
 }
 
 void HTMLDiagnostics::addArrowSVGs(Rewriter &R, FileID BugFileID,
-   unsigned NumberOfArrows) {
+   const ArrowMap &ArrowIndices) {
   std::string S;
   llvm::raw_string_ostream OS(S);
 
@@ -1086,27 +1122,52 @@
   pointer-events: none;
   overflow: visible
   }
+  .arrow {
+  stroke-opacity: 0.2;
+  stroke-width: 1;
+  marker-end: url(#arrowhead);
+  }
+
+  .arrow.selected {
+  stroke-opacity: 0.6;
+  stroke-width: 2;
+  marker-end: url(#arrowheadSelected);
+  }
+
+  .arrowhead {
+  orient: auto;
+  stroke: none;
+  opacity: 0.6;
+  fill: blue;
+  }
 
 http://www.w3.org/2000/svg";>
   
-
+
+  
+
+
   
 
   
-  
+  
 )<<<";
 
-  for (unsigned Index : llvm::seq(0u, NumberOfArrows)) {
-OS << "\n";
+  for (unsigned Index : llvm::seq(0u, ArrowIndices.getTotalNumberOfArrows())) {
+OS << "\n";
   }
 
   OS << R"<<<(
   
 
-)<<<";
+
+const arrowIndices = )<<<";
+
+  OS << ArrowIndices << "\n\n";
 
   R.InsertTextBefore(R.getSourceMgr().getLocForStartOfFile(BugFileID),
  OS.str());
@@ -1203,7 +1264,7 @@
 });
 
 var findNum = function() {
-var s = do

[PATCH] D92928: [analyzer] Highlight arrows for currently selected event

2020-12-09 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Here is the HTML file for the test.F14639004: report-399795.html 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92928/new/

https://reviews.llvm.org/D92928

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92080: [Clang] Mutate long-double math builtins into f128 under IEEE-quad

2020-12-09 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

Please can you pre-commit math-builtins-adjust.c with current IR checks and 
then rebase to show the diffs? Maybe rename it math-builtins-long.c as well?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92080/new/

https://reviews.llvm.org/D92080

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92432: [analyzer] Add a thin abstraction layer between libCrossTU and libAnalysis.

2020-12-09 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/include/clang/CrossTU/CrossTranslationUnit.h:124
 /// Note that this class also implements caching.
-class CrossTranslationUnitContext {
+class CrossTranslationUnitContext : public CrossTUAnalysisHelper {
 public:

Why don't we have a dependency in libCrossTU to libAnalysis? In the 
CMakeLists.txt?
Here we implement the CrossTUAnalysisHelper's abstract virtual function thus we 
include the `CrossTUAnalysisHelper.h`. But 
CMake should know about the dependency even if this is only a header only 
dependency, shouldn't it? (We were talking about this with @steakhal.)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92432/new/

https://reviews.llvm.org/D92432

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92846: [KernelAddressSanitizer] Fix globals exclusion for indirect aliases

2020-12-09 Thread Marco Elver via Phabricator via cfe-commits
melver updated this revision to Diff 310488.
melver added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92846/new/

https://reviews.llvm.org/D92846

Files:
  clang/test/CodeGen/asan-globals-alias.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -792,7 +792,8 @@
   StringRef InternalSuffix);
   Instruction *CreateAsanModuleDtor(Module &M);
 
-  bool canInstrumentAliasedGlobal(const GlobalAlias &GA) const;
+  const GlobalVariable *getExcludedAliasedGlobal(const GlobalAlias &GA,
+ bool Rec = false) const;
   bool shouldInstrumentGlobal(GlobalVariable *G) const;
   bool ShouldUseMachOGlobalsSection() const;
   StringRef getGlobalMetadataSection() const;
@@ -1787,20 +1788,39 @@
   }
 }
 
-bool ModuleAddressSanitizer::canInstrumentAliasedGlobal(
-const GlobalAlias &GA) const {
-  // In case this function should be expanded to include rules that do not just
-  // apply when CompileKernel is true, either guard all existing rules with an
-  // 'if (CompileKernel) { ... }' or be absolutely sure that all these rules
-  // should also apply to user space.
-  assert(CompileKernel && "Only expecting to be called when compiling kernel");
-
-  // When compiling the kernel, globals that are aliased by symbols prefixed
-  // by "__" are special and cannot be padded with a redzone.
-  if (GA.getName().startswith("__"))
-return false;
+const GlobalVariable *
+ModuleAddressSanitizer::getExcludedAliasedGlobal(const GlobalAlias &GA,
+ bool Rec) const {
+  if (!Rec) { // Non-recursive case.
+// In case this function should be expanded to include rules that do not
+// just apply when CompileKernel is true, either guard all existing rules
+// with an 'if (CompileKernel) { ... }' or be absolutely sure that all these
+// rules should also apply to user space.
+assert(CompileKernel &&
+   "Only expecting to be called when compiling kernel");
+
+// When compiling the kernel, globals that are aliased by symbols prefixed
+// by "__" are special and cannot be padded with a redzone.
+if (!GA.getName().startswith("__"))
+  return nullptr;
+  }
+
+  if (const auto *GV = dyn_cast(GA.getAliasee())) {
+// Find GlobalVariable from aliasee.
+return GV;
+  } else if (const auto *CE = dyn_cast(GA.getAliasee())) {
+// Pointer expression into GlobalVariable; find it from one of the operands.
+for (const Use &U : CE->operands()) {
+  if (const auto *GV = dyn_cast(U))
+return GV;
+}
+  } else if (const auto *GAA = dyn_cast(GA.getAliasee())) {
+// Recursive GlobalAlias
+return getExcludedAliasedGlobal(*GAA, true);
+  }
 
-  return true;
+  // Not a GlobalVariable alias, ignore.
+  return nullptr;
 }
 
 bool ModuleAddressSanitizer::shouldInstrumentGlobal(GlobalVariable *G) const {
@@ -2252,14 +2272,12 @@
   *CtorComdat = false;
 
   // Build set of globals that are aliased by some GA, where
-  // canInstrumentAliasedGlobal(GA) returns false.
+  // getExcludedAliasedGlobal(GA) returns the relevant GlobalVariable.
   SmallPtrSet AliasedGlobalExclusions;
   if (CompileKernel) {
 for (auto &GA : M.aliases()) {
-  if (const auto *GV = dyn_cast(GA.getAliasee())) {
-if (!canInstrumentAliasedGlobal(GA))
-  AliasedGlobalExclusions.insert(GV);
-  }
+  if (const GlobalVariable *GV = getExcludedAliasedGlobal(GA))
+AliasedGlobalExclusions.insert(GV);
 }
   }
 
Index: clang/test/CodeGen/asan-globals-alias.cpp
===
--- clang/test/CodeGen/asan-globals-alias.cpp
+++ clang/test/CodeGen/asan-globals-alias.cpp
@@ -1,17 +1,36 @@
 // RUN: %clang_cc1 -triple x86_64-linux -fsanitize=address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,ASAN
+// RUN: %clang_cc1 -triple x86_64-linux -O2 -fsanitize=address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,ASAN
 // RUN: %clang_cc1 -triple x86_64-linux -fsanitize=kernel-address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,KASAN
+// RUN: %clang_cc1 -triple x86_64-linux -O2 -fsanitize=kernel-address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,KASAN
 //
 // Not all platforms support aliases - test for Linux only.
 
-int global; // to generate ctor for at least 1 global
-int aliased_global; // KASAN - ignore globals prefixed by aliases with __-prefix (below)
-extern 

[PATCH] D92930: [Clang] Add vcmla and rotated variants for Arm ACLE.

2020-12-09 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
fhahn added reviewers: SjoerdMeijer, dmgreen, t.p.northover.
Herald added a subscriber: kristof.beyls.
fhahn requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch adds vcmla and the rotated variants as defined in
"Arm Neon Intrinsics Reference for ACLE Q3 2020" [1]

The *_lane_* are still missing, but they can be added separately.

This patch only adds the builtin mapping for AArch64.

[1] https://developer.arm.com/documentation/ihi0073/latest


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92930

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-vcmla.c

Index: clang/test/CodeGen/aarch64-neon-vcmla.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-neon-vcmla.c
@@ -0,0 +1,105 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon \
+// RUN:  -target-feature +v8.3a -target-feature +fullfp16 -S -emit-llvm -o - %s \
+// RUN:  | FileCheck %s
+
+#include 
+
+void foo_16x4(float16x4_t a, float16x4_t b, float16x4_t c) {
+ // CHECK: call <4 x half> @llvm.aarch64.neon.vcmla.v4f16
+  float16x4_t result = vcmla_f16(a, b, c);
+}
+
+void foo_rot90_16x4(float16x4_t a, float16x4_t b, float16x4_t c) {
+ // CHECK: call <4 x half> @llvm.aarch64.neon.vcmla.rot90.v4f16
+  float16x4_t result = vcmla_rot90_f16(a, b, c);
+}
+
+void foo_rot180_16x4(float16x4_t a, float16x4_t b, float16x4_t c) {
+ // CHECK: call <4 x half> @llvm.aarch64.neon.vcmla.rot180.v4f16
+  float16x4_t result = vcmla_rot180_f16(a, b, c);
+}
+
+void foo_rot270_16x4(float16x4_t a, float16x4_t b, float16x4_t c) {
+ // CHECK: call <4 x half> @llvm.aarch64.neon.vcmla.rot270.v4f16
+  float16x4_t result = vcmla_rot270_f16(a, b, c);
+}
+
+void foo_16x8(float16x8_t a, float16x8_t b, float16x8_t c) {
+ // CHECK: call <8 x half> @llvm.aarch64.neon.vcmla.v8f16
+  float16x8_t result = vcmlaq_f16(a, b, c);
+}
+
+void foo_rot90_16x8(float16x8_t a, float16x8_t b, float16x8_t c) {
+ // CHECK: call <8 x half> @llvm.aarch64.neon.vcmla.rot90.v8f16
+  float16x8_t result = vcmlaq_rot90_f16(a, b, c);
+}
+
+void foo_rot180_16x8(float16x8_t a, float16x8_t b, float16x8_t c) {
+ // CHECK: call <8 x half> @llvm.aarch64.neon.vcmla.rot180.v8f16
+  float16x8_t result = vcmlaq_rot180_f16(a, b, c);
+}
+
+void foo_rot270_16x8(float16x8_t a, float16x8_t b, float16x8_t c) {
+ // CHECK: call <8 x half> @llvm.aarch64.neon.vcmla.rot270.v8f16
+  float16x8_t result = vcmlaq_rot270_f16(a, b, c);
+}
+
+void foo_32x2(float32x2_t a, float32x2_t b, float32x2_t c) {
+ // CHECK: call <2 x float> @llvm.aarch64.neon.vcmla.v2f32
+  float32x2_t result = vcmla_f32(a, b, c);
+}
+
+void foo_rot90_32x2(float32x2_t a, float32x2_t b, float32x2_t c) {
+ // CHECK: call <2 x float> @llvm.aarch64.neon.vcmla.rot90.v2f32
+  float32x2_t result = vcmla_rot90_f32(a, b, c);
+}
+
+void foo_rot180_32x2(float32x2_t a, float32x2_t b, float32x2_t c) {
+ // CHECK: call <2 x float> @llvm.aarch64.neon.vcmla.rot180.v2f32
+  float32x2_t result = vcmla_rot180_f32(a, b, c);
+}
+
+void foo_rot270_32x2(float32x2_t a, float32x2_t b, float32x2_t c) {
+ // CHECK: call <2 x float> @llvm.aarch64.neon.vcmla.rot270.v2f32
+  float32x2_t result = vcmla_rot270_f32(a, b, c);
+}
+
+void foo_32x4(float32x4_t a, float32x4_t b, float32x4_t c) {
+ // CHECK: call <4 x float> @llvm.aarch64.neon.vcmla.v4f32
+  float32x4_t result = vcmlaq_f32(a, b, c);
+}
+
+void foo_rot90_32x4(float32x4_t a, float32x4_t b, float32x4_t c) {
+ // CHECK: call <4 x float> @llvm.aarch64.neon.vcmla.rot90.v4f32
+  float32x4_t result = vcmlaq_rot90_f32(a, b, c);
+}
+
+void foo_rot180_32x4(float32x4_t a, float32x4_t b, float32x4_t c) {
+ // CHECK: call <4 x float> @llvm.aarch64.neon.vcmla.rot180.v4f32
+  float32x4_t result = vcmlaq_rot180_f32(a, b, c);
+}
+
+void foo_rot270_32x4(float32x4_t a, float32x4_t b, float32x4_t c) {
+ // CHECK: call <4 x float> @llvm.aarch64.neon.vcmla.rot270.v4f32
+  float32x4_t result = vcmlaq_rot270_f32(a, b, c);
+}
+
+void foo_64x2(float64x2_t a, float64x2_t b, float64x2_t c) {
+ // CHECK: call <2 x double> @llvm.aarch64.neon.vcmla.v2f64
+  float64x2_t result = vcmlaq_f64(a, b, c);
+}
+
+void foo_rot90_64x2(float64x2_t a, float64x2_t b, float64x2_t c) {
+ // CHECK: call <2 x double> @llvm.aarch64.neon.vcmla.rot90.v2f64
+  float64x2_t result = vcmlaq_rot90_f64(a, b, c);
+}
+
+void foo_rot180_64x2(float64x2_t a, float64x2_t b, float64x2_t c) {
+ // CHECK: call <2 x double> @llvm.aarch64.neon.vcmla.rot180.v2f64
+  float64x2_t result = vcmlaq_rot180_f64(a, b, c);
+}
+
+void foo_rot270_64x2(float64x2_t a, float64x2_t b, float64x2_t c) {
+ // CHECK: call <2 x double> @llvm.aarch64.neon.vcmla.rot270.v2f64
+  float64x2_t result = vcmlaq_rot270_f64(a, b, c);
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ cla

[PATCH] D92930: [Clang] Add vcmla and rotated variants for Arm ACLE.

2020-12-09 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added a comment.

Looks fine to me except for one weird quirk that I don't think should be there.




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:5237
   NEONMAP1(vcaddq_rot90_v, arm_neon_vcadd_rot90, Add1ArgType),
+  NEONMAP1(vcaddq_rot90_v, arm_neon_vcadd_rot90, Add1ArgType),
   NEONMAP1(vcage_v, arm_neon_vacge, 0),

This line looks identical to the one above.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92930/new/

https://reviews.llvm.org/D92930

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92432: [analyzer] Add a thin abstraction layer between libCrossTU and libAnalysis.

2020-12-09 Thread BalƔzs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/include/clang/CrossTU/CrossTranslationUnit.h:124
 /// Note that this class also implements caching.
-class CrossTranslationUnitContext {
+class CrossTranslationUnitContext : public CrossTUAnalysisHelper {
 public:

martong wrote:
> Why don't we have a dependency in libCrossTU to libAnalysis? In the 
> CMakeLists.txt?
> Here we implement the CrossTUAnalysisHelper's abstract virtual function thus 
> we include the `CrossTUAnalysisHelper.h`. But 
> CMake should know about the dependency even if this is only a header only 
> dependency, shouldn't it? (We were talking about this with @steakhal.)
IMO if a library (A) does not depend on another library (B), that means we can 
safely delete all files of the **B** and still be able to compile and run the 
**A**.
In this case, it won't, as the given header lives under **B**. So to make sure 
this principle works, we should state the dependency on **B** in **A**.

---
In our case, it means that **libCrossTU** depends on **libAnalysis**, as the 
`CrossTUAnalysisHelper` lives in `libAnalysis` which is used by `libCrossTU` to 
implement the `CrossTranslationUnitContext`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92432/new/

https://reviews.llvm.org/D92432

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92846: [KernelAddressSanitizer] Fix globals exclusion for indirect aliases

2020-12-09 Thread Marco Elver via Phabricator via cfe-commits
melver updated this revision to Diff 310492.
melver added a comment.

Simplify using stripPointerCastsAndAliases()


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92846/new/

https://reviews.llvm.org/D92846

Files:
  clang/test/CodeGen/asan-globals-alias.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -792,7 +792,7 @@
   StringRef InternalSuffix);
   Instruction *CreateAsanModuleDtor(Module &M);
 
-  bool canInstrumentAliasedGlobal(const GlobalAlias &GA) const;
+  const GlobalVariable *getExcludedAliasedGlobal(const GlobalAlias &GA) const;
   bool shouldInstrumentGlobal(GlobalVariable *G) const;
   bool ShouldUseMachOGlobalsSection() const;
   StringRef getGlobalMetadataSection() const;
@@ -1787,20 +1787,22 @@
   }
 }
 
-bool ModuleAddressSanitizer::canInstrumentAliasedGlobal(
-const GlobalAlias &GA) const {
+const GlobalVariable *
+ModuleAddressSanitizer::getExcludedAliasedGlobal(const GlobalAlias &GA) const {
   // In case this function should be expanded to include rules that do not just
   // apply when CompileKernel is true, either guard all existing rules with an
   // 'if (CompileKernel) { ... }' or be absolutely sure that all these rules
   // should also apply to user space.
   assert(CompileKernel && "Only expecting to be called when compiling kernel");
 
-  // When compiling the kernel, globals that are aliased by symbols prefixed
-  // by "__" are special and cannot be padded with a redzone.
-  if (GA.getName().startswith("__"))
-return false;
+  // When compiling the kernel, globals that are aliased by symbols prefixed by
+  // "__" are special and cannot be padded with a redzone.
+  if (GA.getName().startswith("__")) {
+return dyn_cast(
+GA.getAliasee()->stripPointerCastsAndAliases());
+  }
 
-  return true;
+  return nullptr;
 }
 
 bool ModuleAddressSanitizer::shouldInstrumentGlobal(GlobalVariable *G) const {
@@ -2252,14 +2254,12 @@
   *CtorComdat = false;
 
   // Build set of globals that are aliased by some GA, where
-  // canInstrumentAliasedGlobal(GA) returns false.
+  // getExcludedAliasedGlobal(GA) returns the relevant GlobalVariable.
   SmallPtrSet AliasedGlobalExclusions;
   if (CompileKernel) {
 for (auto &GA : M.aliases()) {
-  if (const auto *GV = dyn_cast(GA.getAliasee())) {
-if (!canInstrumentAliasedGlobal(GA))
-  AliasedGlobalExclusions.insert(GV);
-  }
+  if (const GlobalVariable *GV = getExcludedAliasedGlobal(GA))
+AliasedGlobalExclusions.insert(GV);
 }
   }
 
Index: clang/test/CodeGen/asan-globals-alias.cpp
===
--- clang/test/CodeGen/asan-globals-alias.cpp
+++ clang/test/CodeGen/asan-globals-alias.cpp
@@ -1,17 +1,36 @@
 // RUN: %clang_cc1 -triple x86_64-linux -fsanitize=address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,ASAN
+// RUN: %clang_cc1 -triple x86_64-linux -O2 -fsanitize=address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,ASAN
 // RUN: %clang_cc1 -triple x86_64-linux -fsanitize=kernel-address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,KASAN
+// RUN: %clang_cc1 -triple x86_64-linux -O2 -fsanitize=kernel-address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,KASAN
 //
 // Not all platforms support aliases - test for Linux only.
 
-int global; // to generate ctor for at least 1 global
-int aliased_global; // KASAN - ignore globals prefixed by aliases with __-prefix (below)
-extern int __attribute__((alias("aliased_global"))) __global_alias; // KASAN - aliased_global ignored
+int global; // generate ctor for at least 1 global
+int aliased_global; // KASAN ignored
+extern int __attribute__((alias("aliased_global"))) __global_alias;
+
+// Recursive alias:
+int aliased_global_2; // KASAN ignored
+extern int __attribute__((alias("aliased_global_2"))) global_alias_2;
+extern int __attribute__((alias("global_alias_2"))) __global_alias_2_alias;
+
+// Potential indirect alias:
+struct input_device_id {
+  unsigned long keybit[24];
+  unsigned long driver_info;
+};
+struct input_device_id joydev_ids[] = { { {1}, 1234 } }; // KASAN ignored
+extern struct input_device_id __attribute__((alias("joydev_ids"))) __mod_joydev_ids_device_table;
 
 // ASAN: @aliased_global{{.*}} global { i32, [60 x i8] }{{.*}}, align 32
+// ASAN: @aliased_global_2{{.*}} global { i32, [60 x i8] }{{.*}}, align 32
+// ASAN: @joydev_ids{{.*}} global { {{.*}}[56 x i8] zeroinitializer }, align 32
 // KASAN: @aliased_global{{.*}} global i32
+// KASAN: @aliased_global_2{{.*}} global i32
+//

[PATCH] D92846: [KernelAddressSanitizer] Fix globals exclusion for indirect aliases

2020-12-09 Thread Marco Elver via Phabricator via cfe-commits
melver added a comment.

In D92846#2440118 , @dvyukov wrote:

> Have you checked if there is already a function that does this? Frequently 
> there is :)
> Some functions that look similar based on names:
> stripPointerCasts
> stripPointerCastsAndOffsets
> stripPointerCastsAndAliases
> canonicalizeAlias

Yup, stripPointerCastsAndAliases() works.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92846/new/

https://reviews.llvm.org/D92846

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92846: [KernelAddressSanitizer] Fix globals exclusion for indirect aliases

2020-12-09 Thread Marco Elver via Phabricator via cfe-commits
melver updated this revision to Diff 310494.
melver added a comment.

Style


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92846/new/

https://reviews.llvm.org/D92846

Files:
  clang/test/CodeGen/asan-globals-alias.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -792,7 +792,7 @@
   StringRef InternalSuffix);
   Instruction *CreateAsanModuleDtor(Module &M);
 
-  bool canInstrumentAliasedGlobal(const GlobalAlias &GA) const;
+  const GlobalVariable *getExcludedAliasedGlobal(const GlobalAlias &GA) const;
   bool shouldInstrumentGlobal(GlobalVariable *G) const;
   bool ShouldUseMachOGlobalsSection() const;
   StringRef getGlobalMetadataSection() const;
@@ -1787,20 +1787,22 @@
   }
 }
 
-bool ModuleAddressSanitizer::canInstrumentAliasedGlobal(
-const GlobalAlias &GA) const {
+const GlobalVariable *
+ModuleAddressSanitizer::getExcludedAliasedGlobal(const GlobalAlias &GA) const {
   // In case this function should be expanded to include rules that do not just
   // apply when CompileKernel is true, either guard all existing rules with an
   // 'if (CompileKernel) { ... }' or be absolutely sure that all these rules
   // should also apply to user space.
   assert(CompileKernel && "Only expecting to be called when compiling kernel");
 
-  // When compiling the kernel, globals that are aliased by symbols prefixed
-  // by "__" are special and cannot be padded with a redzone.
+  const Constant *C = GA.getAliasee();
+
+  // When compiling the kernel, globals that are aliased by symbols prefixed by
+  // "__" are special and cannot be padded with a redzone.
   if (GA.getName().startswith("__"))
-return false;
+return dyn_cast(C->stripPointerCastsAndAliases());
 
-  return true;
+  return nullptr;
 }
 
 bool ModuleAddressSanitizer::shouldInstrumentGlobal(GlobalVariable *G) const {
@@ -2252,14 +2254,12 @@
   *CtorComdat = false;
 
   // Build set of globals that are aliased by some GA, where
-  // canInstrumentAliasedGlobal(GA) returns false.
+  // getExcludedAliasedGlobal(GA) returns the relevant GlobalVariable.
   SmallPtrSet AliasedGlobalExclusions;
   if (CompileKernel) {
 for (auto &GA : M.aliases()) {
-  if (const auto *GV = dyn_cast(GA.getAliasee())) {
-if (!canInstrumentAliasedGlobal(GA))
-  AliasedGlobalExclusions.insert(GV);
-  }
+  if (const GlobalVariable *GV = getExcludedAliasedGlobal(GA))
+AliasedGlobalExclusions.insert(GV);
 }
   }
 
Index: clang/test/CodeGen/asan-globals-alias.cpp
===
--- clang/test/CodeGen/asan-globals-alias.cpp
+++ clang/test/CodeGen/asan-globals-alias.cpp
@@ -1,17 +1,36 @@
 // RUN: %clang_cc1 -triple x86_64-linux -fsanitize=address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,ASAN
+// RUN: %clang_cc1 -triple x86_64-linux -O2 -fsanitize=address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,ASAN
 // RUN: %clang_cc1 -triple x86_64-linux -fsanitize=kernel-address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,KASAN
+// RUN: %clang_cc1 -triple x86_64-linux -O2 -fsanitize=kernel-address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,KASAN
 //
 // Not all platforms support aliases - test for Linux only.
 
-int global; // to generate ctor for at least 1 global
-int aliased_global; // KASAN - ignore globals prefixed by aliases with __-prefix (below)
-extern int __attribute__((alias("aliased_global"))) __global_alias; // KASAN - aliased_global ignored
+int global; // generate ctor for at least 1 global
+int aliased_global; // KASAN ignored
+extern int __attribute__((alias("aliased_global"))) __global_alias;
+
+// Recursive alias:
+int aliased_global_2; // KASAN ignored
+extern int __attribute__((alias("aliased_global_2"))) global_alias_2;
+extern int __attribute__((alias("global_alias_2"))) __global_alias_2_alias;
+
+// Potential indirect alias:
+struct input_device_id {
+  unsigned long keybit[24];
+  unsigned long driver_info;
+};
+struct input_device_id joydev_ids[] = { { {1}, 1234 } }; // KASAN ignored
+extern struct input_device_id __attribute__((alias("joydev_ids"))) __mod_joydev_ids_device_table;
 
 // ASAN: @aliased_global{{.*}} global { i32, [60 x i8] }{{.*}}, align 32
+// ASAN: @aliased_global_2{{.*}} global { i32, [60 x i8] }{{.*}}, align 32
+// ASAN: @joydev_ids{{.*}} global { {{.*}}[56 x i8] zeroinitializer }, align 32
 // KASAN: @aliased_global{{.*}} global i32
+// KASAN: @aliased_global_2{{.*}} global i32
+// KASAN: @joydev_ids{{.*}} global [1 x {{.*}}i64 1234 }], align 16

[PATCH] D92846: [KernelAddressSanitizer] Fix globals exclusion for indirect aliases

2020-12-09 Thread Marco Elver via Phabricator via cfe-commits
melver updated this revision to Diff 310495.
melver added a comment.

Revert unnecessary reformat


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92846/new/

https://reviews.llvm.org/D92846

Files:
  clang/test/CodeGen/asan-globals-alias.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -792,7 +792,7 @@
   StringRef InternalSuffix);
   Instruction *CreateAsanModuleDtor(Module &M);
 
-  bool canInstrumentAliasedGlobal(const GlobalAlias &GA) const;
+  const GlobalVariable *getExcludedAliasedGlobal(const GlobalAlias &GA) const;
   bool shouldInstrumentGlobal(GlobalVariable *G) const;
   bool ShouldUseMachOGlobalsSection() const;
   StringRef getGlobalMetadataSection() const;
@@ -1787,20 +1787,22 @@
   }
 }
 
-bool ModuleAddressSanitizer::canInstrumentAliasedGlobal(
-const GlobalAlias &GA) const {
+const GlobalVariable *
+ModuleAddressSanitizer::getExcludedAliasedGlobal(const GlobalAlias &GA) const {
   // In case this function should be expanded to include rules that do not just
   // apply when CompileKernel is true, either guard all existing rules with an
   // 'if (CompileKernel) { ... }' or be absolutely sure that all these rules
   // should also apply to user space.
   assert(CompileKernel && "Only expecting to be called when compiling kernel");
 
+  const Constant *C = GA.getAliasee();
+
   // When compiling the kernel, globals that are aliased by symbols prefixed
   // by "__" are special and cannot be padded with a redzone.
   if (GA.getName().startswith("__"))
-return false;
+return dyn_cast(C->stripPointerCastsAndAliases());
 
-  return true;
+  return nullptr;
 }
 
 bool ModuleAddressSanitizer::shouldInstrumentGlobal(GlobalVariable *G) const {
@@ -2252,14 +2254,12 @@
   *CtorComdat = false;
 
   // Build set of globals that are aliased by some GA, where
-  // canInstrumentAliasedGlobal(GA) returns false.
+  // getExcludedAliasedGlobal(GA) returns the relevant GlobalVariable.
   SmallPtrSet AliasedGlobalExclusions;
   if (CompileKernel) {
 for (auto &GA : M.aliases()) {
-  if (const auto *GV = dyn_cast(GA.getAliasee())) {
-if (!canInstrumentAliasedGlobal(GA))
-  AliasedGlobalExclusions.insert(GV);
-  }
+  if (const GlobalVariable *GV = getExcludedAliasedGlobal(GA))
+AliasedGlobalExclusions.insert(GV);
 }
   }
 
Index: clang/test/CodeGen/asan-globals-alias.cpp
===
--- clang/test/CodeGen/asan-globals-alias.cpp
+++ clang/test/CodeGen/asan-globals-alias.cpp
@@ -1,17 +1,36 @@
 // RUN: %clang_cc1 -triple x86_64-linux -fsanitize=address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,ASAN
+// RUN: %clang_cc1 -triple x86_64-linux -O2 -fsanitize=address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,ASAN
 // RUN: %clang_cc1 -triple x86_64-linux -fsanitize=kernel-address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,KASAN
+// RUN: %clang_cc1 -triple x86_64-linux -O2 -fsanitize=kernel-address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,KASAN
 //
 // Not all platforms support aliases - test for Linux only.
 
-int global; // to generate ctor for at least 1 global
-int aliased_global; // KASAN - ignore globals prefixed by aliases with __-prefix (below)
-extern int __attribute__((alias("aliased_global"))) __global_alias; // KASAN - aliased_global ignored
+int global; // generate ctor for at least 1 global
+int aliased_global; // KASAN ignored
+extern int __attribute__((alias("aliased_global"))) __global_alias;
+
+// Recursive alias:
+int aliased_global_2; // KASAN ignored
+extern int __attribute__((alias("aliased_global_2"))) global_alias_2;
+extern int __attribute__((alias("global_alias_2"))) __global_alias_2_alias;
+
+// Potential indirect alias:
+struct input_device_id {
+  unsigned long keybit[24];
+  unsigned long driver_info;
+};
+struct input_device_id joydev_ids[] = { { {1}, 1234 } }; // KASAN ignored
+extern struct input_device_id __attribute__((alias("joydev_ids"))) __mod_joydev_ids_device_table;
 
 // ASAN: @aliased_global{{.*}} global { i32, [60 x i8] }{{.*}}, align 32
+// ASAN: @aliased_global_2{{.*}} global { i32, [60 x i8] }{{.*}}, align 32
+// ASAN: @joydev_ids{{.*}} global { {{.*}}[56 x i8] zeroinitializer }, align 32
 // KASAN: @aliased_global{{.*}} global i32
+// KASAN: @aliased_global_2{{.*}} global i32
+// KASAN: @joydev_ids{{.*}} global [1 x {{.*}}i64 1234 }], align 16
 
 // CHECK-LABEL: define internal void @asan.module_ctor
-// ASAN: call void @__asan_register_globals({{.*}}, i{{32|64

[PATCH] D92846: [KernelAddressSanitizer] Fix globals exclusion for indirect aliases

2020-12-09 Thread Dmitry Vyukov via Phabricator via cfe-commits
dvyukov accepted this revision.
dvyukov added a comment.
This revision is now accepted and ready to land.

The code looks reasonable to me. I see it only affects kernel, so assuming you 
booted kernel, we should be fine.
I can rubber-stamp it, but if you want more meaningful review, please wait for 
Alex or Nick.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92846/new/

https://reviews.llvm.org/D92846

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92922: [clang-format] PR42434 Remove preprocessor and pragma lines from ObjectiveC guess

2020-12-09 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/lib/Format/Format.cpp:2037
+if (Line->First->TokenText.startswith("#") ||
+Line->First->TokenText == "__pragma") {
+  continue;

Maybe you should also handle MS-specific `_Pragma`?
https://docs.microsoft.com/en-us/cpp/preprocessor/pragma-directives-and-the-pragma-keyword?view=msvc-160


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92922/new/

https://reviews.llvm.org/D92922

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92935: Introduce support for PowerPC devices with an Embedded Floating-point APU version 2 (efpu2)

2020-12-09 Thread Michael Kiausch via Phabricator via cfe-commits
kiausch created this revision.
kiausch added reviewers: nemanjai, jhibbits.
Herald added subscribers: dang, steven.zhang, shchenz, kbarton, hiraditya.
kiausch requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

PowerPC cores like e200z759n3 [1] using an efpu2 only support single precision 
hardware floating point instructions.
The single precision instructions efs* and evfs* are identical to the spe float 
instructions while efd* and evfd* instructions trigger a not implemented 
exception.

This patch introduces a new command line option -mefpu2 which leads to 
single-hardware / double-software code generation.

I added a regression test efpu2.ll based on spe.ll where all single tests are 
identical to the tests in spe.ll while the double tests taken from spe.ll were 
modified to basically check that the correct library calls are generated.

[1] Core reference: 
https://www.nxp.com/files-static/32bit/doc/ref_manual/e200z759CRM.pdf


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92935

Files:
  clang/include/clang/Driver/Options.td
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/lib/Target/PowerPC/PPCSubtarget.h
  llvm/test/CodeGen/PowerPC/efpu2.ll

Index: llvm/test/CodeGen/PowerPC/efpu2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/efpu2.ll
@@ -0,0 +1,1141 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc-unknown-linux-gnu \
+; RUN:  -mattr=+efpu2 |  FileCheck %s
+
+; Single tests 
+; identical to tests in spe.ll
+
+declare float @llvm.fabs.float(float)
+define float @test_float_abs(float %a) #0 {
+; CHECK-LABEL: test_float_abs:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:efsabs 3, 3
+; CHECK-NEXT:blr
+  entry:
+%0 = tail call float @llvm.fabs.float(float %a)
+ret float %0
+}
+
+define float @test_fnabs(float %a) #0 {
+; CHECK-LABEL: test_fnabs:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:efsnabs 3, 3
+; CHECK-NEXT:blr
+  entry:
+%0 = tail call float @llvm.fabs.float(float %a)
+%sub = fsub float -0.00e+00, %0
+ret float %sub
+}
+
+define float @test_fdiv(float %a, float %b) {
+; CHECK-LABEL: test_fdiv:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:efsdiv 3, 3, 4
+; CHECK-NEXT:blr
+entry:
+  %v = fdiv float %a, %b
+  ret float %v
+
+}
+
+define float @test_fmul(float %a, float %b) {
+; CHECK-LABEL: test_fmul:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:efsmul 3, 3, 4
+; CHECK-NEXT:blr
+  entry:
+  %v = fmul float %a, %b
+  ret float %v
+}
+
+define float @test_fadd(float %a, float %b) {
+; CHECK-LABEL: test_fadd:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:efsadd 3, 3, 4
+; CHECK-NEXT:blr
+  entry:
+  %v = fadd float %a, %b
+  ret float %v
+}
+
+define float @test_fsub(float %a, float %b) {
+; CHECK-LABEL: test_fsub:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:efssub 3, 3, 4
+; CHECK-NEXT:blr
+  entry:
+  %v = fsub float %a, %b
+  ret float %v
+}
+
+define float @test_fneg(float %a) {
+; CHECK-LABEL: test_fneg:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:efsneg 3, 3
+; CHECK-NEXT:blr
+  entry:
+  %v = fsub float -0.0, %a
+  ret float %v
+}
+
+; todo
+define float @test_dtos(double %a) {
+; CHECK-LABEL: test_dtos:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mflr 0
+; CHECK-NEXT:stw 0, 4(1)
+; CHECK-NEXT:stwu 1, -16(1)
+; CHECK-NEXT:.cfi_def_cfa_offset 16
+; CHECK-NEXT:.cfi_offset lr, 4
+; CHECK-NEXT:bl __truncdfsf2
+; CHECK-NEXT:lwz 0, 20(1)
+; CHECK-NEXT:addi 1, 1, 16
+; CHECK-NEXT:mtlr 0
+; CHECK-NEXT:blr
+  entry:
+  %v = fptrunc double %a to float
+  ret float %v
+}
+
+define i32 @test_fcmpgt(float %a, float %b) {
+; CHECK-LABEL: test_fcmpgt:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stwu 1, -16(1)
+; CHECK-NEXT:.cfi_def_cfa_offset 16
+; CHECK-NEXT:efscmpgt 0, 3, 4
+; CHECK-NEXT:ble 0, .LBB8_2
+; CHECK-NEXT:  # %bb.1: # %tr
+; CHECK-NEXT:li 3, 1
+; CHECK-NEXT:b .LBB8_3
+; CHECK-NEXT:  .LBB8_2: # %fa
+; CHECK-NEXT:li 3, 0
+; CHECK-NEXT:  .LBB8_3: # %ret
+; CHECK-NEXT:stw 3, 12(1)
+; CHECK-NEXT:lwz 3, 12(1)
+; CHECK-NEXT:addi 1, 1, 16
+; CHECK-NEXT:blr
+  entry:
+  %r = alloca i32, align 4
+  %c = fcmp ogt float %a, %b
+  br i1 %c, label %tr, label %fa
+tr:
+  store i32 1, i32* %r, align 4
+  br label %ret
+fa:
+  store i32 0, i32* %r, align 4
+  br label %ret
+ret:
+  %0 = load i32, i32* %r, align 4
+  ret i32 %0
+}
+
+define i32 @test_fcmpugt(float %a, float %b) {
+; CHECK-LABEL: test_fcmpugt:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stwu 1, -16(1)
+; CHECK-NEXT:.cfi_def_cfa_offset 16
+; CHECK-NEXT:efscmpeq 0, 4, 4
+; CHECK-NEXT:bc 4, 1, .LBB9_4
+; CHEC

[PATCH] D92298: [AST][RecoveryAST] Preserve type for member call expr if argments are not matched.

2020-12-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Some case errors on the allowRecovery variable name throughout.




Comment at: clang/include/clang/Sema/Sema.h:3730
+   SourceLocation RParenLoc,
+   bool allowRecovery = false);
   ExprResult

nit: AllowRecovery (case)



Comment at: clang/include/clang/Sema/Sema.h:5242
+   bool IsExecConfig = false,
+   bool allowRecovery = false);
   enum class AtomicArgumentOrder { API, AST };

(and here)



Comment at: clang/lib/Sema/SemaExpr.cpp:6312
+  ExprResult Call = BuildCallExpr(Scope, Fn, LParenLoc, ArgExprs, RParenLoc,
+  ExecConfig, false, true);
   if (Call.isInvalid())

/*IsExecConfig=*/false, /*AllowRecovery=*/true



Comment at: clang/lib/Sema/SemaOverload.cpp:14218
 
+  auto BuildRecoveryExpr = [&](QualType Type) {
+if (!allowRecovery)

This would be a good place to add a comment
// We only try to build a recovery expr at this level if we can preserve the 
return type, otherwise we return ExprError() and let the caller recover.



Comment at: clang/test/AST/ast-dump-recovery.cpp:45
 
+class ForwardClass;
+ForwardClass createFwd();

Is this a leftover?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92298/new/

https://reviews.llvm.org/D92298

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92298: [AST][RecoveryAST] Preserve type for member call expr if argments are not matched.

2020-12-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

(It seems like there are probably other callsites to these functions that could 
be updated to pass AllowRecovery=true. If so, those can easily be separate 
patches of course)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92298/new/

https://reviews.llvm.org/D92298

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92198: [clangd] Log remote index connectivity status

2020-12-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/Client.cpp:114
 assert(!ProjectRoot.empty());
+ChannelStatusWatcher = std::thread([&Channel]() {
+  grpc_connectivity_state Status =

kbobyrev wrote:
> sammccall wrote:
> > The thread is a bit surprising here. I was assuming we'd use some 
> > callback-based API to watch rather than spawn a thread to do the "work" of 
> > blocking on a change.
> > Also this is going to "wake up" periodically to refresh the watch, which 
> > seems undesirable if we want to go truly idle.
> > 
> > Ah, so there's no callback-type connection-changed API! Sorry to mislead 
> > you :-( I hadn't read the API carefully. (I think this is coming as some 
> > point - they're talking about replacing CompletionQueue with EventManager 
> > which is a callback-based abstraction)
> > 
> > Seems the "async" option is to subscribe on a CompletionQueue, but then we 
> > have to poll it. We can use a zero timeout so the poll doesn't block... But 
> > then we might as well poll GetStatus directly.
> > 
> > Then the question is where to do that from. What if we called GetStatus 
> > before/after each request, and reported whenever it has changed? That means:
> > 
> > - no idle background work
> > - we know the connection state for each request
> > - we know when a request triggered a connection, and whether that 
> > connection succeeded in time for the request
> > - if a connection goes idle, we don't know *when*, it gets reported on the 
> > next request
> ("resolved" in this version)
> 
> I can understand your point and I support the arguments but this would mean 
> that we only get status during requests and can't query it at arbitrary time 
> which seems like a loss. Maybe it's OK because there might not be many 
> interesting cases when we want to query the server status but not do any 
> requests and your proposal makes it easier to implement & maintain. But also 
> maybe it could be nice to have some kind of callback on status change.
> 
> As you mentioned, I was looking for something like this in gRPC itself but 
> couldn't find it there outside the CompletionQueue and EvenManager things. 
> Sadly, I don't think we'd be in a position to use the replacement even when 
> it's there since we have to support older gRPC versions :(
> 
> When I see the logs and the server connectivity updates are following the 
> requests, it looks OK but I'm not entirely sure giving up on _watching_ the 
> status is great. But it still makes life easier so maybe this change should 
> be about it.
I agree, it's absolutely a loss vs watching the state continuously.
But I think simplicity needs to win out here. Imagine if we have trouble 
coordinating shutdown in certain configurations because the thread gets blocked 
(grpc bug?)... this would not be much fun to debug.

In principle we could #ifdef based on GRPC version in the future, in practice 
you're probably right that we just suffer without this :-(



Comment at: clang-tools-extra/clangd/index/remote/Client.cpp:124
+  Status = Channel->GetState(/*try_to_connect=*/true);
+  log("Remote index connection status changed: {0}", Status);
+}

kbobyrev wrote:
> sammccall wrote:
> > Can we include the remote address and prior status?
> > 
> > e.g. `"Remote index ({0}): {1} => {2}"`
> I can see how it'd be nice but I'm not sure how to do this properly. My only 
> idea is to query prior status in the beginning of the request? Otherwise it 
> needs to be stored somewhere and gRPC interfaces require `const` functions, 
> so `IndexClient` does not change the state within requests. I could either 
> wrap it into something or have global `grpc_connnectivity_state` for the last 
> observed status but neither look OK. Maybe querying the prior status right 
> before the request is OK (that's what I've done here) but I'm not sure if 
> that's exactly what you suggested.
TL;DR: `mutable atomic`

Using a `mutable` member is the usual solution to "I want to be stateful but 
have to adhere to a `const` interface.
We usually have some philosophical debate about whether the function is still 
"conceptually const" but it certainly is here as the state in question is only 
affecting logging.

With `mutable` you usually have to add a mutex to provide the usual 
thread-safety guarantees (const = threadsafe). However in this case we just 
want to detect transitions, and atomics are great at this:

```
auto NewStatus = getStatus();
auto OldStatus = last_status_.exchange(NewStatus);
if (NewStatus != OldStatus)
  log(...);
```

This is guaranteed to log each time last_status_ changes value. (I think this 
will correspond closely enough to actual status changes, though calling using a 
mutex and calling getStatus() under the mutex would be a little more accurate)

Note that there's no difference between what you want to do before vs after an 
RPC - both a

[PATCH] D92198: [clangd] Log remote index connectivity status

2020-12-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/Client.cpp:91
 SPAN_ATTACH(Tracer, "Failed to parse", FailedToParse);
+vlog("Remote index ({0}): {1} -> {2}", ServerAddress, toString(OldStatus),
+ toString(Channel->GetState(/*try_to_connect=*/false)));

we might want to put the server address at the end in [], mirroring D92181


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92198/new/

https://reviews.llvm.org/D92198

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2020-12-09 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

In D89909#2439837 , @Anastasia wrote:

> In D89909#2423750 , @bader wrote:
>
>>> It was mentioned that the changes in the type system with address spaces is 
>>> undesirable for SYCL because you indend to parse existing C++ code as-is. 
>>> This contradicts the intended semantic of address spaces where the whole 
>>> point of it is to modify the standard types and therefore a compilation of 
>>> C++ with the standard semantic is only guaranteed when the attribute is not 
>>> used at all.
>>
>> Right, but I don't think it's related to the address space attributes. It 
>> was mentioned in the context of re-using OpenCL *mode* for SYCL device 
>> compilation, which modifies types which does use address space attribute 
>> explicitly. "Existing C++ code" doesn't use address space attributes and our 
>> solution does differentiate explicitly annotated type. The difference with 
>> OpenCL mode is that SYCL doesn't change types by modifying "default" address 
>> space attribute and allows conversion from/to "default" address space. As I 
>> mentioned in RFC, according to my understanding this patch doesn't 
>> contradict Embedded C requirements regarding address space attribute usage. 
>> I think the spec allows an implementation to define conversion rules between 
>> address spaces and doesn't imply type change based on the declaration scope 
>> - it's OpenCL specific behavior.
>
> Ok, if you plan to follow the Embedded C semantic (which your current patch 
> confirms) then you should just reuse the existing target address spaces and 
> extend the implementation with the ability to specify the relation among 
> address spaces. The patch that you have mentioned earlier 
> https://reviews.llvm.org/D62574 is providing this logic already and it looks 
> good aside from testing. I would suggest to discuss with @ebevhan the 
> timeline for committing it as the testing could be done using SYCL 
> implementation. Alternatively, you could consider reusing the relevant parts 
> of the patch if @ebevhan has no objections to that.

Let me check that I understand your proposal correctly.
Do suggest that we use `__attribute__((address_space(N)))` attribute and define 
the relation between the set of these? Unfortunately I won't work because SYCL 
supports multiple targets and we need to use address space maps to correctly 
map attributes in LLVM IR. Targets might use different different llvm address 
spaces numbers for memory accessible within a work-item. If I understand it 
correctly, `__attribute__((address_space(N)))` will be mapped to `addrspace(N)` 
in LLVM and this mapping can't be customized for different targets. Right?

I actually proposed a bit different approach in RFC. 
https://reviews.llvm.org/D62574 "moves QualType/Qualifiers accessors which deal 
with qualifier relations (such as compatiblyIncludes, etc.) to ASTContext, as 
Qualifiers cannot be made aware of the relations between address spaces on 
their own". It allows customization based on the language mode as well, so my 
suggestion was to set "default" address space as a superset for opencl_global, 
opencl_local and opencl_private in SYCL mode. Using this approach we re-use 
existing attributes and don't impact other language modes. Does it make sense 
to you?




Comment at: clang/lib/Basic/Targets.cpp:577
-  case llvm::Triple::spir: {
-if (Triple.getOS() != llvm::Triple::UnknownOS ||
-Triple.getEnvironment() != llvm::Triple::UnknownEnvironment)

Anastasia wrote:
> We should not allow any arbitrary OS/Environment for SPIR.
@Anastasia, could you elaborate on that, please? Why can't we allow arbitrary 
values for these triple components?

The only reason I'm aware of is that LLVM-SPIRV-Translator was checking OS 
triple component and rejected LLVM module if value was not "unknow". Today it 
checks only "architecture' component and accepts only "spir" architecture. I 
personally think that even this restriction is artificial and LLVM module 
shouldn't be rejected based on the triple values, but it's a separate 
discussion.

I use additional environment component to choose between address space maps. We 
could update default address space in SPIRAddrSpaceMap directly, but IIRC, it 
caused some issues for OpenCL C++ mode, which uses Default address space 
instead of `opencl_private` in some cases.

Do you know if there is a better way to communicate the difference in Default 
address space to SPIRTargetInfo object?



Comment at: clang/lib/Basic/Targets/SPIR.h:71
 LongWidth = LongAlign = 64;
-AddrSpaceMap = &SPIRAddrSpaceMap;
+if (Triple.getEnvironment() == llvm::Triple::SYCLDevice) {
+  AddrSpaceMap = &SYCLAddrSpaceMap;

Anastasia wrote:
> This deserves clarification - address space map reflect the physical address 
> space of the target - how will upstream users 

[PATCH] D92852: [NFC] Reduce include files dependency and AA header cleanup (part 2).

2020-12-09 Thread Daniil Fukalov via Phabricator via cfe-commits
dfukalov updated this revision to Diff 310506.
dfukalov added a comment.

Splitting change as requested.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92852/new/

https://reviews.llvm.org/D92852

Files:
  llvm/include/llvm/Analysis/AliasAnalysis.h
  llvm/lib/Analysis/AliasAnalysis.cpp
  llvm/lib/Analysis/CaptureTracking.cpp

Index: llvm/lib/Analysis/CaptureTracking.cpp
===
--- llvm/lib/Analysis/CaptureTracking.cpp
+++ llvm/lib/Analysis/CaptureTracking.cpp
@@ -413,8 +413,8 @@
 }
 
 bool llvm::isNonEscapingLocalObject(
-const Value *V, AAQueryInfo::IsCapturedCacheT *IsCapturedCache) {
-  AAQueryInfo::IsCapturedCacheT::iterator CacheIt;
+const Value *V, SmallDenseMap *IsCapturedCache) {
+  SmallDenseMap::iterator CacheIt;
   if (IsCapturedCache) {
 bool Inserted;
 std::tie(CacheIt, Inserted) = IsCapturedCache->insert({V, false});
Index: llvm/lib/Analysis/AliasAnalysis.cpp
===
--- llvm/lib/Analysis/AliasAnalysis.cpp
+++ llvm/lib/Analysis/AliasAnalysis.cpp
@@ -166,13 +166,12 @@
   return Result;
 }
 
-ModRefInfo AAResults::getModRefInfo(const Instruction *I,
-const CallBase *Call2) {
+ModRefInfo AAResults::getModRefInfo(Instruction *I, const CallBase *Call2) {
   AAQueryInfo AAQIP;
   return getModRefInfo(I, Call2, AAQIP);
 }
 
-ModRefInfo AAResults::getModRefInfo(const Instruction *I, const CallBase *Call2,
+ModRefInfo AAResults::getModRefInfo(Instruction *I, const CallBase *Call2,
 AAQueryInfo &AAQI) {
   // We may have two calls.
   if (const auto *Call1 = dyn_cast(I)) {
@@ -648,6 +647,43 @@
   return ModRefInfo::ModRef;
 }
 
+ModRefInfo AAResults::getModRefInfo(const Instruction *I,
+const Optional &OptLoc,
+AAQueryInfo &AAQIP) {
+  if (OptLoc == None) {
+if (const auto *Call = dyn_cast(I)) {
+  return createModRefInfo(getModRefBehavior(Call));
+}
+  }
+
+  const MemoryLocation &Loc = OptLoc.getValueOr(MemoryLocation());
+
+  switch (I->getOpcode()) {
+  case Instruction::VAArg:
+return getModRefInfo((const VAArgInst *)I, Loc, AAQIP);
+  case Instruction::Load:
+return getModRefInfo((const LoadInst *)I, Loc, AAQIP);
+  case Instruction::Store:
+return getModRefInfo((const StoreInst *)I, Loc, AAQIP);
+  case Instruction::Fence:
+return getModRefInfo((const FenceInst *)I, Loc, AAQIP);
+  case Instruction::AtomicCmpXchg:
+return getModRefInfo((const AtomicCmpXchgInst *)I, Loc, AAQIP);
+  case Instruction::AtomicRMW:
+return getModRefInfo((const AtomicRMWInst *)I, Loc, AAQIP);
+  case Instruction::Call:
+return getModRefInfo((const CallInst *)I, Loc, AAQIP);
+  case Instruction::Invoke:
+return getModRefInfo((const InvokeInst *)I, Loc, AAQIP);
+  case Instruction::CatchPad:
+return getModRefInfo((const CatchPadInst *)I, Loc, AAQIP);
+  case Instruction::CatchRet:
+return getModRefInfo((const CatchReturnInst *)I, Loc, AAQIP);
+  default:
+return ModRefInfo::NoModRef;
+  }
+}
+
 /// Return information about whether a particular call site modifies
 /// or reads the specified memory location \p MemLoc before instruction \p I
 /// in a BasicBlock.
@@ -657,7 +693,7 @@
 /// with a smarter AA in place, this test is just wasting compile time.
 ModRefInfo AAResults::callCapturesBefore(const Instruction *I,
  const MemoryLocation &MemLoc,
- const DominatorTree *DT) {
+ DominatorTree *DT) {
   if (!DT)
 return ModRefInfo::ModRef;
 
Index: llvm/include/llvm/Analysis/AliasAnalysis.h
===
--- llvm/include/llvm/Analysis/AliasAnalysis.h
+++ llvm/include/llvm/Analysis/AliasAnalysis.h
@@ -62,8 +62,8 @@
 class Function;
 class InvokeInst;
 class PreservedAnalyses;
-class Value;
 class TargetLibraryInfo;
+class Value;
 
 /// The possible results of an alias query.
 ///
@@ -691,7 +691,7 @@
 
   /// Return information about whether a call and an instruction may refer to
   /// the same memory locations.
-  ModRefInfo getModRefInfo(const Instruction *I, const CallBase *Call);
+  ModRefInfo getModRefInfo(Instruction *I, const CallBase *Call);
 
   /// Return information about whether two call sites may refer to the same set
   /// of memory locations. See the AA documentation for details:
@@ -704,12 +704,11 @@
   /// Early exits in callCapturesBefore may lead to ModRefInfo::Must not being
   /// set.
   ModRefInfo callCapturesBefore(const Instruction *I,
-const MemoryLocation &MemLoc,
-const DominatorTree *DT);
+const MemoryLocation &MemLoc, DominatorTree *DT);
 
   /// A 

[PATCH] D92852: [NFC] Reduce include files dependency and AA header cleanup (part 2).

2020-12-09 Thread Daniil Fukalov via Phabricator via cfe-commits
dfukalov updated this revision to Diff 310509.
dfukalov edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92852/new/

https://reviews.llvm.org/D92852

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/examples/Bye/Bye.cpp
  llvm/include/llvm/Analysis/AliasAnalysis.h
  llvm/include/llvm/Analysis/BasicAliasAnalysis.h
  llvm/include/llvm/Analysis/MemorySSA.h
  llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
  llvm/lib/Analysis/AliasAnalysis.cpp
  llvm/lib/Analysis/MemDepPrinter.cpp
  llvm/lib/Analysis/ScopedNoAliasAA.cpp
  llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
  llvm/lib/CodeGen/LiveIntervals.cpp
  llvm/lib/LTO/Caching.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
  llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
  llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
  llvm/lib/Transforms/IPO/FunctionAttrs.cpp
  llvm/lib/Transforms/IPO/HotColdSplitting.cpp
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/ObjCARC/ProvenanceAnalysisEvaluator.cpp
  llvm/lib/Transforms/Scalar/FlattenCFGPass.cpp
  llvm/lib/Transforms/Scalar/Float2Int.cpp
  llvm/lib/Transforms/Scalar/LoopDistribute.cpp
  llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
  llvm/lib/Transforms/Scalar/LoopPassManager.cpp
  llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
  llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
  llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
  llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
  llvm/lib/Transforms/Utils/LoopVersioning.cpp
  llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -16,6 +16,7 @@
 #include "PassPrinters.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/CGSCCPassManager.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Bitcode/BitcodeWriterPass.h"
Index: llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
===
--- llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
+++ llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
 #include "llvm/CodeGen/CommandFlags.h"
@@ -18,6 +19,7 @@
 #include "llvm/IR/Verifier.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Passes/PassBuilder.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
Index: llvm/lib/Transforms/Utils/LoopVersioning.cpp
===
--- llvm/lib/Transforms/Utils/LoopVersioning.cpp
+++ llvm/lib/Transforms/Utils/LoopVersioning.cpp
@@ -14,7 +14,6 @@
 
 #include "llvm/Transforms/Utils/LoopVersioning.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/LoopAccessAnalysis.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/MemorySSA.h"
Index: llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
===
--- llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
+++ llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
@@ -22,7 +22,6 @@
 
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/Statistic.h"
-#include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/LoopIterator.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/IR/BasicBlock.h"
Index: llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
===
--- llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
+++ llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
@@ -12,7 +12,6 @@
 
 #include "llvm/Transforms/Utils/LoopRotationUtils.h"
 #include "llvm/ADT/Statistic.h"
-#include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/AssumptionCache.h"
 #include "llvm/Analysis/BasicAliasAnalysis.h"
 #include "llvm/Analysis/CodeMetrics.h"
Index: llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
===
--- llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -27,16 +27,17 @@
 #include "llvm/Analysis/MemorySSA.h"
 #include "llvm/Analysis/MemorySSAUpdater.h"
 #include "llvm/Analysis/MustExecute.h"
+#include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Constant.h"
 #include "llvm/IR/

[PATCH] D92209: [ASTImporter] Support CXXDeductionGuideDecl with local typedef

2020-12-09 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 310510.
martong added a comment.

- Remove `if (!DC || !LexicalDC)`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92209/new/

https://reviews.llvm.org/D92209

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5925,6 +5925,22 @@
   EXPECT_TRUE(ToD->isExplicit());
 }
 
+TEST_P(ImportFunctions, CTADWithLocalTypedef) {
+  Decl *TU = getTuDecl(
+  R"(
+  template  struct A {
+typedef T U;
+A(U, T);
+  };
+  A a{(int)0, (int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  auto *FromD = FirstDeclMatcher().match(
+  TU, cxxDeductionGuideDecl());
+  auto *ToD = Import(FromD, Lang_CXX17);
+  ASSERT_TRUE(ToD);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -385,6 +385,8 @@
 ExpectedType VisitObjCObjectPointerType(const ObjCObjectPointerType *T);
 
 // Importing declarations
+Error ImportDeclParts(NamedDecl *D, DeclarationName &Name, NamedDecl *&ToD,
+  SourceLocation &Loc);
 Error ImportDeclParts(
 NamedDecl *D, DeclContext *&DC, DeclContext *&LexicalDC,
 DeclarationName &Name, NamedDecl *&ToD, SourceLocation &Loc);
@@ -1644,6 +1646,25 @@
   return Error::success();
 }
 
+Error ASTNodeImporter::ImportDeclParts(NamedDecl *D, DeclarationName &Name,
+   NamedDecl *&ToD, SourceLocation &Loc) {
+
+  // Import the name of this declaration.
+  if (Error Err = importInto(Name, D->getDeclName()))
+return Err;
+
+  // Import the location of this declaration.
+  if (Error Err = importInto(Loc, D->getLocation()))
+return Err;
+
+  ToD = cast_or_null(Importer.GetAlreadyImportedOrNull(D));
+  if (ToD)
+if (Error Err = ASTNodeImporter(*this).ImportDefinitionIfNeeded(D, ToD))
+  return Err;
+
+  return Error::success();
+}
+
 Error ASTNodeImporter::ImportDefinitionIfNeeded(Decl *FromD, Decl *ToD) {
   if (!FromD)
 return Error::success();
@@ -2412,22 +2433,29 @@
 ExpectedDecl
 ASTNodeImporter::VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias) {
   // Import the major distinguishing characteristics of this typedef.
-  DeclContext *DC, *LexicalDC;
   DeclarationName Name;
   SourceLocation Loc;
   NamedDecl *ToD;
-  if (Error Err = ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
+  // Do not import the DeclContext, we will import it once the TypedefNameDecl
+  // is created.
+  if (Error Err = ImportDeclParts(D, Name, ToD, Loc))
 return std::move(Err);
   if (ToD)
 return ToD;
 
+  DeclContext *DC = cast_or_null(
+  Importer.GetAlreadyImportedOrNull(cast(D->getDeclContext(;
+  DeclContext *LexicalDC =
+  cast_or_null(Importer.GetAlreadyImportedOrNull(
+  cast(D->getLexicalDeclContext(;
+
   // If this typedef is not in block scope, determine whether we've
   // seen a typedef with the same name (that we can merge with) or any
   // other entity by that name (which name lookup could conflict with).
   // Note: Repeated typedefs are not valid in C99:
   // 'typedef int T; typedef int T;' is invalid
   // We do not care about this now.
-  if (!DC->isFunctionOrMethod()) {
+  if (DC && !DC->isFunctionOrMethod()) {
 SmallVector ConflictingDecls;
 unsigned IDNS = Decl::IDNS_Ordinary;
 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
@@ -2484,8 +2512,15 @@
   Name.getAsIdentifierInfo(), ToTypeSourceInfo))
 return ToTypedef;
 
-  ToTypedef->setAccess(D->getAccess());
+  // Import the DeclContext and set it to the Typedef.
+  if ((Err = ImportDeclContext(D, DC, LexicalDC)))
+return std::move(Err);
+  ToTypedef->setDeclContext(DC);
   ToTypedef->setLexicalDeclContext(LexicalDC);
+  // Add to the lookupTable because we could not do that in MapImported.
+  Importer.AddToLookupTable(ToTypedef);
+
+  ToTypedef->setAccess(D->getAccess());
 
   // Templated declarations should not appear in DeclContext.
   TypeAliasDecl *FromAlias = IsAlias ? cast(D) : nullptr;
@@ -9189,7 +9224,11 @@
   // This mapping should be maintained only in this function. Therefore do not
   // check for additional consistency.
   ImportedFromDecls[To] = From;
-  AddToLookupTable(To);
+  // In the case of TypedefNameDecl we create the Decl first and only then we
+  // import and set its DeclContext. So, the DC is still not set when we reach
+  // here from GetImportedOrCreateDecl.
+  if (To->getDeclContext())
+AddToLookupTable(To);
   return To;
 }
 

[PATCH] D92209: [ASTImporter] Support CXXDeductionGuideDecl with local typedef

2020-12-09 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added a comment.

Thanks for the review guys!




Comment at: clang/lib/AST/ASTImporter.cpp:2522
+  // Add to the lookupTable because we could not do that in MapImported.
+  Importer.AddToLookupTable(ToTypedef);
+

teemperor wrote:
> martong wrote:
> > shafik wrote:
> > > I am not super excited about this solution, I feel like several bugs we 
> > > have had can be attributed to these exception control flow cases that we 
> > > have in the ASTImporter. I don't have any immediate better solution.
> > > 
> > > 
> > Before uploading this patch I had been thinking about several other 
> > solutions
> > but all of them had some problems:
> > 
> > 1) 
> > Detect the loop in the AST and return with UnsupportedConstruct. We could do
> > the detection with the help of ImportPath. However, I realized this 
> > approach is
> > way too defensive and removes the support for an important AST node which is
> > against our goals.
> > 
> > 2) 
> > Try to eliminate the looping contruct from the AST. I could do that for some
> > cases (D92101) but there are still cases when the Sema must create such a 
> > loop
> > deliberately (the test case in this patch shows that).
> > 
> > It is essential to add a newly created Decl to the lookupTable ASAP because 
> > it
> > makes it possible for subsequent imports to find the existing Decl and this 
> > way
> > avoiding the creation of duplicated Decls. This is why AddToLookupTable is
> > called in MapImported. But the lookuptable operates on the DeclContext of 
> > the
> > Decl, and in this patch we must not import the DeclContext before.
> > Consequently, we have to add to the loopkuptable once the DeclContext is
> > imported. Perhaps, we could provide an optional lambda function to
> > GetImportedOrCreateDecl which would be called before MapImported (and that
> > lambda would do the DC import), but this seems even more clumsy.
> > 
> > BTW, the lookuptable is not used in LLDB, there you use the traditional 
> > lookup
> > implemented in DeclContext (addDeclInternal and noload_lookup). One problem
> > with noload_lookup is that it does not find some Decls because it obeys to 
> > C++
> > visibility rules, thus new duplicated Decls are created. The ASTImporter 
> > must
> > be able to lookup e.g. template specialization Decls too, in order to avoid
> > creating a redundant duplicated clone and this is the task of the 
> > lookupTable.
> > I hope one day LLDB would be able to switch to ASTImporterLookupTable from
> > noload_lookup. The other problem is with addDeclInternal: we call this 
> > later,
> > not in MapImported. The only responsibility attached to the use of 
> > addDeclInternal 
> > should be to clone the visibility as it is in the source context (and not 
> > managing 
> > the do-not-create-duplicate-decls issue).
> > 
> > So yes, there are many exceptional control flow cases, but most of them 
> > stems
> > from the complexity of trying to support two different needs: noload_lookup 
> > and
> > minimal import are needed exceptionally for LLDB. I was thinking about to
> > create a separate ASTImporter implementation specifically for CTU and LLDB
> > could have it's own implementation. For that we just need to create an
> > interface class with virtual functions. Having two different implementations
> > could save us from braking each others tests and this could be a big gain, 
> > WDYT?
> > (On the other hand, we'd loose updates and fixes from the other team.)
> > 
> > I hope one day LLDB would be able to switch to ASTImporterLookupTable from 
> > noload_lookup.
> 
> Done here: https://reviews.llvm.org/D92848
Thanks, this could enable some simplifications in the ASTImporter then.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92209/new/

https://reviews.llvm.org/D92209

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92852: [NFC] Reduce include files dependency and AA header cleanup (part 2).

2020-12-09 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: llvm/lib/Analysis/AliasAnalysis.cpp:685
+  }
+}
+

This should probably be pulled out too


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92852/new/

https://reviews.llvm.org/D92852

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92936: [Sema] Fix deleted function problem in implicitly movable test

2020-12-09 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp created this revision.
nullptr.cpp requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92936

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp

Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- /dev/null
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=cxx20 %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcxx-exceptions -verify=cxx11_14_17 %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -fcxx-exceptions -verify=cxx11_14_17 %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -verify=cxx11_14_17 %s
+
+namespace test_delete_function {
+struct A1 {
+  A1();
+  A1(const A1&);
+  A1(A1&&) = delete;
+  // cxx11_14_17-note@-1 {{'A1' has been explicitly marked deleted here}}
+  // cxx20-note@-2 {{'A1' has been explicitly marked deleted here}}
+};
+A1 test1() {
+  A1 a;
+  return a;
+  // cxx11_14_17-error@-1 {{call to deleted constructor of 'test_delete_function::A1'}}
+  // cxx20-error@-2 {{call to deleted constructor of 'test_delete_function::A1'}}
+}
+
+struct A2 {
+  A2();
+  A2(const A2&);
+private:
+  A2(A2&&);
+  // cxx11_14_17-note@-1 {{declared private here}}
+  // cxx20-note@-2 {{declared private here}}
+};
+A2 test2() {
+  A2 a;
+  return a;
+  // cxx11_14_17-error@-1 {{calling a private constructor of class 'test_delete_function::A2'}}
+  // cxx20-error@-2 {{calling a private constructor of class 'test_delete_function::A2'}}
+}
+
+
+struct C {};
+
+struct B1 {
+  B1(C&);
+  B1(C&&) = delete;
+  // cxx11_14_17-note@-1 {{'B1' has been explicitly marked deleted here}}
+  // cxx20-note@-2 {{'B1' has been explicitly marked deleted here}}
+};
+B1 test3() {
+  C c;
+  return c;
+  // cxx11_14_17-error@-1 {{conversion function from 'test_delete_function::C' to 'test_delete_function::B1' invokes a deleted function}}
+  // cxx20-error@-2 {{conversion function from 'test_delete_function::C' to 'test_delete_function::B1' invokes a deleted function}}
+}
+
+struct B2 {
+  B2(C&);
+private:
+  B2(C&&);
+  // cxx11_14_17-note@-1 {{declared private here}}
+  // cxx20-note@-2 {{declared private here}}
+};
+B2 test4() {
+  C c;
+  return c;
+  // cxx11_14_17-error@-1 {{calling a private constructor of class 'test_delete_function::B2'}}
+  // cxx20-error@-2 {{calling a private constructor of class 'test_delete_function::B2'}}
+}
+} // namespace test_delete_function
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3106,11 +3106,14 @@
 /// If move-initialization is not possible, such that we must fall back to
 /// treating the operand as an lvalue, we will leave Res in its original
 /// invalid state.
-static void TryMoveInitialization(Sema& S,
-  const InitializedEntity &Entity,
+///
+/// \returns Whether need to do the second overload resolution. If the first
+/// overload resolution fails, or if the first overload resolution success but
+/// the selected constructor/operator doesn't match the additional criteria, we
+/// need to do the second overload resolution.
+static bool TryMoveInitialization(Sema &S, const InitializedEntity &Entity,
   const VarDecl *NRVOCandidate,
-  QualType ResultType,
-  Expr *&Value,
+  QualType ResultType, Expr *&Value,
   bool ConvertingConstructorsOnly,
   ExprResult &Res) {
   ImplicitCastExpr AsRvalue(ImplicitCastExpr::OnStack, Value->getType(),
@@ -3123,8 +3126,10 @@
 
   InitializationSequence Seq(S, Entity, Kind, InitExpr);
 
-  if (!Seq)
-return;
+  bool NeedSecondOverload = true;
+  if (!Seq && Seq.getFailedOverloadResult() != OR_Deleted) {
+return NeedSecondOverload;
+  }
 
   for (const InitializationSequence::Step &Step : Seq.steps()) {
 if (Step.Kind != InitializationSequence::SK_ConstructorInitialization &&
@@ -3167,6 +3172,7 @@
   }
 }
 
+NeedSecondOverload = false;
 // Promote "AsRvalue" to the heap, since we now need this
 // expression node to persist.
 Value =
@@ -3177,6 +3183,8 @@
 // using the constructor we found.
 Res = Seq.Perform(S, Entity, Kind, Value);
   }
+
+  return NeedSecondOverload;
 }
 
 /// Perform the initialization of a potentially-movable value, which
@@ -3201,6 +3209,7 @@
   // select the constructor for the copy is first performed as if the object
   // were designated by an rvalue.
   ExprResult Res = ExprError();
+  bool NeedSecondOverload = true;
 
   if (AllowNRVO

[PATCH] D92922: [clang-format] PR42434 Remove preprocessor and pragma lines from ObjectiveC guess

2020-12-09 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 310524.
MyDeveloperDay added a comment.

add support for additional _Pragma


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92922/new/

https://reviews.llvm.org/D92922

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16713,6 +16713,15 @@
   guessLanguage("foo.h", "int(^foo[(kNumEntries + 10)])(char, float);"));
 }
 
+TEST_F(FormatTest, GuessLanguageWithPragmas) {
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "__pragma(warning(disable:))"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "#pragma(warning(disable:))"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "_Pragma(warning(disable:))"));
+}
+
 TEST_F(FormatTest, FormatsInlineAsmSymbolicNames) {
   // ASM symbolic names are identifiers that must be surrounded by [] without
   // space in between:
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2032,6 +2032,10 @@
 };
 
 for (auto Line : AnnotatedLines) {
+  if (Line->First && (Line->First->TokenText.startswith("#") ||
+  Line->First->TokenText == "__pragma" ||
+  Line->First->TokenText == "_Pragma"))
+continue;
   for (const FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
 if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16713,6 +16713,15 @@
   guessLanguage("foo.h", "int(^foo[(kNumEntries + 10)])(char, float);"));
 }
 
+TEST_F(FormatTest, GuessLanguageWithPragmas) {
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "__pragma(warning(disable:))"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "#pragma(warning(disable:))"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "_Pragma(warning(disable:))"));
+}
+
 TEST_F(FormatTest, FormatsInlineAsmSymbolicNames) {
   // ASM symbolic names are identifiers that must be surrounded by [] without
   // space in between:
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2032,6 +2032,10 @@
 };
 
 for (auto Line : AnnotatedLines) {
+  if (Line->First && (Line->First->TokenText.startswith("#") ||
+  Line->First->TokenText == "__pragma" ||
+  Line->First->TokenText == "_Pragma"))
+continue;
   for (const FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
 if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91311: Add new 'preferred_name' attribute.

2020-12-09 Thread James Y Knight via Phabricator via cfe-commits
jyknight added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2384
+  let Spellings = [Clang<"preferred_name", /*AllowInC*/0>];
+  let Subjects = SubjectList<[ClassTmpl]>;
+  let Args = [TypeArgument<"TypedefType">];

I wonder if this attribute ought to be allowed to be used on any Record (which 
would make it potentially also valid for C). In case you also wanted to do 
something like this in the future:

```
class any;
using any_copyable = any;

class [[clang::preferred_name(any_copyable)]] any { ... };
```



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91311/new/

https://reviews.llvm.org/D91311

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92922: [clang-format] PR42434 Remove preprocessor and pragma lines from ObjectiveC guess

2020-12-09 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.

This is very nice :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92922/new/

https://reviews.llvm.org/D92922

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92852: [NFC] Reduce include files dependency and AA header cleanup (part 2).

2020-12-09 Thread Daniil Fukalov via Phabricator via cfe-commits
dfukalov added inline comments.



Comment at: llvm/lib/Analysis/AliasAnalysis.cpp:685
+  }
+}
+

RKSimon wrote:
> This should probably be pulled out too
It uses `dyn_cast(I)` so clang-tidy reports //incomplete type 
'llvm::CallBase' named in nested name specifier// if the function definition is 
in header. This is result of removing include Instructions.h from 
AliasAnalysis.h.

Actually there is one more same clang-tidy report on `isa` in 
MemorySSA.h that includes AliasAnalysis.h (and so included Instructions.h 
through it). I thought to fix it the same way - moving function with 
`isa` to MemorySSA.cpp

Or should I leave include Instructions.h in AliasAnalysis.h?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92852/new/

https://reviews.llvm.org/D92852

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92761: [clang][AArch64][SVE] Avoid going through memory for VLAT <-> VLST casts

2020-12-09 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis updated this revision to Diff 310529.
joechrisellis added a comment.
Herald added a subscriber: NickHung.

Rebase.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92761/new/

https://reviews.llvm.org/D92761

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-codegen.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c
  llvm/include/llvm/IR/IRBuilder.h

Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -923,6 +923,20 @@
 return CreateBinaryIntrinsic(Intrinsic::maximum, LHS, RHS, nullptr, Name);
   }
 
+  CallInst *CreateExtractVector(Type *DstType, Value *SrcVec, Value *Idx,
+const Twine &Name = "") {
+return CreateIntrinsic(Intrinsic::experimental_vector_extract,
+   {DstType, SrcVec->getType()}, {SrcVec, Idx}, nullptr,
+   Name);
+  }
+
+  CallInst *CreateInsertVector(Type *DstType, Value *SrcVec, Value *SubVec,
+   Value *Idx, const Twine &Name = "") {
+return CreateIntrinsic(Intrinsic::experimental_vector_insert,
+   {DstType, SubVec->getType()}, {SrcVec, SubVec, Idx},
+   nullptr, Name);
+  }
+
 private:
   /// Create a call to a masked intrinsic with given Id.
   CallInst *CreateMaskedIntrinsic(Intrinsic::ID Id, ArrayRef Ops,
Index: clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c
===
--- clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c
+++ clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c
@@ -21,40 +21,28 @@
 
 // CHECK-128-LABEL: @write_global_i64(
 // CHECK-128-NEXT:  entry:
-// CHECK-128-NEXT:[[V_ADDR:%.*]] = alloca , align 16
-// CHECK-128-NEXT:store  [[V:%.*]], * [[V_ADDR]], align 16, [[TBAA6:!tbaa !.*]]
-// CHECK-128-NEXT:[[TMP0:%.*]] = bitcast * [[V_ADDR]] to <2 x i64>*
-// CHECK-128-NEXT:[[TMP1:%.*]] = load <2 x i64>, <2 x i64>* [[TMP0]], align 16, [[TBAA10:!tbaa !.*]]
-// CHECK-128-NEXT:store <2 x i64> [[TMP1]], <2 x i64>* @global_i64, align 16, [[TBAA10]]
+// CHECK-128-NEXT:[[CASTFIXEDSVE:%.*]] = call <2 x i64> @llvm.experimental.vector.extract.v2i64.nxv2i64( [[V:%.*]], i64 0)
+// CHECK-128-NEXT:store <2 x i64> [[CASTFIXEDSVE]], <2 x i64>* @global_i64, align 16, [[TBAA6:!tbaa !.*]]
 // CHECK-128-NEXT:ret void
 //
 // CHECK-512-LABEL: @write_global_i64(
 // CHECK-512-NEXT:  entry:
-// CHECK-512-NEXT:[[V_ADDR:%.*]] = alloca , align 16
-// CHECK-512-NEXT:store  [[V:%.*]], * [[V_ADDR]], align 16, [[TBAA6:!tbaa !.*]]
-// CHECK-512-NEXT:[[TMP0:%.*]] = bitcast * [[V_ADDR]] to <8 x i64>*
-// CHECK-512-NEXT:[[TMP1:%.*]] = load <8 x i64>, <8 x i64>* [[TMP0]], align 16, [[TBAA10:!tbaa !.*]]
-// CHECK-512-NEXT:store <8 x i64> [[TMP1]], <8 x i64>* @global_i64, align 16, [[TBAA10]]
+// CHECK-512-NEXT:[[CASTFIXEDSVE:%.*]] = call <8 x i64> @llvm.experimental.vector.extract.v8i64.nxv2i64( [[V:%.*]], i64 0)
+// CHECK-512-NEXT:store <8 x i64> [[CASTFIXEDSVE]], <8 x i64>* @global_i64, align 16, [[TBAA6:!tbaa !.*]]
 // CHECK-512-NEXT:ret void
 //
 void write_global_i64(svint64_t v) { global_i64 = v; }
 
 // CHECK-128-LABEL: @write_global_bf16(
 // CHECK-128-NEXT:  entry:
-// CHECK-128-NEXT:[[V_ADDR:%.*]] = alloca , align 16
-// CHECK-128-NEXT:store  [[V:%.*]], * [[V_ADDR]], align 16, [[TBAA11:!tbaa !.*]]
-// CHECK-128-NEXT:[[TMP0:%.*]] = bitcast * [[V_ADDR]] to <8 x bfloat>*
-// CHECK-128-NEXT:[[TMP1:%.*]] = load <8 x bfloat>, <8 x bfloat>* [[TMP0]], align 16, [[TBAA10]]
-// CHECK-128-NEXT:store <8 x bfloat> [[TMP1]], <8 x bfloat>* @global_bf16, align 16, [[TBAA10]]
+// CHECK-128-NEXT:[[CASTFIXEDSVE:%.*]] = call <8 x bfloat> @llvm.experimental.vector.extract.v8bf16.nxv8bf16( [[V:%.*]], i64 0)
+// CHECK-128-NEXT:store <8 x bfloat> [[CASTFIXEDSVE]], <8 x bfloat>* @global_bf16, align 16, [[TBAA6]]
 // CHECK-128-NEXT:ret void
 //
 // CHECK-512-LABEL: @write_global_bf16(
 // CHECK-512-NEXT:  entry:
-// CHECK-512-NEXT:[[V_ADDR:%.*]] = alloca , align 16
-// CHECK-512-NEXT:store  [[V:%.*]], * [[V_ADDR]], align 16, [[TBAA11:!tbaa !.*]]
-// CHECK-512-NEXT:[[TMP0:%.*]] = bitcast * [[V_ADDR]] to <32 x bfloat>*
-// CHECK-512-NEXT:[[TMP1:%.*]] = load <32 x bfloat>, <32 x bfloat>* [[TMP0]], align 16, [[TBAA10]]
-// CHECK-512-NEXT:store <32 x bfloat> [[TMP1]], <32 x bfloat>* @global_bf16, align 16, [[TBAA10]]
+// CHECK-512-NEXT:[[CASTFIXEDSVE:%.*]] = call <32 x bfloat> @llvm.experimental.vector.extr

[PATCH] D92940: [X86] Convert fadd/fmul _mm_reduce_* intrinsics to emit llvm.reduction intrinsics (PR47506)

2020-12-09 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon created this revision.
RKSimon added reviewers: craig.topper, pengfei.
RKSimon requested review of this revision.
Herald added a project: clang.

Followup to D87604 , having confirmed on 
PR47506 that we can use the llvm codegen expansion for fadd/fmul as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92940

Files:
  clang/include/clang/Basic/BuiltinsX86.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/avx512fintrin.h
  clang/test/CodeGen/X86/avx512-reduceIntrin.c

Index: clang/test/CodeGen/X86/avx512-reduceIntrin.c
===
--- clang/test/CodeGen/X86/avx512-reduceIntrin.c
+++ clang/test/CodeGen/X86/avx512-reduceIntrin.c
@@ -115,67 +115,25 @@
 
 double test_mm512_reduce_add_pd(__m512d __W){
 // CHECK-LABEL: @test_mm512_reduce_add_pd(
-// CHECK:shufflevector <8 x double> %{{.*}}, <8 x double> undef, <4 x i32> 
-// CHECK:shufflevector <8 x double> %{{.*}}, <8 x double> undef, <4 x i32> 
-// CHECK:fadd <4 x double> %{{.*}}, %{{.*}}
-// CHECK:shufflevector <4 x double> %{{.*}}, <4 x double> undef, <2 x i32> 
-// CHECK:shufflevector <4 x double> %{{.*}}, <4 x double> undef, <2 x i32> 
-// CHECK:fadd <2 x double> %{{.*}}, %{{.*}}
-// CHECK:shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x i32> 
-// CHECK:fadd <2 x double> %{{.*}}, %{{.*}}
-// CHECK:extractelement <2 x double> %{{.*}}, i32 0
+// CHECK:call double @llvm.vector.reduce.fadd.v8f64(double 0.00e+00, <8 x double> %{{.*}})
   return _mm512_reduce_add_pd(__W); 
 }
 
 double test_mm512_reduce_mul_pd(__m512d __W){
 // CHECK-LABEL: @test_mm512_reduce_mul_pd(
-// CHECK:shufflevector <8 x double> %{{.*}}, <8 x double> undef, <4 x i32> 
-// CHECK:shufflevector <8 x double> %{{.*}}, <8 x double> undef, <4 x i32> 
-// CHECK:fmul <4 x double> %{{.*}}, %{{.*}}
-// CHECK:shufflevector <4 x double> %{{.*}}, <4 x double> undef, <2 x i32> 
-// CHECK:shufflevector <4 x double> %{{.*}}, <4 x double> undef, <2 x i32> 
-// CHECK:fmul <2 x double> %{{.*}}, %{{.*}}
-// CHECK:shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x i32> 
-// CHECK:fmul <2 x double> %{{.*}}, %{{.*}}
-// CHECK:extractelement <2 x double> %{{.*}}, i32 0
+// CHECK:call double @llvm.vector.reduce.fmul.v8f64(double 1.00e+00, <8 x double> %{{.*}})
   return _mm512_reduce_mul_pd(__W); 
 }
 
 float test_mm512_reduce_add_ps(__m512 __W){
 // CHECK-LABEL: @test_mm512_reduce_add_ps(
-// CHECK:bitcast <16 x float> %{{.*}} to <8 x double>
-// CHECK:shufflevector <8 x double> %{{.*}}, <8 x double> undef, <4 x i32> 
-// CHECK:bitcast <4 x double> %{{.*}} to <8 x float>
-// CHECK:shufflevector <8 x double> %{{.*}}, <8 x double> undef, <4 x i32> 
-// CHECK:bitcast <4 x double> %{{.*}} to <8 x float>
-// CHECK:fadd <8 x float> %{{.*}}, %{{.*}}
-// CHECK:shufflevector <8 x float> %{{.*}}, <8 x float> undef, <4 x i32> 
-// CHECK:shufflevector <8 x float> %{{.*}}, <8 x float> undef, <4 x i32> 
-// CHECK:fadd <4 x float> %{{.*}}, %{{.*}}
-// CHECK:shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> 
-// CHECK:fadd <4 x float> %{{.*}}, %{{.*}}
-// CHECK:shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> 
-// CHECK:fadd <4 x float> %{{.*}}, %{{.*}}
-// CHECK:extractelement <4 x float> %{{.*}}, i32 0
+// CHECK:call float @llvm.vector.reduce.fadd.v16f32(float 0.00e+00, <16 x float> %{{.*}})
   return _mm512_reduce_add_ps(__W); 
 }
 
 float test_mm512_reduce_mul_ps(__m512 __W){
 // CHECK-LABEL: @test_mm512_reduce_mul_ps(
-// CHECK:bitcast <16 x float> %{{.*}} to <8 x double>
-// CHECK:shufflevector <8 x double> %{{.*}}, <8 x double> undef, <4 x i32> 
-// CHECK:bitcast <4 x double> %{{.*}} to <8 x float>
-// CHECK:shufflevector <8 x double> %{{.*}}, <8 x double> undef, <4 x i32> 
-// CHECK:bitcast <4 x double> %{{.*}} to <8 x float>
-// CHECK:fmul <8 x float> %{{.*}}, %{{.*}}
-// CHECK:shufflevector <8 x float> %{{.*}}, <8 x float> undef, <4 x i32> 
-// CHECK:shufflevector <8 x float> %{{.*}}, <8 x float> undef, <4 x i32> 
-// CHECK:fmul <4 x float> %{{.*}}, %{{.*}}
-// CHECK:shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> 
-// CHECK:fmul <4 x float> %{{.*}}, %{{.*}}
-// CHECK:shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> 
-// CHECK:fmul <4 x float> %{{.*}}, %{{.*}}
-// CHECK:extractelement <4 x float> %{{.*}}, i32 0
+// CHECK:call float @llvm.vector.reduce.fmul.v16f32(float 1.00e+00, <16 x float> %{{.*}})
   return _mm512_reduce_mul_ps(__W); 
 }
 
@@ -183,15 +141,7 @@
 // CHECK-LABEL: @test_mm512_mask_reduce_add_pd(
 // CHECK:bitcast i8 %{{.*}} to <8 x i1>
 // CHECK:select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}}
-// CHECK:shufflevector <8 x double> %{{.*}}, <8

[PATCH] D92762: [clang][AArch64][SVE] Avoid going through memory for coerced VLST arguments

2020-12-09 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis updated this revision to Diff 310532.
joechrisellis added a comment.
Herald added a subscriber: NickHung.

Rebase.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92762/new/

https://reviews.llvm.org/D92762

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.c
  clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.cpp
  clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c

Index: clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
===
--- clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
+++ clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
@@ -13,11 +13,8 @@
 
 // CHECK-LABEL: @to_svint32_t(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TYPE:%.*]] = alloca <16 x i32>, align 16
-// CHECK-NEXT:[[TMP0:%.*]] = bitcast <16 x i32>* [[TYPE]] to *
-// CHECK-NEXT:store  [[TYPE_COERCE:%.*]], * [[TMP0]], align 16
-// CHECK-NEXT:[[TYPE1:%.*]] = load <16 x i32>, <16 x i32>* [[TYPE]], align 16, [[TBAA6:!tbaa !.*]]
-// CHECK-NEXT:[[CASTSCALABLESVE:%.*]] = call  @llvm.experimental.vector.insert.nxv4i32.v16i32( undef, <16 x i32> [[TYPE1]], i64 0)
+// CHECK-NEXT:[[TYPE:%.*]] = call <16 x i32> @llvm.experimental.vector.extract.v16i32.nxv4i32( [[X_COERCE:%.*]], i64 0)
+// CHECK-NEXT:[[CASTSCALABLESVE:%.*]] = call  @llvm.experimental.vector.insert.nxv4i32.v16i32( undef, <16 x i32> [[TYPE]], i64 0)
 // CHECK-NEXT:ret  [[CASTSCALABLESVE]]
 //
 svint32_t to_svint32_t(fixed_int32_t type) {
@@ -39,11 +36,8 @@
 
 // CHECK-LABEL: @to_svfloat64_t(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TYPE:%.*]] = alloca <8 x double>, align 16
-// CHECK-NEXT:[[TMP0:%.*]] = bitcast <8 x double>* [[TYPE]] to *
-// CHECK-NEXT:store  [[TYPE_COERCE:%.*]], * [[TMP0]], align 16
-// CHECK-NEXT:[[TYPE1:%.*]] = load <8 x double>, <8 x double>* [[TYPE]], align 16, [[TBAA6]]
-// CHECK-NEXT:[[CASTSCALABLESVE:%.*]] = call  @llvm.experimental.vector.insert.nxv2f64.v8f64( undef, <8 x double> [[TYPE1]], i64 0)
+// CHECK-NEXT:[[TYPE:%.*]] = call <8 x double> @llvm.experimental.vector.extract.v8f64.nxv2f64( [[X_COERCE:%.*]], i64 0)
+// CHECK-NEXT:[[CASTSCALABLESVE:%.*]] = call  @llvm.experimental.vector.insert.nxv2f64.v8f64( undef, <8 x double> [[TYPE]], i64 0)
 // CHECK-NEXT:ret  [[CASTSCALABLESVE]]
 //
 svfloat64_t to_svfloat64_t(fixed_float64_t type) {
@@ -69,7 +63,7 @@
 // CHECK-NEXT:[[TYPE_ADDR:%.*]] = alloca <8 x i8>, align 16
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <8 x i8>* [[TYPE]] to *
 // CHECK-NEXT:store  [[TYPE_COERCE:%.*]], * [[TMP0]], align 16
-// CHECK-NEXT:[[TYPE1:%.*]] = load <8 x i8>, <8 x i8>* [[TYPE]], align 16, [[TBAA6]]
+// CHECK-NEXT:[[TYPE1:%.*]] = load <8 x i8>, <8 x i8>* [[TYPE]], align 16, [[TBAA6:!tbaa !.*]]
 // CHECK-NEXT:store <8 x i8> [[TYPE1]], <8 x i8>* [[TYPE_ADDR]], align 16, [[TBAA6]]
 // CHECK-NEXT:[[TMP1:%.*]] = bitcast <8 x i8>* [[TYPE_ADDR]] to *
 // CHECK-NEXT:[[TMP2:%.*]] = load , * [[TMP1]], align 16, [[TBAA6]]
@@ -130,11 +124,8 @@
 
 // CHECK-LABEL: @from_fixed_int32_t__to_gnu_int32_t(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TYPE:%.*]] = alloca <16 x i32>, align 16
-// CHECK-NEXT:[[TMP0:%.*]] = bitcast <16 x i32>* [[TYPE]] to *
-// CHECK-NEXT:store  [[TYPE_COERCE:%.*]], * [[TMP0]], align 16
-// CHECK-NEXT:[[TYPE1:%.*]] = load <16 x i32>, <16 x i32>* [[TYPE]], align 16, [[TBAA6]]
-// CHECK-NEXT:store <16 x i32> [[TYPE1]], <16 x i32>* [[AGG_RESULT:%.*]], align 16, [[TBAA6]]
+// CHECK-NEXT:[[TYPE:%.*]] = call <16 x i32> @llvm.experimental.vector.extract.v16i32.nxv4i32( [[X_COERCE:%.*]], i64 0)
+// CHECK-NEXT:store <16 x i32> [[TYPE]], <16 x i32>* [[AGG_RESULT:%.*]], align 16, [[TBAA6]]
 // CHECK-NEXT:ret void
 //
 gnu_int32_t from_fixed_int32_t__to_gnu_int32_t(fixed_int32_t type) {
Index: clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
===
--- clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
+++ clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
@@ -24,17 +24,14 @@
 
 // CHECK-LABEL: @fixed_caller(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[X:%.*]] = alloca <16 x i32>, align 16
 // CHECK-NEXT:[[RETVAL_COERCE:%.*]] = alloca , align 16
-// CHECK-NEXT:[[TMP0:%.*]] = bitcast <16 x i32>* [[X]] to *
-// CHECK-NEXT:store  [[X_COERCE:%.*]], * [[TMP0]], align 16
-// CHECK-NEXT:[[X1:%.*]] = load <16 x i32>, <16 x i32>* [[X]], align 16, [[TBAA6:!tbaa !.*]]
-// CHECK-NEXT:[[CASTSCALABLESVE:%.*]] = call  @llvm.experimental.vector.insert.nxv4i32.v16i32( undef, <16 x i32> [[X1]], i64 0)
+// CHECK-NEXT:[[X:%.*]] = call <16 x i32> @llvm.experimental.vector.extract.v16i32.nxv4i32( [[X_COERCE:%.*]], i64 0)
+// CHECK-NEXT:[[CASTSCALABLESVE:%.*]] = call  @llvm.experimental.vecto

[PATCH] D83088: Introduce CfgTraits abstraction

2020-12-09 Thread Nicolai HƤhnle via Phabricator via cfe-commits
nhaehnle abandoned this revision.
nhaehnle added a comment.
Herald added a subscriber: teijeong.

Superseded by D92924 , D92925 
, D92926 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83088/new/

https://reviews.llvm.org/D83088

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92939: [clangd] Split tweak tests into one file per tweak.

2020-12-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: 
clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp:9
+
+#include "Annotations.h"
+#include "Config.h"

Most of these headers are unused in most of the tests, not sure what's the best 
point to clean them up

Most of these should just need TweakTests, gmock and gtest.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92939/new/

https://reviews.llvm.org/D92939

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92663: [clangd] Add hot-reload of compile_commands.json and compile_flags.txt

2020-12-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

this mostly LGTM. there are some changes to the existing behavior; like 
discovery order and not looking for other plugins under `build/`, but they seem 
like non-harmful changes to me.

my biggest question is, have we considered updating `CompilationDatabasePlugin` 
interface to provide a `loadFromBuffer` and `relativeFileName` virtual methods. 
I think loading logic could've been a lot simpler and more uniform that way.
i think we discussed this option but i don't remember the outcome, sorry :(.




Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:185
+bool MayCache = load(*TFS.view(/*CWD=*/llvm::None));
+if (MayCache) {
+  // Use new timestamp, as loading may be slow.

nit: inline `MayCache`



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:205
+  auto Stat = FS.status(Path);
+  if (!Stat || !Stat->isRegularFile()) {
+Size = NoFileCached;

what about symlinks ? i think users usually have `cc.json -> 
obscure_build_dir/cc.json` as a symlink.



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:224
+  if (HasOldData && NewContentHash == ContentHash)
+// mtime changed but data is the same: avoid rebuilding the CDB.
+return {LoadResult::FoundSameData, nullptr};

also update cached mtime ?



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:267
+// Wrapper for {Fixed,JSON}CompilationDatabase::loadFromBuffer.
+std::unique_ptr (*Parser)(
+PathRef,

nit: can we have a functor(probably llvm::function_ref) rather than a function 
pointer?



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:322
+auto Plugin = Entry.instantiate();
+if (auto CDB = Plugin->loadFromDirectory(Path, Error)) {
+  log("Loaded compilation database from {0} with plugin {1}", Path,

it is not crucial but we used to try to load these from `Path + "/build"` as 
well



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:456
 CDBLookupResult Result) const {
+  vlog("Broadcasting compilation database from {0}", Result.PI.SourceRoot);
   assert(Result.CDB && "Trying to broadcast an invalid CDB!");

why not `log` instead of `vlog`? this shouldn't be too noisy anyway.



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.h:133
+
+  std::chrono::steady_clock::duration RevalidateAfter;
+  std::chrono::steady_clock::duration RevalidateMissingAfter;

why not directly store `Options` ?



Comment at: 
clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp:393
+
+auto HasFlag(llvm::StringRef Flag) { return HasFlag(Flag, "dummy.cc"); }
+

nit: maybe a `MATCHER_P` instead ?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92663/new/

https://reviews.llvm.org/D92663

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92661: [RFC] Fix TLS and Coroutine

2020-12-09 Thread Nicolai HƤhnle via Phabricator via cfe-commits
nhaehnle added inline comments.



Comment at: llvm/include/llvm/IR/Intrinsics.td:1281-1282
 // The pseudoprobe intrinsic works as a place holder to the block it probes.
-// Like the sideeffect intrinsic defined above, this intrinsic is treated by 
the 
-// optimizer as having opaque side effects so that it won't be get rid of or 
moved 
+// Like the sideeffect intrinsic defined above, this intrinsic is treated by 
the
+// optimizer as having opaque side effects so that it won't be get rid of or 
moved
 // out of the block it probes.

Unrelated change


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92661/new/

https://reviews.llvm.org/D92661

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92922: [clang-format] PR42434 Remove preprocessor and pragma lines from ObjectiveC guess

2020-12-09 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

Great! LGTM.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92922/new/

https://reviews.llvm.org/D92922

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92808: [ObjC][ARC] Annotate calls with attributes instead of emitting retainRV or claimRV calls in the IR

2020-12-09 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: clang/lib/CodeGen/CGObjC.cpp:2326
+
+  if (CGF.CGM.getCodeGenOpts().OptimizationLevel != 0 &&
+  CGF.CGM.getTarget().getTriple().isAArch64() &&

Nit: I think that `> 0` is easier to read.



Comment at: clang/lib/CodeGen/CGObjC.cpp:2328
+  CGF.CGM.getTarget().getTriple().isAArch64() &&
+  !CGF.CGM.getTarget().getTriple().isOSWindows()) {
+auto *callBase = cast(value);

Hmm, why the explicit check for not-Windows?



Comment at: llvm/include/llvm/Analysis/ObjCARCRVAttr.h:43
+CB->removeAttribute(llvm::AttributeList::ReturnIndex, "claimRV");
+  if (RemoveMarker && hasRVMarkerAttr(CB))
+CB->removeAttribute(llvm::AttributeList::ReturnIndex, "rv_marker");

Nit: A new line before this would be nice.



Comment at: llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp:468
+if (IsBundled)
+  return false;
+

It seems that `IsBundled` is unused after this point, why not just do:

```
if (BundledInsts->contains(Inst))
  return false;
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92808/new/

https://reviews.llvm.org/D92808

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92381: [clangd] Extract per-dir CDB cache to its own threadsafe class. NFC

2020-12-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 2 inline comments as done.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:79
+  // Absolute canonical path that we're the cache for. (Not case-folded).
+  std::string Path;
+

kadircet wrote:
> nit: mark it const ?
Yeah, Done. I don't usually like const on members but all the other state is so 
complicated here and we definitely aren't movable and don't want to be.



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:128
+
+load();
+CachePopulated = true;

kadircet wrote:
> nit: maybe stash modification of control signals to `load()` rather than 
> having them split between `load()` and `get()` (or alternatively just change 
> the `load` to return a `{shared,unique}_ptr` while making it a free function 
> and then perform all the signal modifications inside `get`)
Moved them all into `get` to isolate the complexity somewhat. We can in fact 
infer NeedsBroadcast from the old/new CDB pointer.

Unfortunately making `load` a free function falls apart in the next patch as 
`load` gets complicated:
 - it needs to own the state of "which cached file corresponds to the current 
CDB" as well as the CDB itself
 - it needs to access and update the file cache state itself
 - it has a one-off query of the CachePopulated flag to avoid reloading 
plugin-based CDBs
It's of course *possible* to make it a free function but the signature is such 
a mess that I don't think it buys anything.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92381/new/

https://reviews.llvm.org/D92381

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 634a377 - [clangd] Extract per-dir CDB cache to its own threadsafe class. NFC

2020-12-09 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-12-09T17:40:12+01:00
New Revision: 634a377bd8cbaa515a58295cfd85dcb6a21381c1

URL: 
https://github.com/llvm/llvm-project/commit/634a377bd8cbaa515a58295cfd85dcb6a21381c1
DIFF: 
https://github.com/llvm/llvm-project/commit/634a377bd8cbaa515a58295cfd85dcb6a21381c1.diff

LOG: [clangd] Extract per-dir CDB cache to its own threadsafe class. NFC

This is a step towards making compile_commands.json reloadable.

The idea is:
 - in addition to rare CDB loads we're soon going to have somewhat-rare CDB
   reloads and fairly-common stat() of files to validate the CDB
 - so stop doing all our work under a big global lock, instead using it to
   acquire per-directory structures with their own locks
 - each directory can be refreshed from disk every N seconds, like filecache
 - avoid locking these at all in the most common case: directory has no CDB

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

Added: 


Modified: 
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/clangd/GlobalCompilationDatabase.h

Removed: 




diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index 23e8c9fe716d0..f867920c9d1fc 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -16,11 +16,13 @@
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
+#include 
 #include 
 #include 
 #include 
@@ -58,10 +60,117 @@ GlobalCompilationDatabase::getFallbackCommand(PathRef 
File) const {
   return Cmd;
 }
 
+// Loads and caches the CDB from a single directory.
+//
+// This class is threadsafe, which is to say we have independent locks for each
+// directory we're searching for a CDB.
+// Loading is deferred until first access.
+//
+// The DirectoryBasedCDB keeps a map from path => DirectoryCache.
+// Typical usage is to:
+//  - 1) determine all the paths that might be searched
+//  - 2) acquire the map lock and get-or-create all the DirectoryCache entries
+//  - 3) release the map lock and query the caches as desired
+//
+// FIXME: this should revalidate the cache sometimes
+// FIXME: IO should go through a VFS
+class DirectoryBasedGlobalCompilationDatabase::DirectoryCache {
+  // Absolute canonical path that we're the cache for. (Not case-folded).
+  const std::string Path;
+
+  // True if we've looked for a CDB here and found none.
+  // (This makes it possible for get() to return without taking a lock)
+  // FIXME: this should have an expiry time instead of lasting forever.
+  std::atomic FinalizedNoCDB = {false};
+
+  // Guards following cache state.
+  std::mutex Mu;
+  // Has cache been filled from disk? FIXME: this should be an expiry time.
+  bool CachePopulated = false;
+  // Whether a new CDB has been loaded but not broadcast yet.
+  bool NeedsBroadcast = false;
+  // Last loaded CDB, meaningful if CachePopulated is set.
+  // shared_ptr so we can overwrite this when callers are still using the CDB.
+  std::shared_ptr CDB;
+
+public:
+  DirectoryCache(llvm::StringRef Path) : Path(Path) {
+assert(llvm::sys::path::is_absolute(Path));
+  }
+
+  // Get the CDB associated with this directory.
+  // ShouldBroadcast:
+  //  - as input, signals whether the caller is willing to broadcast a
+  //newly-discovered CDB. (e.g. to trigger background indexing)
+  //  - as output, signals whether the caller should do so.
+  // (If a new CDB is discovered and ShouldBroadcast is false, we mark the
+  // CDB as needing broadcast, and broadcast it next time we can).
+  std::shared_ptr
+  get(bool &ShouldBroadcast) {
+// Fast path for common case without taking lock.
+if (FinalizedNoCDB.load()) {
+  ShouldBroadcast = false;
+  return nullptr;
+}
+std::lock_guard Lock(Mu);
+auto RequestBroadcast = llvm::make_scope_exit([&, OldCDB(CDB.get())] {
+  // If we loaded a new CDB, it should be broadcast at some point.
+  if (CDB != nullptr && CDB.get() != OldCDB)
+NeedsBroadcast = true;
+  else if (CDB == nullptr) // nothing to broadcast anymore!
+NeedsBroadcast = false;
+  // If we have something to broadcast, then do so iff allowed.
+  if (!ShouldBroadcast)
+return;
+  ShouldBroadcast = NeedsBroadcast;
+  NeedsBroadcast = false;
+});
+
+// For now, we never actually attempt to revalidate a populated cache.
+if (CachePopulated)
+  return CDB;
+assert(CDB == nullptr);
+
+load();
+CachePopulated = true;
+
+if (!CDB)
+  FinalizedNoCDB.store(true);
+return CDB;
+  }
+
+  llvm::StringRef path() const {

[PATCH] D92381: [clangd] Extract per-dir CDB cache to its own threadsafe class. NFC

2020-12-09 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rG634a377bd8cb: [clangd] Extract per-dir CDB cache to its own 
threadsafe class. NFC (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D92381?vs=309474&id=310552#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92381/new/

https://reviews.llvm.org/D92381

Files:
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.h

Index: clang-tools-extra/clangd/GlobalCompilationDatabase.h
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.h
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.h
@@ -81,13 +81,19 @@
   llvm::Optional getProjectInfo(PathRef File) const override;
 
 private:
-  /// Caches compilation databases loaded from directories.
-  struct CachedCDB {
-std::string Path; // Not case-folded.
-std::unique_ptr CDB = nullptr;
-bool SentBroadcast = false;
-  };
-  CachedCDB &getCDBInDirLocked(PathRef File) const;
+  class DirectoryCache;
+  // If there's an explicit CompileCommandsDir, cache of the CDB found there.
+  mutable std::unique_ptr OnlyDirCache;
+
+  // Keyed by possibly-case-folded directory path.
+  // We can hand out pointers as they're stable and entries are never removed.
+  // Empty if CompileCommandsDir is given (OnlyDirCache is used instead).
+  mutable llvm::StringMap DirCaches;
+  // DirCaches access must be locked (unlike OnlyDirCache, which is threadsafe).
+  mutable std::mutex DirCachesMutex;
+
+  std::vector
+  getDirectoryCaches(llvm::ArrayRef Dirs) const;
 
   struct CDBLookupRequest {
 PathRef FileName;
@@ -95,21 +101,13 @@
 bool ShouldBroadcast = false;
   };
   struct CDBLookupResult {
-tooling::CompilationDatabase *CDB = nullptr;
+std::shared_ptr CDB;
 ProjectInfo PI;
   };
   llvm::Optional lookupCDB(CDBLookupRequest Request) const;
 
   // Performs broadcast on governed files.
   void broadcastCDB(CDBLookupResult Res) const;
-
-  mutable std::mutex Mutex;
-  // Keyed by possibly-case-folded directory path.
-  mutable llvm::StringMap CompilationDatabases;
-
-  /// Used for command argument pointing to folder where compile_commands.json
-  /// is located.
-  llvm::Optional CompileCommandsDir;
 };
 
 /// Extracts system include search path from drivers matching QueryDriverGlobs
Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -16,11 +16,13 @@
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
+#include 
 #include 
 #include 
 #include 
@@ -58,10 +60,117 @@
   return Cmd;
 }
 
+// Loads and caches the CDB from a single directory.
+//
+// This class is threadsafe, which is to say we have independent locks for each
+// directory we're searching for a CDB.
+// Loading is deferred until first access.
+//
+// The DirectoryBasedCDB keeps a map from path => DirectoryCache.
+// Typical usage is to:
+//  - 1) determine all the paths that might be searched
+//  - 2) acquire the map lock and get-or-create all the DirectoryCache entries
+//  - 3) release the map lock and query the caches as desired
+//
+// FIXME: this should revalidate the cache sometimes
+// FIXME: IO should go through a VFS
+class DirectoryBasedGlobalCompilationDatabase::DirectoryCache {
+  // Absolute canonical path that we're the cache for. (Not case-folded).
+  const std::string Path;
+
+  // True if we've looked for a CDB here and found none.
+  // (This makes it possible for get() to return without taking a lock)
+  // FIXME: this should have an expiry time instead of lasting forever.
+  std::atomic FinalizedNoCDB = {false};
+
+  // Guards following cache state.
+  std::mutex Mu;
+  // Has cache been filled from disk? FIXME: this should be an expiry time.
+  bool CachePopulated = false;
+  // Whether a new CDB has been loaded but not broadcast yet.
+  bool NeedsBroadcast = false;
+  // Last loaded CDB, meaningful if CachePopulated is set.
+  // shared_ptr so we can overwrite this when callers are still using the CDB.
+  std::shared_ptr CDB;
+
+public:
+  DirectoryCache(llvm::StringRef Path) : Path(Path) {
+assert(llvm::sys::path::is_absolute(Path));
+  }
+
+  // Get the CDB associated with this directory.
+  // ShouldBroadcast:
+  //  - as input, signals whether the caller is willing to broadcast a
+  //newly-discovered CDB. (e.g. to trig

[PATCH] D92788: [clangd] NFC: Use SmallVector where possible

2020-12-09 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clangd/ConfigProvider.cpp:100
   llvm::StringRef Parent = path::parent_path(P.Path);
-  llvm::SmallVector Ancestors;
   for (auto I = path::begin(Parent, path::Style::posix),

This should be using the same size as the vector below as they are guaranteed 
to be the same size. There may be an argument for merging them both into the 
same vector using a pair but obviously that wouldn't be part of this patch. 



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:608
   for (const auto &Line : Tokens) {
-llvm::SmallVector LineByteTokens;
+llvm::SmallVector LineByteTokens;
 llvm::raw_svector_ostream OS(LineByteTokens);

Looks like this is referring to how many bytes are in a line, having 128 seems 
like a good amount, most coding standards don't like lines longer than that. As 
a follow up refractor, this could be extracted out the loop to reuse the buffer 
on the case it does need to allocate. 



Comment at: clang-tools-extra/clangd/unittests/TestTU.cpp:190
 const NamedDecl &findDecl(ParsedAST &AST, llvm::StringRef QName) {
-  llvm::SmallVector Components;
+  llvm::SmallVector Components;
   QName.split(Components, "::");

A follow up refractor, this doesn't strictly need to be stored in a vector. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92788/new/

https://reviews.llvm.org/D92788

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92788: [clangd] NFC: Use SmallVector where possible

2020-12-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:608
   for (const auto &Line : Tokens) {
-llvm::SmallVector LineByteTokens;
+llvm::SmallVector LineByteTokens;
 llvm::raw_svector_ostream OS(LineByteTokens);

njames93 wrote:
> Looks like this is referring to how many bytes are in a line, having 128 
> seems like a good amount, most coding standards don't like lines longer than 
> that. As a follow up refractor, this could be extracted out the loop to reuse 
> the buffer on the case it does need to allocate. 
Nit; This is rather the encoded data for all the highlighted tokens on a line 
of source code. Which appears to be a constant 8 bytes for token. So previously 
16 tokens, now 32 tokens. Either seems fine to me given we don't highlight most 
punctuation I think.

(Incidentally, this is the old pre-standard semantic highlighting protocol that 
will go away soon, so I wouldn't worry too much about its performance)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92788/new/

https://reviews.llvm.org/D92788

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92808: [ObjC][ARC] Annotate calls with attributes instead of emitting retainRV or claimRV calls in the IR

2020-12-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 310561.
ahatanak marked 3 inline comments as done.
ahatanak added a comment.

Address review comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92808/new/

https://reviews.llvm.org/D92808

Files:
  clang/lib/CodeGen/CGObjC.cpp
  clang/test/CodeGenObjC/arc-rv-attr.m
  clang/test/CodeGenObjC/arc-unsafeclaim.m
  llvm/include/llvm/Analysis/ObjCARCRVAttr.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/lib/IR/Instruction.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
  llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
  llvm/lib/Transforms/ObjCARC/ObjCARC.cpp
  llvm/lib/Transforms/ObjCARC/ObjCARC.h
  llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
  llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
  llvm/lib/Transforms/ObjCARC/PtrState.cpp
  llvm/lib/Transforms/ObjCARC/PtrState.h
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/test/Transforms/DeadArgElim/deadretval.ll
  llvm/test/Transforms/Inline/inline-retainRV-call.ll
  llvm/test/Transforms/ObjCARC/contract-rv-attr.ll
  llvm/test/Transforms/ObjCARC/rv.ll

Index: llvm/test/Transforms/ObjCARC/rv.ll
===
--- llvm/test/Transforms/ObjCARC/rv.ll
+++ llvm/test/Transforms/ObjCARC/rv.ll
@@ -452,6 +452,28 @@
   ret i8* %v3
 }
 
+; Remove attributes and the autoreleaseRV call if the call is a tail call.
+
+; CHECK-LABEL: define i8* @test31(
+; CHECK: %[[CALL:.*]] = tail call i8* @returner()
+; CHECK: ret i8* %[[CALL]]
+
+define i8* @test31() {
+  %call = tail call "retainRV" "rv_marker" i8* @returner()
+  %1 = call i8* @llvm.objc.autoreleaseReturnValue(i8* %call)
+  ret i8* %1
+}
+
+; CHECK-LABEL: define i8* @test32(
+; CHECK: %[[CALL:.*]] = call "retainRV" "rv_marker" i8* @returner()
+; CHECK: call i8* @llvm.objc.autoreleaseReturnValue(i8* %[[CALL]])
+
+define i8* @test32() {
+  %call = call "retainRV" "rv_marker" i8* @returner()
+  %1 = call i8* @llvm.objc.autoreleaseReturnValue(i8* %call)
+  ret i8* %1
+}
+
 !0 = !{}
 
 ; CHECK: attributes [[NUW]] = { nounwind }
Index: llvm/test/Transforms/ObjCARC/contract-rv-attr.ll
===
--- /dev/null
+++ llvm/test/Transforms/ObjCARC/contract-rv-attr.ll
@@ -0,0 +1,63 @@
+; RUN: opt -objc-arc-contract -S < %s | FileCheck %s
+; RUN: opt -passes=objc-arc-contract -S < %s | FileCheck %s
+
+; CHECK-LABEL: define void @test0() {
+; CHECK: %[[CALL:.*]] = notail call "rv_marker" i8* @foo()
+; CHECK: call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[CALL]])
+
+define void @test0() {
+  %call1 = call "retainRV" "rv_marker" i8* @foo()
+  ret void
+}
+
+; CHECK-LABEL: define void @test1() {
+; CHECK: %[[CALL:.*]] = notail call "rv_marker" i8* @foo()
+; CHECK: call i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8* %[[CALL]])
+
+define void @test1() {
+  %call1 = call "claimRV" "rv_marker" i8* @foo()
+  ret void
+}
+
+; CHECK-LABEL:define i8* @test2(
+; CHECK: %[[CALL1:.*]] = invoke "rv_marker" i8* @foo()
+
+; CHECK: %[[V0:.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[CALL1]])
+; CHECK-NEXT: br
+
+; CHECK: %[[CALL3:.*]] = invoke "rv_marker" i8* @foo()
+
+; CHECK: %[[V2:.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[CALL3]])
+; CHECK-NEXT: br
+
+; CHECK: %[[RETVAL:.*]] = phi i8* [ %[[V0]], {{.*}} ], [ %[[V2]], {{.*}} ]
+; CHECK: ret i8* %[[RETVAL]]
+
+define i8* @test2(i1 zeroext %b) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+entry:
+  br i1 %b, label %if.then, label %if.end
+
+if.then:
+  %call1 = invoke "retainRV" "rv_marker" i8* @foo()
+  to label %cleanup unwind label %lpad
+
+lpad:
+  %0 = landingpad { i8*, i32 }
+  cleanup
+  resume { i8*, i32 } undef
+
+if.end:
+  %call3 = invoke "retainRV" "rv_marker" i8* @foo()
+  to label %cleanup unwind label %lpad
+
+cleanup:
+  %retval.0 = phi i8* [ %call1, %if.then ], [ %call3, %if.end ]
+  ret i8* %retval.0
+}
+
+declare i8* @foo()
+declare i32 @__gxx_personality_v0(...)
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 1, !"clang.arc.retainAutoreleasedReturnValueMarker", !"mov\09fp, fp\09\09// marker for objc_retainAutoreleaseReturnValue"}
Index: llvm/test/Transforms/Inline/inline-retainRV-call.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/inline-retainRV-call.ll
@@ -0,0 +1,175 @@
+; RUN: opt < %s -inline -S | FileCheck %s
+
+@g0 = global i8* null, align 8
+declare i8* @foo0()
+
+define i8* @callee0_autoreleaseRV() {
+  %call = call "retainRV" i8* @foo0()
+  %1 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %call)
+  ret i8* %call
+}
+
+; CHECK-LABEL: define void @test0_autoreleaseRV(
+; CHECK: call "retainRV" i8* @foo0()
+
+define void @test0_autoreleaseRV() {
+  %call = call "retainRV" "rv_marker" i8* @callee0_autoreleaseRV()
+  ret void
+}
+
+; CHECK-LABEL: define void @test0

[PATCH] D92808: [ObjC][ARC] Annotate calls with attributes instead of emitting retainRV or claimRV calls in the IR

2020-12-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: clang/lib/CodeGen/CGObjC.cpp:2328
+  CGF.CGM.getTarget().getTriple().isAArch64() &&
+  !CGF.CGM.getTarget().getTriple().isOSWindows()) {
+auto *callBase = cast(value);

ahatanak wrote:
> rjmccall wrote:
> > compnerd wrote:
> > > Hmm, why the explicit check for not-Windows?
> > It would be good to explain why this is target-specific in a comment.
> I didn't really have a reason for limiting this to arm64 and non-windows OS 
> other than I didn't want to do too many things in the initial patch. I don't 
> think it would be hard to do this on x86-64. For windows, it looks like we'll 
> have to emit the markers and the ARC calls before CodeGen (before 
> WinEHPrepare) is run, but I haven't thought it through.
My understanding is that we'll have to do things differently in ARC contract on 
Windows, so for now, this patch disables this optimization on Windows.

Is the FIXME comment about Windows I added correct?.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92808/new/

https://reviews.llvm.org/D92808

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92846: [KernelAddressSanitizer] Fix globals exclusion for indirect aliases

2020-12-09 Thread Marco Elver via Phabricator via cfe-commits
melver added a comment.

In D92846#2442447 , @dvyukov wrote:

> The code looks reasonable to me. I see it only affects kernel, so assuming 
> you booted kernel, we should be fine.
> I can rubber-stamp it, but if you want more meaningful review, please wait 
> for Alex or Nick.

Added Nick.

I suppose all I'd like a 2nd confirmation on is if 
stripPointerCastsAndAliases() is the right thing to use here.

Nick or Alex, if you could have a brief look would be great -- thanks!

Thanks,

- Marco


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92846/new/

https://reviews.llvm.org/D92846

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92191: [clang-scan-deps] Add support for clang-cl

2020-12-09 Thread Sylvain Audi via Phabricator via cfe-commits
saudi added a comment.

Ping!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92191/new/

https://reviews.llvm.org/D92191

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92808: [ObjC][ARC] Annotate calls with attributes instead of emitting retainRV or claimRV calls in the IR

2020-12-09 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

There is nothing particularly special about that.  The reason for the funclet 
handling there is that in the case of an outlined block for exception handling 
(i.e. a funclet), we need to ensure that the assembly marker received the 
funclet token as failure to do so would mark the assembly as unreachable and 
would thus thwart the auto-release claim.  For the normal codepath, the 
behaviour should be identical.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92808/new/

https://reviews.llvm.org/D92808

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92936: [Sema] Fix deleted function problem in implicitly movable test

2020-12-09 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/lib/Sema/SemaStmt.cpp:3110
+///
+/// \returns Whether need to do the second overload resolution. If the first
+/// overload resolution fails, or if the first overload resolution success but

s/need/we need/



Comment at: clang/lib/Sema/SemaStmt.cpp:3111
+/// \returns Whether need to do the second overload resolution. If the first
+/// overload resolution fails, or if the first overload resolution success but
+/// the selected constructor/operator doesn't match the additional criteria, we

s/success/succeeds/



Comment at: clang/lib/Sema/SemaStmt.cpp:3212
   ExprResult Res = ExprError();
+  bool NeedSecondOverload = true;
 

Naming nit: I would prefer to call this "NeedSecondStep" or 
"NeedSecondOverloadResolution" or "NeedSecondResolution". The way it is now, it 
sounds like it's saying we need to find a second //overload//, which isn't 
really the intended meaning.



Comment at: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp:4
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -fcxx-exceptions 
-verify=cxx11_14_17 %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions 
-verify=cxx11_14_17 %s
+

The new behavior looks good to me (once the tests pass).
Why are there two different `-verify=` tags here, though? This behavior hasn't 
changed between C++11/14/17 and C++20.

(IIUC, the point of this patch is to fix the implementation divergence 
described in 
http://quuxplusone.github.io/draft/d2266-implicit-move-rvalue-ref.html#two-lookups
 , example `thirteen`.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92936/new/

https://reviews.llvm.org/D92936

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92944: Don't setup inalloca for swiftcc on i686-windows-msvc

2020-12-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: compnerd, rjmccall.
rnk requested review of this revision.
Herald added a project: clang.

Swiftcall does it's own target-independent argument type classification,
since it is not designed to be ABI compatible with anything local on the
target that isn't LLVM-based. This means it never uses inalloca.
However, we have duplicate logic for checking for inalloca parameters
that runs before call argument setup. This logic needs to know ahead of
time if inalloca will be used later, and we can't move the
CGFunctionInfo calculation earlier.

This change gets the calling convention from either the
FunctionProtoType or ObjCMethodDecl, checks if it is swift, and if so
skips the stackbase setup.

Depends on D92883 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92944

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenCXX/windows-x86-swiftcall.cpp

Index: clang/test/CodeGenCXX/windows-x86-swiftcall.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/windows-x86-swiftcall.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-windows -emit-llvm -target-cpu core2 -o - %s | FileCheck %s
+
+#define SWIFTCALL __attribute__((swiftcall))
+#define OUT __attribute__((swift_indirect_result))
+#define ERROR __attribute__((swift_error_result))
+#define CONTEXT __attribute__((swift_context))
+
+/*/
+/** PARAMETER ABIS ***/
+/*/
+
+// Swift doesn't use inalloca like windows x86 normally does.
+struct NonTrivial {
+  NonTrivial();
+  NonTrivial(const NonTrivial &);
+  int o;
+};
+
+SWIFTCALL int receiveNonTrivial(NonTrivial o) { return o.o; }
+
+// CHECK-LABEL: define dso_local swiftcc i32 @"?receiveNonTrivial@@YSHUNonTrivial@@@Z"(%struct.NonTrivial* %o)
+
+int passNonTrivial() {
+  return receiveNonTrivial({});
+}
+
+// CHECK-LABEL: define dso_local i32 @"?passNonTrivial@@YAHXZ"()
+// CHECK-NOT: stacksave
+// CHECK: call swiftcc i32 @"?receiveNonTrivial@@YSHUNonTrivial@@@Z"(%struct.NonTrivial* %{{.*}})
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -198,7 +198,8 @@
FTP);
 }
 
-static CallingConv getCallingConventionForDecl(const Decl *D, bool IsWindows) {
+static CallingConv getCallingConventionForDecl(const ObjCMethodDecl *D,
+   bool IsWindows) {
   // Set the appropriate calling convention for the Function.
   if (D->hasAttr())
 return CC_X86StdCall;
@@ -3818,6 +3819,24 @@
   EmitCheck(std::make_pair(Cond, CheckKind), Handler, StaticData, None);
 }
 
+// Check if the call is going to use the inalloca convention. This needs to
+// agree with CGFunctionInfo::usesInAlloca. The CGFunctionInfo is arranged
+// later, so we can't check it directly.
+static bool hasInAllocaArgs(CodeGenModule &CGM, CallingConv ExplicitCC,
+ArrayRef ArgTypes) {
+  // The Swift calling convention doesn't go through the target-specific
+  // argument classification, so it never uses inalloca.
+  // TODO: Consider limiting inalloca use to only calling conventions supported
+  // by MSVC.
+  if (ExplicitCC == CC_Swift)
+return false;
+  if (!CGM.getTarget().getCXXABI().isMicrosoft())
+return false;
+  return llvm::any_of(ArgTypes, [&](QualType Ty) {
+return isInAllocaArgument(CGM.getCXXABI(), Ty);
+  });
+}
+
 #ifndef NDEBUG
 // Determine whether the given argument is an Objective-C method
 // that may have type parameters in its signature.
@@ -3845,21 +3864,29 @@
   assert((ParamsToSkip == 0 || Prototype.P) &&
  "Can't skip parameters if type info is not provided");
 
-  // First, use the argument types that the type info knows about
+  // This variable only captures *explicitly* written conventions, not those
+  // applied by default via command line flags or target defaults, such as
+  // thiscall, aapcs, stdcall via -mrtd, etc. Computing that correctly would
+  // require knowing if this is a C++ instance method or being able to see
+  // unprototyped FunctionTypes.
+  CallingConv ExplicitCC = CC_C;
+
+  // First, if a prototype was provided, use those argument types.
   bool IsVariadic = false;
   if (Prototype.P) {
 const auto *MD = Prototype.P.dyn_cast();
 if (MD) {
   IsVariadic = MD->isVariadic();
-  for (QualType Ty : llvm::make_range(MD->param_type_begin() + ParamsToSkip,
-  MD->param_type_end()))
-ArgTypes.push_back(Ty);
+  ExplicitCC = getCallingConventionForDecl(
+  MD, CGM.getTarget().getTriple().isOSWindows());
+  ArgTypes.assign(MD-

[PATCH] D92915: [Driver] Add -f[no-]new-pass-manager to supersede -f[no-]experimental-new-pass-manager

2020-12-09 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks accepted this revision.
aeubanks added a comment.
This revision is now accepted and ready to land.

Makes sense to me, thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92915/new/

https://reviews.llvm.org/D92915

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92808: [ObjC][ARC] Annotate calls with attributes instead of emitting retainRV or claimRV calls in the IR

2020-12-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 310568.
ahatanak added a comment.

Fix an incorrect comment in insertRetainOrClaimRVCalls in InlineFunction.cpp.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92808/new/

https://reviews.llvm.org/D92808

Files:
  clang/lib/CodeGen/CGObjC.cpp
  clang/test/CodeGenObjC/arc-rv-attr.m
  clang/test/CodeGenObjC/arc-unsafeclaim.m
  llvm/include/llvm/Analysis/ObjCARCRVAttr.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/lib/IR/Instruction.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
  llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
  llvm/lib/Transforms/ObjCARC/ObjCARC.cpp
  llvm/lib/Transforms/ObjCARC/ObjCARC.h
  llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
  llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
  llvm/lib/Transforms/ObjCARC/PtrState.cpp
  llvm/lib/Transforms/ObjCARC/PtrState.h
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/test/Transforms/DeadArgElim/deadretval.ll
  llvm/test/Transforms/Inline/inline-retainRV-call.ll
  llvm/test/Transforms/ObjCARC/contract-rv-attr.ll
  llvm/test/Transforms/ObjCARC/rv.ll

Index: llvm/test/Transforms/ObjCARC/rv.ll
===
--- llvm/test/Transforms/ObjCARC/rv.ll
+++ llvm/test/Transforms/ObjCARC/rv.ll
@@ -452,6 +452,28 @@
   ret i8* %v3
 }
 
+; Remove attributes and the autoreleaseRV call if the call is a tail call.
+
+; CHECK-LABEL: define i8* @test31(
+; CHECK: %[[CALL:.*]] = tail call i8* @returner()
+; CHECK: ret i8* %[[CALL]]
+
+define i8* @test31() {
+  %call = tail call "retainRV" "rv_marker" i8* @returner()
+  %1 = call i8* @llvm.objc.autoreleaseReturnValue(i8* %call)
+  ret i8* %1
+}
+
+; CHECK-LABEL: define i8* @test32(
+; CHECK: %[[CALL:.*]] = call "retainRV" "rv_marker" i8* @returner()
+; CHECK: call i8* @llvm.objc.autoreleaseReturnValue(i8* %[[CALL]])
+
+define i8* @test32() {
+  %call = call "retainRV" "rv_marker" i8* @returner()
+  %1 = call i8* @llvm.objc.autoreleaseReturnValue(i8* %call)
+  ret i8* %1
+}
+
 !0 = !{}
 
 ; CHECK: attributes [[NUW]] = { nounwind }
Index: llvm/test/Transforms/ObjCARC/contract-rv-attr.ll
===
--- /dev/null
+++ llvm/test/Transforms/ObjCARC/contract-rv-attr.ll
@@ -0,0 +1,63 @@
+; RUN: opt -objc-arc-contract -S < %s | FileCheck %s
+; RUN: opt -passes=objc-arc-contract -S < %s | FileCheck %s
+
+; CHECK-LABEL: define void @test0() {
+; CHECK: %[[CALL:.*]] = notail call "rv_marker" i8* @foo()
+; CHECK: call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[CALL]])
+
+define void @test0() {
+  %call1 = call "retainRV" "rv_marker" i8* @foo()
+  ret void
+}
+
+; CHECK-LABEL: define void @test1() {
+; CHECK: %[[CALL:.*]] = notail call "rv_marker" i8* @foo()
+; CHECK: call i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8* %[[CALL]])
+
+define void @test1() {
+  %call1 = call "claimRV" "rv_marker" i8* @foo()
+  ret void
+}
+
+; CHECK-LABEL:define i8* @test2(
+; CHECK: %[[CALL1:.*]] = invoke "rv_marker" i8* @foo()
+
+; CHECK: %[[V0:.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[CALL1]])
+; CHECK-NEXT: br
+
+; CHECK: %[[CALL3:.*]] = invoke "rv_marker" i8* @foo()
+
+; CHECK: %[[V2:.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[CALL3]])
+; CHECK-NEXT: br
+
+; CHECK: %[[RETVAL:.*]] = phi i8* [ %[[V0]], {{.*}} ], [ %[[V2]], {{.*}} ]
+; CHECK: ret i8* %[[RETVAL]]
+
+define i8* @test2(i1 zeroext %b) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+entry:
+  br i1 %b, label %if.then, label %if.end
+
+if.then:
+  %call1 = invoke "retainRV" "rv_marker" i8* @foo()
+  to label %cleanup unwind label %lpad
+
+lpad:
+  %0 = landingpad { i8*, i32 }
+  cleanup
+  resume { i8*, i32 } undef
+
+if.end:
+  %call3 = invoke "retainRV" "rv_marker" i8* @foo()
+  to label %cleanup unwind label %lpad
+
+cleanup:
+  %retval.0 = phi i8* [ %call1, %if.then ], [ %call3, %if.end ]
+  ret i8* %retval.0
+}
+
+declare i8* @foo()
+declare i32 @__gxx_personality_v0(...)
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 1, !"clang.arc.retainAutoreleasedReturnValueMarker", !"mov\09fp, fp\09\09// marker for objc_retainAutoreleaseReturnValue"}
Index: llvm/test/Transforms/Inline/inline-retainRV-call.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/inline-retainRV-call.ll
@@ -0,0 +1,175 @@
+; RUN: opt < %s -inline -S | FileCheck %s
+
+@g0 = global i8* null, align 8
+declare i8* @foo0()
+
+define i8* @callee0_autoreleaseRV() {
+  %call = call "retainRV" i8* @foo0()
+  %1 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %call)
+  ret i8* %call
+}
+
+; CHECK-LABEL: define void @test0_autoreleaseRV(
+; CHECK: call "retainRV" i8* @foo0()
+
+define void @test0_autoreleaseRV() {
+  %call = call "retainRV" "rv_marker" i8* @callee0_autoreleaseRV()
+  ret void
+}
+
+; CHECK-LABEL: define 

[PATCH] D92883: De-templatify EmitCallArgs argument type checking, NFCI

2020-12-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk updated this revision to Diff 310569.
rnk added a comment.

- use assign instead of push_back


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92883/new/

https://reviews.llvm.org/D92883

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h

Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -4560,26 +4560,6 @@
Address Loc);
 
 public:
-#ifndef NDEBUG
-  // Determine whether the given argument is an Objective-C method
-  // that may have type parameters in its signature.
-  static bool isObjCMethodWithTypeParams(const ObjCMethodDecl *method) {
-const DeclContext *dc = method->getDeclContext();
-if (const ObjCInterfaceDecl *classDecl= dyn_cast(dc)) {
-  return classDecl->getTypeParamListAsWritten();
-}
-
-if (const ObjCCategoryDecl *catDecl = dyn_cast(dc)) {
-  return catDecl->getTypeParamList();
-}
-
-return false;
-  }
-
-  template
-  static bool isObjCMethodWithTypeParams(const T *) { return false; }
-#endif
-
   enum class EvaluationOrder {
 ///! No language constraints on evaluation order.
 Default,
@@ -4589,56 +4569,16 @@
 ForceRightToLeft
   };
 
-  /// EmitCallArgs - Emit call arguments for a function.
-  template 
-  void EmitCallArgs(CallArgList &Args, const T *CallArgTypeInfo,
-llvm::iterator_range ArgRange,
-AbstractCallee AC = AbstractCallee(),
-unsigned ParamsToSkip = 0,
-EvaluationOrder Order = EvaluationOrder::Default) {
-SmallVector ArgTypes;
-CallExpr::const_arg_iterator Arg = ArgRange.begin();
-
-assert((ParamsToSkip == 0 || CallArgTypeInfo) &&
-   "Can't skip parameters if type info is not provided");
-if (CallArgTypeInfo) {
-#ifndef NDEBUG
-  bool isGenericMethod = isObjCMethodWithTypeParams(CallArgTypeInfo);
-#endif
-
-  // First, use the argument types that the type info knows about
-  for (auto I = CallArgTypeInfo->param_type_begin() + ParamsToSkip,
-E = CallArgTypeInfo->param_type_end();
-   I != E; ++I, ++Arg) {
-assert(Arg != ArgRange.end() && "Running over edge of argument list!");
-assert((isGenericMethod ||
-((*I)->isVariablyModifiedType() ||
- (*I).getNonReferenceType()->isObjCRetainableType() ||
- getContext()
- .getCanonicalType((*I).getNonReferenceType())
- .getTypePtr() ==
- getContext()
- .getCanonicalType((*Arg)->getType())
- .getTypePtr())) &&
-   "type mismatch in call argument!");
-ArgTypes.push_back(*I);
-  }
-}
-
-// Either we've emitted all the call args, or we have a call to variadic
-// function.
-assert((Arg == ArgRange.end() || !CallArgTypeInfo ||
-CallArgTypeInfo->isVariadic()) &&
-   "Extra arguments in non-variadic function!");
-
-// If we still have any arguments, emit them using the type of the argument.
-for (auto *A : llvm::make_range(Arg, ArgRange.end()))
-  ArgTypes.push_back(CallArgTypeInfo ? getVarArgType(A) : A->getType());
+  // Wrapper for function prototype sources. Wraps either a FunctionProtoType or
+  // an ObjCMethodDecl.
+  struct PrototypeWrapper {
+llvm::PointerUnion P;
 
-EmitCallArgs(Args, ArgTypes, ArgRange, AC, ParamsToSkip, Order);
-  }
+PrototypeWrapper(const FunctionProtoType *FT) : P(FT) {}
+PrototypeWrapper(const ObjCMethodDecl *MD) : P(MD) {}
+  };
 
-  void EmitCallArgs(CallArgList &Args, ArrayRef ArgTypes,
+  void EmitCallArgs(CallArgList &Args, PrototypeWrapper Prototype,
 llvm::iterator_range ArgRange,
 AbstractCallee AC = AbstractCallee(),
 unsigned ParamsToSkip = 0,
Index: clang/lib/CodeGen/CGExprCXX.cpp
===
--- clang/lib/CodeGen/CGExprCXX.cpp
+++ clang/lib/CodeGen/CGExprCXX.cpp
@@ -1329,7 +1329,7 @@
  const CallExpr *TheCall,
  bool IsDelete) {
   CallArgList Args;
-  EmitCallArgs(Args, Type->getParamTypes(), TheCall->arguments());
+  EmitCallArgs(Args, Type, TheCall->arguments());
   // Find the allocation or deallocation function that we're calling.
   ASTContext &Ctx = getContext();
   DeclarationName Name = Ctx.DeclarationNames
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3818,13 +3818,79 @@
   EmitCheck(std::make_pair(Cond, CheckKind), Handler, St

[PATCH] D92663: [clangd] Add hot-reload of compile_commands.json and compile_flags.txt

2020-12-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 7 inline comments as done.
sammccall added a comment.

Thanks for the review!

> my biggest question is, have we considered updating CompilationDatabasePlugin 
> interface to provide a loadFromBuffer and relativeFileName virtual methods. I 
> think loading logic could've been a lot simpler and more uniform that way.

I thought about it, not sure if we discussed it. TL;DR: I feel like we can do a 
good job of the concrete cases, but don't feel ready to generalize.

It's a larger, complicated design problem and the costs of getting it wrong 
(either making it too limiting *or* too flexible) are much higher than the 
benefits we'd get here. Apart from JSON/Fixed CDBs, we know there are 
downstream CDBs and this is a key extension point. What assumptions should we 
bake in?

- CDB state is derived from a single file with known path?
- CDBs should be thrown away and reloaded, rather than updated, when data 
changes?
- CDBs are not invalidated by any other events?

I like the idea of extending the interface at some point. But I'm not sure the 
model from this patch is the right one to codify.

Meanwhile, most clang tools are batch, so the audience for this is... clangd 
and ccls? I don't think it's a pressing need.




Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:205
+  auto Stat = FS.status(Path);
+  if (!Stat || !Stat->isRegularFile()) {
+Size = NoFileCached;

kadircet wrote:
> what about symlinks ? i think users usually have `cc.json -> 
> obscure_build_dir/cc.json` as a symlink.
`RealFileSystem::status()` is `stat()` rather than `lstat()` (it uses the 
default `follow=true` for `sys::fs::status`) so it will follow symlinks and 
report "regular file".



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:322
+auto Plugin = Entry.instantiate();
+if (auto CDB = Plugin->loadFromDirectory(Path, Error)) {
+  log("Loaded compilation database from {0} with plugin {1}", Path,

kadircet wrote:
> it is not crucial but we used to try to load these from `Path + "/build"` as 
> well
Yeah, this is on purpose, I think it's better only to do this for 
compile_commands.json. Now that we're periodically stat'ing we should think a 
little about how many files are necessary.

The build/ heuristic is basically targetting the "standard cmake setup" which 
is always compile_commands.json.

I think it's unlikely this is a significant regression for anyone. In a 
standard build it only affects build/compile_flags.txt which AFAIK is always 
hand-authored, and I'd expect authors to put it in the project root (we never 
documented the build/ behavior, and other clang tools don't have it).

FWIW, the old implementation looked in `build/` for all plugins only because I 
wanted to stick to the high-level API rather than piercing the abstraction.

---

As an aside, I am slightly worried this hot-reload feature will make us wary of 
supporting more build systems that require more IO, because both more periodic 
stats and having some CDBs only scanned once would be unpalatable options.

Still, given how dominant compile_commands.json is today, we can't let the 
extensibility argument get in the way of an important feature like this.



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:456
 CDBLookupResult Result) const {
+  vlog("Broadcasting compilation database from {0}", Result.PI.SourceRoot);
   assert(Result.CDB && "Trying to broadcast an invalid CDB!");

kadircet wrote:
> why not `log` instead of `vlog`? this shouldn't be too noisy anyway.
Basically because "broacdasting" per se isn't meaningful to users.
This log line is going to be sandwiched between "Loaded compilation database 
from {0}" and "Enqueueing {0} commands for indexing", which tell them what they 
need to know.

I'm not sure it adds much, and maybe we should just remove it entirely? (But as 
a developer I do find it a nice reminder of what the flow is)



Comment at: 
clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp:393
+
+auto HasFlag(llvm::StringRef Flag) { return HasFlag(Flag, "dummy.cc"); }
+

kadircet wrote:
> nit: maybe a `MATCHER_P` instead ?
Well, I find functions easier to reason about than the MATCHER_P factories...

Here it's pretty ugly: if we want to delegate to the two-arg version from the 
body, we have to pass through the result_listener, so something like
```
MATCHER_P(HasFlag, Flag, "") {
  return HasFlag(Flag, "dummy.cc").MatchAndExplain(arg, result_listener);
}
```

however the MATCHER_P macros produce *polymorphic* matchers (which is why we 
don't need to provide the arg type), so we need something more like

```
return Matcher(HasFlag(Flag, "dummy.cc")).MatchAndExplain(arg, 
result_listener);
```

(Not sure if that's quite right)
I don't think that does a great job of communicating "this is the same HasFlag 
matche

[PATCH] D92439: [CLANG] Fix missing error for use of 128-bit integer inside SPIR64 device code.

2020-12-09 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 closed this revision.
jyu2 added a comment.

commit by rGf8d5b49c786f 
: Fix 
missing error for use of 128-bit integer inside SPIR64 device code.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92439/new/

https://reviews.llvm.org/D92439

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92663: [clangd] Add hot-reload of compile_commands.json and compile_flags.txt

2020-12-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 310574.
sammccall marked an inline comment as done.
sammccall added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92663/new/

https://reviews.llvm.org/D92663

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.h
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp

Index: clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -11,8 +11,10 @@
 #include "Matchers.h"
 #include "TestFS.h"
 #include "support/Path.h"
+#include "support/ThreadsafeFS.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
@@ -23,6 +25,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 #include 
 #include 
 
@@ -40,7 +43,8 @@
 using ::testing::UnorderedElementsAre;
 
 TEST(GlobalCompilationDatabaseTest, FallbackCommand) {
-  DirectoryBasedGlobalCompilationDatabase DB(None);
+  MockFS TFS;
+  DirectoryBasedGlobalCompilationDatabase DB(TFS);
   auto Cmd = DB.getFallbackCommand(testPath("foo/bar.cc"));
   EXPECT_EQ(Cmd.Directory, testPath("foo"));
   EXPECT_THAT(Cmd.CommandLine, ElementsAre("clang", testPath("foo/bar.cc")));
@@ -166,6 +170,7 @@
 }
 
 // Allows placement of files for tests and cleans them up after.
+// FIXME: GlobalCompilationDatabase is mostly VFS-clean now, switch to MockFS?
 class ScratchFS {
   llvm::SmallString<128> Root;
 
@@ -238,13 +243,14 @@
   ]
   )cdb";
   ScratchFS FS;
+  RealThreadsafeFS TFS;
   FS.write("compile_commands.json", CDBOuter);
   FS.write("build/compile_commands.json", CDBInner);
 
   // Note that gen2.cc goes missing with our following model, not sure this
   // happens in practice though.
   {
-DirectoryBasedGlobalCompilationDatabase DB(llvm::None);
+DirectoryBasedGlobalCompilationDatabase DB(TFS);
 std::vector DiscoveredFiles;
 auto Sub =
 DB.watch([&DiscoveredFiles](const std::vector Changes) {
@@ -262,7 +268,9 @@
 
   // With a custom compile commands dir.
   {
-DirectoryBasedGlobalCompilationDatabase DB(FS.root().str());
+DirectoryBasedGlobalCompilationDatabase::Options Opts(TFS);
+Opts.CompileCommandsDir = FS.root().str();
+DirectoryBasedGlobalCompilationDatabase DB(Opts);
 std::vector DiscoveredFiles;
 auto Sub =
 DB.watch([&DiscoveredFiles](const std::vector Changes) {
@@ -282,17 +290,34 @@
 
 TEST(GlobalCompilationDatabaseTest, BuildDir) {
   ScratchFS FS;
+  RealThreadsafeFS TFS;
   auto Command = [&](llvm::StringRef Relative) {
-return DirectoryBasedGlobalCompilationDatabase(llvm::None)
+DirectoryBasedGlobalCompilationDatabase::Options Opts(TFS);
+return DirectoryBasedGlobalCompilationDatabase(Opts)
 .getCompileCommand(FS.path(Relative))
 .getValueOr(tooling::CompileCommand())
 .CommandLine;
   };
   EXPECT_THAT(Command("x/foo.cc"), IsEmpty());
-  FS.write("x/build/compile_flags.txt", "-DXYZZY");
+  const char *const CDB =
+  R"cdb(
+  [
+{
+  "file": "{0}/x/foo.cc",
+  "command": "clang -DXYZZY {0}/x/foo.cc",
+  "directory": "{0}",
+},
+{
+  "file": "{0}/bar.cc",
+  "command": "clang -DXYZZY {0}/bar.cc",
+  "directory": "{0}",
+}
+  ]
+  )cdb";
+  FS.write("x/build/compile_commands.json", CDB);
   EXPECT_THAT(Command("x/foo.cc"), Contains("-DXYZZY"));
   EXPECT_THAT(Command("bar.cc"), IsEmpty())
-  << "x/build/compile_flags.txt only applicable to x/";
+  << "x/build/compile_flags.json only applicable to x/";
 }
 
 TEST(GlobalCompilationDatabaseTest, NonCanonicalFilenames) {
@@ -330,5 +355,89 @@
   EXPECT_EQ(DB.getProjectInfo(Header)->SourceRoot, testRoot());
 }
 } // namespace
+
+// Friend test has access to internals.
+class DirectoryBasedGlobalCompilationDatabaseCacheTest
+: public ::testing::Test {
+protected:
+  std::shared_ptr
+  lookupCDB(const DirectoryBasedGlobalCompilationDatabase &GDB,
+llvm::StringRef Path,
+std::chrono::steady_clock::time_point FreshTime) {
+DirectoryBasedGlobalCompilationDatabase::CDBLookupRequest Req;
+Req.FileName = Path;
+Req.FreshTime = Req.FreshTimeMissing = FreshTime;
+if (auto Result = GDB.lookupCDB(Req))
+  return std::move(Result->CDB);
+return nullptr;
+  }
+};
+
+// Matches non-null CDBs which include the specified flag.
+MATCHER_P2(HasFlag, Flag, P

[PATCH] D92432: [analyzer] Add a thin abstraction layer between libCrossTU and libAnalysis.

2020-12-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/include/clang/CrossTU/CrossTranslationUnit.h:124
 /// Note that this class also implements caching.
-class CrossTranslationUnitContext {
+class CrossTranslationUnitContext : public CrossTUAnalysisHelper {
 public:

steakhal wrote:
> martong wrote:
> > Why don't we have a dependency in libCrossTU to libAnalysis? In the 
> > CMakeLists.txt?
> > Here we implement the CrossTUAnalysisHelper's abstract virtual function 
> > thus we include the `CrossTUAnalysisHelper.h`. But 
> > CMake should know about the dependency even if this is only a header only 
> > dependency, shouldn't it? (We were talking about this with @steakhal.)
> IMO if a library (A) does not depend on another library (B), that means we 
> can safely delete all files of the **B** and still be able to compile and run 
> the **A**.
> In this case, it won't, as the given header lives under **B**. So to make 
> sure this principle works, we should state the dependency on **B** in **A**.
> 
> ---
> In our case, it means that **libCrossTU** depends on **libAnalysis**, as the 
> `CrossTUAnalysisHelper` lives in `libAnalysis` which is used by `libCrossTU` 
> to implement the `CrossTranslationUnitContext`.
There's already an indirect dependency (you have to look at all those 
CMakeLists.txt in order to notice it): libCrossTU -> libFrontend -> libSema -> 
libAnalysis (and a few other paths through the dependency graph). There's no 
harm in writing it down explicitly but there's also no explicit need and i'd 
rather have it not specified directly (if there's too little dependencies it'll 
warn us) than to specify too much by accident (there's no warning for unused 
dependencies and if a dependency eventually becomes unused it may accidentally 
prevent people from adding the dependencies they actually need).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92432/new/

https://reviews.llvm.org/D92432

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92661: [RFC] Fix TLS and Coroutine

2020-12-09 Thread Xun Li via Phabricator via cfe-commits
lxfind updated this revision to Diff 310575.
lxfind added a comment.
Herald added subscribers: nikic, kerbowa, jvesely.

Fix all failing tests


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92661/new/

https://reviews.llvm.org/D92661

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGen/lto-newpm-pipeline.c
  clang/test/CodeGenCXX/cxx2a-thread-local-constinit.cpp
  clang/test/CodeGenCoroutines/coro-tls.cpp
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/Scalar.h
  llvm/include/llvm/Transforms/Scalar/LowerThreadLocalIntrinsic.h
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/Scalar/CMakeLists.txt
  llvm/lib/Transforms/Scalar/LowerThreadLocalIntrinsic.cpp
  llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-O0-defaults.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  llvm/test/Other/pass-pipelines.ll

Index: llvm/test/Other/pass-pipelines.ll
===
--- llvm/test/Other/pass-pipelines.ll
+++ llvm/test/Other/pass-pipelines.ll
@@ -72,6 +72,7 @@
 ; Next we break out of the main Function passes inside the CGSCC pipeline with
 ; a barrier pass.
 ; CHECK-O2: A No-Op Barrier Pass
+; CHECK-O2-NEXT: Lower ThreadLocal Intrinsics
 ; CHECK-O2-NEXT: Eliminate Available Externally
 ; Inferring function attribute should be right after the CGSCC pipeline, before
 ; any other optimizations/analyses.
Index: llvm/test/Other/opt-Os-pipeline.ll
===
--- llvm/test/Other/opt-Os-pipeline.ll
+++ llvm/test/Other/opt-Os-pipeline.ll
@@ -173,6 +173,7 @@
 ; CHECK-NEXT: Optimization Remark Emitter
 ; CHECK-NEXT: Combine redundant instructions
 ; CHECK-NEXT: A No-Op Barrier Pass
+; CHECK-NEXT: Lower ThreadLocal Intrinsics
 ; CHECK-NEXT: Eliminate Available Externally Globals
 ; CHECK-NEXT: CallGraph Construction
 ; CHECK-NEXT: Deduce function attributes in RPO
Index: llvm/test/Other/opt-O3-pipeline.ll
===
--- llvm/test/Other/opt-O3-pipeline.ll
+++ llvm/test/Other/opt-O3-pipeline.ll
@@ -192,6 +192,7 @@
 ; CHECK-NEXT: Optimization Remark Emitter
 ; CHECK-NEXT: Combine redundant instructions
 ; CHECK-NEXT: A No-Op Barrier Pass
+; CHECK-NEXT: Lower ThreadLocal Intrinsics
 ; CHECK-NEXT: Eliminate Available Externally Globals
 ; CHECK-NEXT: CallGraph Construction
 ; CHECK-NEXT: Deduce function attributes in RPO
Index: llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
===
--- llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
+++ llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
@@ -192,6 +192,7 @@
 ; CHECK-NEXT: Optimization Remark Emitter
 ; CHECK-NEXT: Combine redundant instructions
 ; CHECK-NEXT: A No-Op Barrier Pass
+; CHECK-NEXT: Lower ThreadLocal Intrinsics
 ; CHECK-NEXT: Eliminate Available Externally Globals
 ; CHECK-NEXT: CallGraph Construction
 ; CHECK-NEXT: Deduce function attributes in RPO
Index: llvm/test/Other/opt-O2-pipeline.ll
===
--- llvm/test/Other/opt-O2-pipeline.ll
+++ llvm/test/Other/opt-O2-pipeline.ll
@@ -187,6 +187,7 @@
 ; CHECK-NEXT: Optimization Remark Emitter
 ; CHECK-NEXT: Combine redundant instructions
 ; CHECK-NEXT: A No-Op Barrier Pass
+; CHECK-NEXT: Lower ThreadLocal Intrinsics
 ; CHECK-NEXT: Eliminate Available Externally Globals
 ; CHECK-NEXT: CallGraph Construction
 ; CHECK-NEXT: Deduce function attributes in RPO
Index: llvm/test/Other/new-pm-defaults.ll
===
--- llvm/test/Other/new-pm-defaults.ll
+++ llvm/test/Other/new-pm-defaults.ll
@@ -209,6 +209,7 @@
 ; CHECK-EP-CGSCC-LATE-NEXT: Running pass: NoOpCGSCCPass
 ; CHECK-O-NEXT: Finished CGSCC pass manager run.
 ; CHECK-O-NEXT: Finished llvm::Module pass manager run.
+; CHECK-O-NEXT: Running pass: LowerThreadLocalIntrinsicPass
 ; CHECK-O-NEXT: Running pass: GlobalOptPass
 ; CHECK-O-NEXT: Running pass: GlobalDCEPass
 ; CHECK-DEFAULT-NEXT: Running pass: EliminateAvailableExternallyPass
Index: llvm/test/Other/new-pm-O0-defaults.ll
===
--- llvm/test/Other/new-pm-O0-defaults.ll
+++ llvm/test/Other/new-pm-O0-defaults.ll
@@ -32,6 +32,7 @@
 ; CHECK-DEFAULT-NEXT: Running analysis: ProfileSummaryAnalysis
 ; CHECK-MATRIX-NEXT: Running

[PATCH] D92857: [clang][cli] Don't always emit -f[no-]experimental-new-pass-manager

2020-12-09 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

LGTM. I don't see any reason to always emit this option.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92857/new/

https://reviews.llvm.org/D92857

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92886: [Sema] Warn about unused functions even when they're inline

2020-12-09 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D92886#2441290 , @Quuxplusone wrote:

> I agree with your reasoning, but in practice I still see a lot of people 
> using `static inline` for functions (especially function templates) in .h 
> files.

That's also what I was seeing, and then I wondered why our warnings don't catch 
this.

> I'm not sure exactly why — maybe to reduce the burden on the linker, which 
> would otherwise have to make sure all the symbols had the same address, 
> whereas with `static` it doesn't have to worry about that?

I don't think it helps, but perhaps I'm missing something. There are 
essentially two cases:

- The function is inlined everywhere. Then it's going to be pruned from the 
object file (because inline functions need to have a definition in all 
translation units where they're odr-used or something like that), and the 
linker will never see it.
- The function is not inlined everywhere, so it will be emitted. Then you're 
right that the linker doesn't have to merge the emitted functions, but that 
might actually make linking slower, because relocations and so on have to be 
done for every copy.

My theory is that especially in OOP-heavy code bases programmers develop a 
habit of thinking in class scope, where `static` has a completely different 
meaning. At least that's my impression from our code base.

> Have you run this patch over Clang's own codebase, and over libc++? How many 
> positives are there, and do they fall into any thought-provoking patterns?

That's likely a good idea, I will try to run over some code bases.

In D92886#2441410 , @efriedma wrote:

> There's a long history of defining utility functions in headers as "static 
> inline".

Indeed, I wouldn't want to warn about something that never happens anyway.

> Non-static inline functions in C have confusing semantics.

I'm not terribly familiar with C, but judging from C11 6.7.4 it seems that C is 
a bit more permissive, but then says that certain things are 
implementation-defined. Whereas in C++ it's forbidden by the one-definition 
rule that an inline function has another external definition, it's allowed in C 
but implementation-defined which variant is called.

So if you do non-static inline functions like you'd do them in C++, I think you 
should be fine. But perhaps I'm missing something, in that case feel free to 
give me a pointer.

> The warning is designed to be compatible with that reality: it allows people 
> to define "static inline" functions, and still get warnings about other 
> functions that might be unused unintentionally.  I don't think the warning is 
> realistically usable if it doesn't allow "static inline" functions in headers.

Though it does warn about static non-inline functions, and at least for C++ 
that has the same effect as "static inline" (perhaps even for C). It would be 
strange if the warning would hinge on a keyword that doesn't actually change 
anything in that case, and it would suggest to developers that it's a 
meaningful change.

> Have you tried to see what the practical impact of this change is on 
> real-world codebases?

I'd expect a lot of warnings on our code base at least. We have a bit of a 
problem with binary sizes, and I think part of that is our usage of internal 
linkage in header files. (I'm not talking about sure-to-be-inlined functions, 
but rather templates or functions that shouldn't be in a header.)

Perhaps this is a different issue though, and the proper fix is rather to 
suppress `unused-*` warnings in headers entirely and have a different warning 
about using internal linkage in header files.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92886/new/

https://reviews.llvm.org/D92886

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92432: [analyzer] Add a thin abstraction layer between libCrossTU and libAnalysis.

2020-12-09 Thread BalƔzs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/include/clang/CrossTU/CrossTranslationUnit.h:124
 /// Note that this class also implements caching.
-class CrossTranslationUnitContext {
+class CrossTranslationUnitContext : public CrossTUAnalysisHelper {
 public:

NoQ wrote:
> steakhal wrote:
> > martong wrote:
> > > Why don't we have a dependency in libCrossTU to libAnalysis? In the 
> > > CMakeLists.txt?
> > > Here we implement the CrossTUAnalysisHelper's abstract virtual function 
> > > thus we include the `CrossTUAnalysisHelper.h`. But 
> > > CMake should know about the dependency even if this is only a header only 
> > > dependency, shouldn't it? (We were talking about this with @steakhal.)
> > IMO if a library (A) does not depend on another library (B), that means we 
> > can safely delete all files of the **B** and still be able to compile and 
> > run the **A**.
> > In this case, it won't, as the given header lives under **B**. So to make 
> > sure this principle works, we should state the dependency on **B** in **A**.
> > 
> > ---
> > In our case, it means that **libCrossTU** depends on **libAnalysis**, as 
> > the `CrossTUAnalysisHelper` lives in `libAnalysis` which is used by 
> > `libCrossTU` to implement the `CrossTranslationUnitContext`.
> There's already an indirect dependency (you have to look at all those 
> CMakeLists.txt in order to notice it): libCrossTU -> libFrontend -> libSema 
> -> libAnalysis (and a few other paths through the dependency graph). There's 
> no harm in writing it down explicitly but there's also no explicit need and 
> i'd rather have it not specified directly (if there's too little dependencies 
> it'll warn us) than to specify too much by accident (there's no warning for 
> unused dependencies and if a dependency eventually becomes unused it may 
> accidentally prevent people from adding the dependencies they actually need).
Thank you for the explanation.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92432/new/

https://reviews.llvm.org/D92432

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91673: [PGO] Enable preinline and cleanup when optimize for size

2020-12-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I see two pre-commit test failures on the patch. Can you take a look at those 
as well?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91673/new/

https://reviews.llvm.org/D91673

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d7098ff - De-templatify EmitCallArgs argument type checking, NFCI

2020-12-09 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-12-09T11:08:00-08:00
New Revision: d7098ff29c58dd08ede8314818b7de7fd2fea4cc

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

LOG: De-templatify EmitCallArgs argument type checking, NFCI

This template exists to abstract over FunctionPrototype and
ObjCMethodDecl, which have similar APIs for storing parameter types. In
place of a template, use a PointerUnion with two cases to handle this.
Hopefully this improves readability, since the type of the prototype is
easier to discover. This allows me to sink this code, which is mostly
assertions, out of the header file and into the cpp file. I can also
simplify the overloaded methods for computing isGenericMethod, and get
rid of the second EmitCallArgs overload.

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

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGExprCXX.cpp
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 2b9bfb6a6c88..83903af55ab3 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3818,13 +3818,79 @@ void CodeGenFunction::EmitNonNullArgCheck(RValue RV, 
QualType ArgType,
   EmitCheck(std::make_pair(Cond, CheckKind), Handler, StaticData, None);
 }
 
+#ifndef NDEBUG
+// Determine whether the given argument is an Objective-C method
+// that may have type parameters in its signature.
+static bool isObjCMethodWithTypeParams(const ObjCMethodDecl *method) {
+  const DeclContext *dc = method->getDeclContext();
+  if (const ObjCInterfaceDecl *classDecl = dyn_cast(dc)) {
+return classDecl->getTypeParamListAsWritten();
+  }
+
+  if (const ObjCCategoryDecl *catDecl = dyn_cast(dc)) {
+return catDecl->getTypeParamList();
+  }
+
+  return false;
+}
+#endif
+
+/// EmitCallArgs - Emit call arguments for a function.
 void CodeGenFunction::EmitCallArgs(
-CallArgList &Args, ArrayRef ArgTypes,
+CallArgList &Args, PrototypeWrapper Prototype,
 llvm::iterator_range ArgRange,
 AbstractCallee AC, unsigned ParamsToSkip, EvaluationOrder Order) {
+  SmallVector ArgTypes;
+
+  assert((ParamsToSkip == 0 || Prototype.P) &&
+ "Can't skip parameters if type info is not provided");
+
+  // First, use the argument types that the type info knows about
+  bool IsVariadic = false;
+  if (Prototype.P) {
+const auto *MD = Prototype.P.dyn_cast();
+if (MD) {
+  IsVariadic = MD->isVariadic();
+  ArgTypes.assign(MD->param_type_begin() + ParamsToSkip,
+  MD->param_type_end());
+} else {
+  const auto *FPT = Prototype.P.get();
+  IsVariadic = FPT->isVariadic();
+  ArgTypes.assign(FPT->param_type_begin() + ParamsToSkip,
+  FPT->param_type_end());
+}
+
+#ifndef NDEBUG
+// Check that the prototyped types match the argument expression types.
+bool isGenericMethod = MD && isObjCMethodWithTypeParams(MD);
+CallExpr::const_arg_iterator Arg = ArgRange.begin();
+for (QualType Ty : ArgTypes) {
+  assert(Arg != ArgRange.end() && "Running over edge of argument list!");
+  assert(
+  (isGenericMethod || Ty->isVariablyModifiedType() ||
+   Ty.getNonReferenceType()->isObjCRetainableType() ||
+   getContext()
+   .getCanonicalType(Ty.getNonReferenceType())
+   .getTypePtr() ==
+   getContext().getCanonicalType((*Arg)->getType()).getTypePtr()) 
&&
+  "type mismatch in call argument!");
+  ++Arg;
+}
+
+// Either we've emitted all the call args, or we have a call to variadic
+// function.
+assert((Arg == ArgRange.end() || IsVariadic) &&
+   "Extra arguments in non-variadic function!");
+#endif
+  }
+
+  // If we still have any arguments, emit them using the type of the argument.
+  for (auto *A : llvm::make_range(std::next(ArgRange.begin(), ArgTypes.size()),
+  ArgRange.end()))
+ArgTypes.push_back(IsVariadic ? getVarArgType(A) : A->getType());
   assert((int)ArgTypes.size() == (ArgRange.end() - ArgRange.begin()));
 
-  // We *have* to evaluate arguments from right to left in the MS C++ ABI,
+  // We must evaluate arguments from right to left in the MS C++ ABI,
   // because arguments are destroyed left to right in the callee. As a special
   // case, there are certain language constructs that require left-to-right
   // evaluation, and in those cases we consider the evaluation order 
requirement

diff  --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index c8b059fd7db0..e1907a6f0680 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -1329,7 +1329,7 @@ RValue CodeGenFunction::EmitBuil

[PATCH] D92883: De-templatify EmitCallArgs argument type checking, NFCI

2020-12-09 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd7098ff29c58: De-templatify EmitCallArgs argument type 
checking, NFCI (authored by rnk).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92883/new/

https://reviews.llvm.org/D92883

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h

Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -4560,26 +4560,6 @@
Address Loc);
 
 public:
-#ifndef NDEBUG
-  // Determine whether the given argument is an Objective-C method
-  // that may have type parameters in its signature.
-  static bool isObjCMethodWithTypeParams(const ObjCMethodDecl *method) {
-const DeclContext *dc = method->getDeclContext();
-if (const ObjCInterfaceDecl *classDecl= dyn_cast(dc)) {
-  return classDecl->getTypeParamListAsWritten();
-}
-
-if (const ObjCCategoryDecl *catDecl = dyn_cast(dc)) {
-  return catDecl->getTypeParamList();
-}
-
-return false;
-  }
-
-  template
-  static bool isObjCMethodWithTypeParams(const T *) { return false; }
-#endif
-
   enum class EvaluationOrder {
 ///! No language constraints on evaluation order.
 Default,
@@ -4589,56 +4569,16 @@
 ForceRightToLeft
   };
 
-  /// EmitCallArgs - Emit call arguments for a function.
-  template 
-  void EmitCallArgs(CallArgList &Args, const T *CallArgTypeInfo,
-llvm::iterator_range ArgRange,
-AbstractCallee AC = AbstractCallee(),
-unsigned ParamsToSkip = 0,
-EvaluationOrder Order = EvaluationOrder::Default) {
-SmallVector ArgTypes;
-CallExpr::const_arg_iterator Arg = ArgRange.begin();
-
-assert((ParamsToSkip == 0 || CallArgTypeInfo) &&
-   "Can't skip parameters if type info is not provided");
-if (CallArgTypeInfo) {
-#ifndef NDEBUG
-  bool isGenericMethod = isObjCMethodWithTypeParams(CallArgTypeInfo);
-#endif
-
-  // First, use the argument types that the type info knows about
-  for (auto I = CallArgTypeInfo->param_type_begin() + ParamsToSkip,
-E = CallArgTypeInfo->param_type_end();
-   I != E; ++I, ++Arg) {
-assert(Arg != ArgRange.end() && "Running over edge of argument list!");
-assert((isGenericMethod ||
-((*I)->isVariablyModifiedType() ||
- (*I).getNonReferenceType()->isObjCRetainableType() ||
- getContext()
- .getCanonicalType((*I).getNonReferenceType())
- .getTypePtr() ==
- getContext()
- .getCanonicalType((*Arg)->getType())
- .getTypePtr())) &&
-   "type mismatch in call argument!");
-ArgTypes.push_back(*I);
-  }
-}
-
-// Either we've emitted all the call args, or we have a call to variadic
-// function.
-assert((Arg == ArgRange.end() || !CallArgTypeInfo ||
-CallArgTypeInfo->isVariadic()) &&
-   "Extra arguments in non-variadic function!");
-
-// If we still have any arguments, emit them using the type of the argument.
-for (auto *A : llvm::make_range(Arg, ArgRange.end()))
-  ArgTypes.push_back(CallArgTypeInfo ? getVarArgType(A) : A->getType());
+  // Wrapper for function prototype sources. Wraps either a FunctionProtoType or
+  // an ObjCMethodDecl.
+  struct PrototypeWrapper {
+llvm::PointerUnion P;
 
-EmitCallArgs(Args, ArgTypes, ArgRange, AC, ParamsToSkip, Order);
-  }
+PrototypeWrapper(const FunctionProtoType *FT) : P(FT) {}
+PrototypeWrapper(const ObjCMethodDecl *MD) : P(MD) {}
+  };
 
-  void EmitCallArgs(CallArgList &Args, ArrayRef ArgTypes,
+  void EmitCallArgs(CallArgList &Args, PrototypeWrapper Prototype,
 llvm::iterator_range ArgRange,
 AbstractCallee AC = AbstractCallee(),
 unsigned ParamsToSkip = 0,
Index: clang/lib/CodeGen/CGExprCXX.cpp
===
--- clang/lib/CodeGen/CGExprCXX.cpp
+++ clang/lib/CodeGen/CGExprCXX.cpp
@@ -1329,7 +1329,7 @@
  const CallExpr *TheCall,
  bool IsDelete) {
   CallArgList Args;
-  EmitCallArgs(Args, Type->getParamTypes(), TheCall->arguments());
+  EmitCallArgs(Args, Type, TheCall->arguments());
   // Find the allocation or deallocation function that we're calling.
   ASTContext &Ctx = getContext();
   DeclarationName Name = Ctx.DeclarationNames
Index: clang/lib/CodeGen/CGCall.cpp
===
--- cla

[clang] df28221 - Don't setup inalloca for swiftcc on i686-windows-msvc

2020-12-09 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-12-09T11:08:48-08:00
New Revision: df282215d497e15104ae9e182e083cdfa0bae3c2

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

LOG: Don't setup inalloca for swiftcc on i686-windows-msvc

Swiftcall does it's own target-independent argument type classification,
since it is not designed to be ABI compatible with anything local on the
target that isn't LLVM-based. This means it never uses inalloca.
However, we have duplicate logic for checking for inalloca parameters
that runs before call argument setup. This logic needs to know ahead of
time if inalloca will be used later, and we can't move the
CGFunctionInfo calculation earlier.

This change gets the calling convention from either the
FunctionProtoType or ObjCMethodDecl, checks if it is swift, and if so
skips the stackbase setup.

Depends on D92883.

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

Added: 
clang/test/CodeGenCXX/windows-x86-swiftcall.cpp

Modified: 
clang/lib/CodeGen/CGCall.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 83903af55ab3..5db34b693bf3 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -198,7 +198,8 @@ 
CodeGenTypes::arrangeFreeFunctionType(CanQual FTP) {
FTP);
 }
 
-static CallingConv getCallingConventionForDecl(const Decl *D, bool IsWindows) {
+static CallingConv getCallingConventionForDecl(const ObjCMethodDecl *D,
+   bool IsWindows) {
   // Set the appropriate calling convention for the Function.
   if (D->hasAttr())
 return CC_X86StdCall;
@@ -3818,6 +3819,24 @@ void CodeGenFunction::EmitNonNullArgCheck(RValue RV, 
QualType ArgType,
   EmitCheck(std::make_pair(Cond, CheckKind), Handler, StaticData, None);
 }
 
+// Check if the call is going to use the inalloca convention. This needs to
+// agree with CGFunctionInfo::usesInAlloca. The CGFunctionInfo is arranged
+// later, so we can't check it directly.
+static bool hasInAllocaArgs(CodeGenModule &CGM, CallingConv ExplicitCC,
+ArrayRef ArgTypes) {
+  // The Swift calling convention doesn't go through the target-specific
+  // argument classification, so it never uses inalloca.
+  // TODO: Consider limiting inalloca use to only calling conventions supported
+  // by MSVC.
+  if (ExplicitCC == CC_Swift)
+return false;
+  if (!CGM.getTarget().getCXXABI().isMicrosoft())
+return false;
+  return llvm::any_of(ArgTypes, [&](QualType Ty) {
+return isInAllocaArgument(CGM.getCXXABI(), Ty);
+  });
+}
+
 #ifndef NDEBUG
 // Determine whether the given argument is an Objective-C method
 // that may have type parameters in its signature.
@@ -3845,17 +3864,27 @@ void CodeGenFunction::EmitCallArgs(
   assert((ParamsToSkip == 0 || Prototype.P) &&
  "Can't skip parameters if type info is not provided");
 
-  // First, use the argument types that the type info knows about
+  // This variable only captures *explicitly* written conventions, not those
+  // applied by default via command line flags or target defaults, such as
+  // thiscall, aapcs, stdcall via -mrtd, etc. Computing that correctly would
+  // require knowing if this is a C++ instance method or being able to see
+  // unprototyped FunctionTypes.
+  CallingConv ExplicitCC = CC_C;
+
+  // First, if a prototype was provided, use those argument types.
   bool IsVariadic = false;
   if (Prototype.P) {
 const auto *MD = Prototype.P.dyn_cast();
 if (MD) {
   IsVariadic = MD->isVariadic();
+  ExplicitCC = getCallingConventionForDecl(
+  MD, CGM.getTarget().getTriple().isOSWindows());
   ArgTypes.assign(MD->param_type_begin() + ParamsToSkip,
   MD->param_type_end());
 } else {
   const auto *FPT = Prototype.P.get();
   IsVariadic = FPT->isVariadic();
+  ExplicitCC = FPT->getExtInfo().getCC();
   ArgTypes.assign(FPT->param_type_begin() + ParamsToSkip,
   FPT->param_type_end());
 }
@@ -3923,15 +3952,10 @@ void CodeGenFunction::EmitCallArgs(
   };
 
   // Insert a stack save if we're going to need any inalloca args.
-  bool HasInAllocaArgs = false;
-  if (CGM.getTarget().getCXXABI().isMicrosoft()) {
-for (ArrayRef::iterator I = ArgTypes.begin(), E = ArgTypes.end();
- I != E && !HasInAllocaArgs; ++I)
-  HasInAllocaArgs = isInAllocaArgument(CGM.getCXXABI(), *I);
-if (HasInAllocaArgs) {
-  assert(getTarget().getTriple().getArch() == llvm::Triple::x86);
-  Args.allocateArgumentMemory(*this);
-}
+  if (hasInAllocaArgs(CGM, ExplicitCC, ArgTypes)) {
+assert(getTarget().getTriple().getArch() == llvm::Triple::x86 &&
+   "inalloca only supported on x8

[PATCH] D92944: Don't setup inalloca for swiftcc on i686-windows-msvc

2020-12-09 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdf282215d497: Don't setup inalloca for swiftcc on 
i686-windows-msvc (authored by rnk).

Changed prior to commit:
  https://reviews.llvm.org/D92944?vs=310565&id=310586#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92944/new/

https://reviews.llvm.org/D92944

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenCXX/windows-x86-swiftcall.cpp

Index: clang/test/CodeGenCXX/windows-x86-swiftcall.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/windows-x86-swiftcall.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-windows -emit-llvm -target-cpu core2 -o - %s | FileCheck %s
+
+#define SWIFTCALL __attribute__((swiftcall))
+#define OUT __attribute__((swift_indirect_result))
+#define ERROR __attribute__((swift_error_result))
+#define CONTEXT __attribute__((swift_context))
+
+/*/
+/** PARAMETER ABIS ***/
+/*/
+
+// Swift doesn't use inalloca like windows x86 normally does.
+struct NonTrivial {
+  NonTrivial();
+  NonTrivial(const NonTrivial &);
+  int o;
+};
+
+SWIFTCALL int receiveNonTrivial(NonTrivial o) { return o.o; }
+
+// CHECK-LABEL: define dso_local swiftcc i32 @"?receiveNonTrivial@@YSHUNonTrivial@@@Z"(%struct.NonTrivial* %o)
+
+int passNonTrivial() {
+  return receiveNonTrivial({});
+}
+
+// CHECK-LABEL: define dso_local i32 @"?passNonTrivial@@YAHXZ"()
+// CHECK-NOT: stacksave
+// CHECK: call swiftcc i32 @"?receiveNonTrivial@@YSHUNonTrivial@@@Z"(%struct.NonTrivial* %{{.*}})
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -198,7 +198,8 @@
FTP);
 }
 
-static CallingConv getCallingConventionForDecl(const Decl *D, bool IsWindows) {
+static CallingConv getCallingConventionForDecl(const ObjCMethodDecl *D,
+   bool IsWindows) {
   // Set the appropriate calling convention for the Function.
   if (D->hasAttr())
 return CC_X86StdCall;
@@ -3818,6 +3819,24 @@
   EmitCheck(std::make_pair(Cond, CheckKind), Handler, StaticData, None);
 }
 
+// Check if the call is going to use the inalloca convention. This needs to
+// agree with CGFunctionInfo::usesInAlloca. The CGFunctionInfo is arranged
+// later, so we can't check it directly.
+static bool hasInAllocaArgs(CodeGenModule &CGM, CallingConv ExplicitCC,
+ArrayRef ArgTypes) {
+  // The Swift calling convention doesn't go through the target-specific
+  // argument classification, so it never uses inalloca.
+  // TODO: Consider limiting inalloca use to only calling conventions supported
+  // by MSVC.
+  if (ExplicitCC == CC_Swift)
+return false;
+  if (!CGM.getTarget().getCXXABI().isMicrosoft())
+return false;
+  return llvm::any_of(ArgTypes, [&](QualType Ty) {
+return isInAllocaArgument(CGM.getCXXABI(), Ty);
+  });
+}
+
 #ifndef NDEBUG
 // Determine whether the given argument is an Objective-C method
 // that may have type parameters in its signature.
@@ -3845,17 +3864,27 @@
   assert((ParamsToSkip == 0 || Prototype.P) &&
  "Can't skip parameters if type info is not provided");
 
-  // First, use the argument types that the type info knows about
+  // This variable only captures *explicitly* written conventions, not those
+  // applied by default via command line flags or target defaults, such as
+  // thiscall, aapcs, stdcall via -mrtd, etc. Computing that correctly would
+  // require knowing if this is a C++ instance method or being able to see
+  // unprototyped FunctionTypes.
+  CallingConv ExplicitCC = CC_C;
+
+  // First, if a prototype was provided, use those argument types.
   bool IsVariadic = false;
   if (Prototype.P) {
 const auto *MD = Prototype.P.dyn_cast();
 if (MD) {
   IsVariadic = MD->isVariadic();
+  ExplicitCC = getCallingConventionForDecl(
+  MD, CGM.getTarget().getTriple().isOSWindows());
   ArgTypes.assign(MD->param_type_begin() + ParamsToSkip,
   MD->param_type_end());
 } else {
   const auto *FPT = Prototype.P.get();
   IsVariadic = FPT->isVariadic();
+  ExplicitCC = FPT->getExtInfo().getCC();
   ArgTypes.assign(FPT->param_type_begin() + ParamsToSkip,
   FPT->param_type_end());
 }
@@ -3923,15 +3952,10 @@
   };
 
   // Insert a stack save if we're going to need any inalloca args.
-  bool HasInAllocaArgs = false;
-  if (CGM.getTarget().getCXXABI().isMicrosoft()) {
-for (ArrayRef::iterator I = ArgTypes.begin(), E = ArgType

[PATCH] D92954: [clang-offload-bundler] Add option -list

2020-12-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
yaxunl requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

clang-offload-bundler is not only used by clang driver
to bundle/unbundle files for offloading toolchains,
but also used by out of tree tools to unbundle
fat binaries generated by clang. It is important
to be able to list the bundle IDs in a bundled
file so that the bundles can be extracted.

This patch adds an option -list to list bundle
ID's in a bundled file. Each bundle ID is separated
by new line. If the file is not a bundled file
nothing is output and returns 0.


https://reviews.llvm.org/D92954

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -62,11 +62,11 @@
cl::desc("[,...]"),
cl::cat(ClangOffloadBundlerCategory));
 static cl::list
-OutputFileNames("outputs", cl::CommaSeparated, cl::OneOrMore,
+OutputFileNames("outputs", cl::CommaSeparated,
 cl::desc("[,...]"),
 cl::cat(ClangOffloadBundlerCategory));
 static cl::list
-TargetNames("targets", cl::CommaSeparated, cl::OneOrMore,
+TargetNames("targets", cl::CommaSeparated,
 cl::desc("[-,...]"),
 cl::cat(ClangOffloadBundlerCategory));
 static cl::opt
@@ -89,6 +89,10 @@
  cl::desc("Unbundle bundled file into several output files.\n"),
  cl::init(false), cl::cat(ClangOffloadBundlerCategory));
 
+static cl::opt
+ListBundleIDs("list", cl::desc("List bundle IDs in the bundled file.\n"),
+  cl::init(false), cl::cat(ClangOffloadBundlerCategory));
+
 static cl::opt PrintExternalCommands(
 "###",
 cl::desc("Print any external commands that are to be executed "
@@ -109,6 +113,41 @@
 /// Path to the current binary.
 static std::string BundlerExecutable;
 
+namespace {
+
+// This class implements a list of temporary files that are removed upon
+// object destruction.
+class TempFileHandlerRAII {
+public:
+  ~TempFileHandlerRAII() {
+for (const auto &File : Files)
+  sys::fs::remove(File);
+  }
+
+  // Creates temporary file with given contents.
+  Expected Create(Optional> Contents) {
+SmallString<128u> File;
+if (std::error_code EC =
+sys::fs::createTemporaryFile("clang-offload-bundler", "tmp", File))
+  return createFileError(File, EC);
+Files.push_front(File);
+
+if (Contents) {
+  std::error_code EC;
+  raw_fd_ostream OS(File, EC);
+  if (EC)
+return createFileError(File, EC);
+  OS.write(Contents->data(), Contents->size());
+}
+return Files.front();
+  }
+
+private:
+  std::forward_list> Files;
+};
+
+} // end anonymous namespace
+
 /// Obtain the offload kind and real machine triple out of the target
 /// information specified by the user.
 static void getOffloadKindAndTriple(StringRef Target, StringRef &OffloadKind,
@@ -163,6 +202,9 @@
 
   /// Write the bundle from \a Input into \a OS.
   virtual Error WriteBundle(raw_fd_ostream &OS, MemoryBuffer &Input) = 0;
+
+  /// List bundle IDs in \a Input.
+  virtual Error listBundleIDs(MemoryBuffer &Input) = 0;
 };
 
 /// Handler for binary files. The bundled file will have the following format
@@ -290,6 +332,8 @@
 
   StringRef Triple(&FC.data()[ReadChars], TripleSize);
   ReadChars += TripleSize;
+  if (ListBundleIDs)
+llvm::outs() << Triple << '\n';
 
   // Check if the offset and size make sense.
   if (!Offset || Offset + Size > FC.size())
@@ -376,42 +420,13 @@
 OS.write(Input.getBufferStart(), Input.getBufferSize());
 return Error::success();
   }
-};
-
-namespace {
-
-// This class implements a list of temporary files that are removed upon
-// object destruction.
-class TempFileHandlerRAII {
-public:
-  ~TempFileHandlerRAII() {
-for (const auto &File : Files)
-  sys::fs::remove(File);
-  }
 
-  // Creates temporary file with given contents.
-  Expected Create(Optional> Contents) {
-SmallString<128u> File;
-if (std::error_code EC =
-sys::fs::createTemporaryFile("clang-offload-bundler", "tmp", File))
-  return createFileError(File, EC);
-Files.push_front(File);
-
-if (Contents) {
-  std::error_code EC;
-  raw_fd_ostream OS(File, EC);
-  if (EC)
-return createFileError(File, EC);
-  OS.write(Contents->data(), Contents->size());
-}
-return Files.front();
+  Error listBundleIDs(MemoryBuffer &Input) final {
+// List bundle IDs in a binary file only needs go through the header.
+return ReadHeader(Input);
   }
-
-private:
-  std::forward_list> Files;
 };
 
-} // end

[PATCH] D92006: Refactoring the attrubute plugin example to fit the new API

2020-12-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/Frontend/plugin-attribute.cpp:1
-// RUN: %clang -fplugin=%llvmshlibdir/Attribute%pluginext -emit-llvm -S %s -o 
- 2>&1 | FileCheck %s --check-prefix=ATTRIBUTE
-// RUN: not %clang -fplugin=%llvmshlibdir/Attribute%pluginext -emit-llvm 
-DBAD_ATTRIBUTE -S %s -o - 2>&1 | FileCheck %s --check-prefix=BADATTRIBUTE
+// RUN: split-file %s %t
+// RUN: %clang -cc1 -load %llvmshlibdir/Attribute%pluginext -fsyntax-only 
-ast-dump -verify %t/good_attr.cpp | FileCheck %s

I am unfamiliar with this construct -- is there a reason to do this as opposed 
to making two separate files with separate content (these are testing 
fundamentally different things)?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92006/new/

https://reviews.llvm.org/D92006

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92955: [openmp] Remove clause from OMPKinds.def and use OMP.td info

2020-12-09 Thread Valentin Clement via Phabricator via cfe-commits
clementval created this revision.
clementval added reviewers: jdoerfert, jdenny, kiranchandramohan.
Herald added subscribers: jfb, arphaman, guansong, yaxunl.
clementval requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1.
Herald added projects: clang, LLVM.

Remove the OpenMP clause information from the OMPKinds.def file and use the
information from the new OMP.td file. There is now a single source of truth for 
the 
directives and clauses.

To avoid generate lots of specific small code from tablegen, the macros 
previously
used in OMPKinds.def are generated almost as identical. This can be polished and
possibly removed in a further patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92955

Files:
  clang/include/clang/AST/ASTFwd.h
  clang/include/clang/AST/ASTTypeTraits.h
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/AST/ASTTypeTraits.cpp
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.h
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/include/llvm/TableGen/DirectiveEmitter.h
  llvm/test/TableGen/directive2.td
  llvm/utils/TableGen/DirectiveEmitter.cpp

Index: llvm/utils/TableGen/DirectiveEmitter.cpp
===
--- llvm/utils/TableGen/DirectiveEmitter.cpp
+++ llvm/utils/TableGen/DirectiveEmitter.cpp
@@ -645,6 +645,72 @@
   GenerateFlangClauseUnparse(DirLang, OS);
 }
 
+void GenerateClauseClassMacro(const DirectiveLanguage &DirLang,
+  raw_ostream &OS) {
+  // Generate macros style information for legacy code in clang
+  IfDefScope Scope("GEN_CLANG_CLAUSE_CLASS", OS);
+
+  OS << "\n";
+
+  OS << "#ifndef CLAUSE\n";
+  OS << "#define CLAUSE(Enum, Str, Implicit)\n";
+  OS << "#endif\n";
+  OS << "#ifndef CLAUSE_CLASS\n";
+  OS << "#define CLAUSE_CLASS(Enum, Str, Class)\n";
+  OS << "#endif\n";
+  OS << "#ifndef CLAUSE_NO_CLASS\n";
+  OS << "#define CLAUSE_NO_CLASS(Enum, Str)\n";
+  OS << "#endif\n";
+  OS << "\n";
+  OS << "#define __CLAUSE(Name, Class)  \\\n";
+  OS << "  CLAUSE(" << DirLang.getClausePrefix()
+ << "##Name, #Name, /* Implicit */ false) \\\n";
+  OS << "  CLAUSE_CLASS(" << DirLang.getClausePrefix()
+ << "##Name, #Name, Class)\n";
+  OS << "#define __CLAUSE_NO_CLASS(Name)\\\n";
+  OS << "  CLAUSE(" << DirLang.getClausePrefix()
+ << "##Name, #Name, /* Implicit */ false) \\\n";
+  OS << "  CLAUSE_NO_CLASS(" << DirLang.getClausePrefix() << "##Name, #Name)\n";
+  OS << "#define __IMPLICIT_CLAUSE_CLASS(Name, Str, Class)  \\\n";
+  OS << "  CLAUSE(" << DirLang.getClausePrefix()
+ << "##Name, Str, /* Implicit */ true)\\\n";
+  OS << "  CLAUSE_CLASS(" << DirLang.getClausePrefix()
+ << "##Name, Str, Class)\n";
+  OS << "#define __IMPLICIT_CLAUSE_NO_CLASS(Name, Str)  \\\n";
+  OS << "  CLAUSE(" << DirLang.getClausePrefix()
+ << "##Name, Str, /* Implicit */ true)\\\n";
+  OS << "  CLAUSE_NO_CLASS(" << DirLang.getClausePrefix() << "##Name, Str)\n";
+  OS << "\n";
+
+  for (const auto &R : DirLang.getClauses()) {
+Clause C{R};
+if (C.getClangClass().empty()) { // NO_CLASS
+  if (C.isImplicit()) {
+OS << "__IMPLICIT_CLAUSE_NO_CLASS(" << C.getFormattedName() << ", \""
+   << C.getFormattedName() << "\")\n";
+  } else {
+OS << "__CLAUSE_NO_CLASS(" << C.getFormattedName() << ")\n";
+  }
+} else { // CLASS
+  if (C.isImplicit()) {
+OS << "__IMPLICIT_CLAUSE_CLASS(" << C.getFormattedName() << ", \""
+   << C.getFormattedName() << "\", " << C.getClangClass() << ")\n";
+  } else {
+OS << "__CLAUSE(" << C.getFormattedName() << ", " << C.getClangClass()
+   << ")\n";
+  }
+}
+  }
+
+  OS << "\n";
+  OS << "#undef __IMPLICIT_CLAUSE_NO_CLASS\n";
+  OS << "#undef __IMPLICIT_CLAUSE_CLASS\n";
+  OS << "#undef __CLAUSE\n";
+  OS << "#undef CLAUSE_NO_CLASS\n";
+  OS << "#undef CLAUSE_CLASS\n";
+  OS << "#undef CLAUSE\n";
+}
+
 // Generate the implemenation section for the enumeration in the directive
 // language.
 void EmitDirectivesGen(RecordKeeper &Records, raw_ostream &OS) {
@@ -653,6 +719,8 @@
 return;
 
   EmitDirectivesFlangImpl(DirLang, OS);
+
+  GenerateClauseClassMacro(DirLang, OS);
 }
 
 // Generate the implemenation for the enumeration in the directive
Index: llvm/test/TableGen/directive2.td
===
--- llvm/test/TableGen/directive2.td
+++ llvm/test/TableGen/directive2.td
@@ -23,10 +23,15 @@
   let isValueList = 1;
 }
 def TDLC_ClauseC : Clause<"clausec"> {
+  let clan

[PATCH] D92956: Fix https://bugs.llvm.org/show_bug.cgi?id=48011

2020-12-09 Thread z via Phabricator via cfe-commits
fanfuqiang created this revision.
fanfuqiang added a reviewer: dblaikie.
fanfuqiang requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

fix https://bugs.llvm.org/show_bug.cgi?id=48011


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92956

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/SemaCXX/warn-range-loop-analysis.cpp


Index: clang/test/SemaCXX/warn-range-loop-analysis.cpp
===
--- clang/test/SemaCXX/warn-range-loop-analysis.cpp
+++ clang/test/SemaCXX/warn-range-loop-analysis.cpp
@@ -29,6 +29,12 @@
   operator int();
 };
 
+struct ID1 {
+  // Small trivally copy constructor, but no trivally copy assignment 
+  // operator.
+  ID1& operator=(ID1 const& other) { return *this; }
+};
+
 // Testing notes:
 // test0 checks that the full text of the warnings and notes is correct.  The
 //   rest of the tests checks a smaller portion of the text.
@@ -455,6 +461,23 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:17-[[@LINE-3]]:18}:" "
 }
 
+void test11() {
+  Container C;
+
+  for (const ID1 &x : C) {}
+  // No warning
+
+  for (const ID1& x : C) {}
+  // No warning
+
+  for (const ID1 & x : C) {}
+  // No warning
+
+  for (const ID1&x : C) {}
+  // No warning
+}
+
+
 template 
 void test_template_function() {
   // In a template instantiation the diagnostics should not be emitted for
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -2855,8 +2855,14 @@
   // diagnostic for these instances. 64 bytes is a common size of a cache line.
   // (The function `getTypeSize` returns the size in bits.)
   ASTContext &Ctx = SemaRef.Context;
+  const CXXRecordDecl *ClassDecl = nullptr;
+  if (const auto *RT = VariableType->getAs()) {
+ClassDecl = dyn_cast(RT->getDecl());
+  }
   if (Ctx.getTypeSize(VariableType) <= 64 * 8 &&
   (VariableType.isTriviallyCopyableType(Ctx) ||
+   // Fix https://bugs.llvm.org/show_bug.cgi?id=48011
+   (ClassDecl && !ClassDecl->hasNonTrivialCopyConstructor()) ||
hasTrivialABIAttr(VariableType)))
 return;
 


Index: clang/test/SemaCXX/warn-range-loop-analysis.cpp
===
--- clang/test/SemaCXX/warn-range-loop-analysis.cpp
+++ clang/test/SemaCXX/warn-range-loop-analysis.cpp
@@ -29,6 +29,12 @@
   operator int();
 };
 
+struct ID1 {
+  // Small trivally copy constructor, but no trivally copy assignment 
+  // operator.
+  ID1& operator=(ID1 const& other) { return *this; }
+};
+
 // Testing notes:
 // test0 checks that the full text of the warnings and notes is correct.  The
 //   rest of the tests checks a smaller portion of the text.
@@ -455,6 +461,23 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:17-[[@LINE-3]]:18}:" "
 }
 
+void test11() {
+  Container C;
+
+  for (const ID1 &x : C) {}
+  // No warning
+
+  for (const ID1& x : C) {}
+  // No warning
+
+  for (const ID1 & x : C) {}
+  // No warning
+
+  for (const ID1&x : C) {}
+  // No warning
+}
+
+
 template 
 void test_template_function() {
   // In a template instantiation the diagnostics should not be emitted for
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -2855,8 +2855,14 @@
   // diagnostic for these instances. 64 bytes is a common size of a cache line.
   // (The function `getTypeSize` returns the size in bits.)
   ASTContext &Ctx = SemaRef.Context;
+  const CXXRecordDecl *ClassDecl = nullptr;
+  if (const auto *RT = VariableType->getAs()) {
+ClassDecl = dyn_cast(RT->getDecl());
+  }
   if (Ctx.getTypeSize(VariableType) <= 64 * 8 &&
   (VariableType.isTriviallyCopyableType(Ctx) ||
+   // Fix https://bugs.llvm.org/show_bug.cgi?id=48011
+   (ClassDecl && !ClassDecl->hasNonTrivialCopyConstructor()) ||
hasTrivialABIAttr(VariableType)))
 return;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92808: [ObjC][ARC] Annotate calls with attributes instead of emitting retainRV or claimRV calls in the IR

2020-12-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In D92808#2443006 , @compnerd wrote:

> There is nothing particularly special about that.  The reason for the funclet 
> handling there is that in the case of an outlined block for exception 
> handling (i.e. a funclet), we need to ensure that the assembly marker 
> received the funclet token as failure to do so would mark the assembly as 
> unreachable and would thus thwart the auto-release claim.  For the normal 
> codepath, the behaviour should be identical.

ARC contract pass removes attribute retainRV/claimRV (but not attribute 
rv_marker) from a call and inserts a retainRV/claimRV call after the call in 
the IR. In that case, the inserted retainRV/claimRV should get the funclet 
token. Is that right?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92808/new/

https://reviews.llvm.org/D92808

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92955: [openmp] Remove clause from OMPKinds.def and use OMP.td info

2020-12-09 Thread Valentin Clement via Phabricator via cfe-commits
clementval updated this revision to Diff 310589.
clementval added a comment.

Remove useless define macro


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92955/new/

https://reviews.llvm.org/D92955

Files:
  clang/include/clang/AST/ASTFwd.h
  clang/include/clang/AST/ASTTypeTraits.h
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/AST/ASTTypeTraits.cpp
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.h
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/include/llvm/TableGen/DirectiveEmitter.h
  llvm/test/TableGen/directive2.td
  llvm/utils/TableGen/DirectiveEmitter.cpp

Index: llvm/utils/TableGen/DirectiveEmitter.cpp
===
--- llvm/utils/TableGen/DirectiveEmitter.cpp
+++ llvm/utils/TableGen/DirectiveEmitter.cpp
@@ -645,6 +645,72 @@
   GenerateFlangClauseUnparse(DirLang, OS);
 }
 
+void GenerateClauseClassMacro(const DirectiveLanguage &DirLang,
+  raw_ostream &OS) {
+  // Generate macros style information for legacy code in clang
+  IfDefScope Scope("GEN_CLANG_CLAUSE_CLASS", OS);
+
+  OS << "\n";
+
+  OS << "#ifndef CLAUSE\n";
+  OS << "#define CLAUSE(Enum, Str, Implicit)\n";
+  OS << "#endif\n";
+  OS << "#ifndef CLAUSE_CLASS\n";
+  OS << "#define CLAUSE_CLASS(Enum, Str, Class)\n";
+  OS << "#endif\n";
+  OS << "#ifndef CLAUSE_NO_CLASS\n";
+  OS << "#define CLAUSE_NO_CLASS(Enum, Str)\n";
+  OS << "#endif\n";
+  OS << "\n";
+  OS << "#define __CLAUSE(Name, Class)  \\\n";
+  OS << "  CLAUSE(" << DirLang.getClausePrefix()
+ << "##Name, #Name, /* Implicit */ false) \\\n";
+  OS << "  CLAUSE_CLASS(" << DirLang.getClausePrefix()
+ << "##Name, #Name, Class)\n";
+  OS << "#define __CLAUSE_NO_CLASS(Name)\\\n";
+  OS << "  CLAUSE(" << DirLang.getClausePrefix()
+ << "##Name, #Name, /* Implicit */ false) \\\n";
+  OS << "  CLAUSE_NO_CLASS(" << DirLang.getClausePrefix() << "##Name, #Name)\n";
+  OS << "#define __IMPLICIT_CLAUSE_CLASS(Name, Str, Class)  \\\n";
+  OS << "  CLAUSE(" << DirLang.getClausePrefix()
+ << "##Name, Str, /* Implicit */ true)\\\n";
+  OS << "  CLAUSE_CLASS(" << DirLang.getClausePrefix()
+ << "##Name, Str, Class)\n";
+  OS << "#define __IMPLICIT_CLAUSE_NO_CLASS(Name, Str)  \\\n";
+  OS << "  CLAUSE(" << DirLang.getClausePrefix()
+ << "##Name, Str, /* Implicit */ true)\\\n";
+  OS << "  CLAUSE_NO_CLASS(" << DirLang.getClausePrefix() << "##Name, Str)\n";
+  OS << "\n";
+
+  for (const auto &R : DirLang.getClauses()) {
+Clause C{R};
+if (C.getClangClass().empty()) { // NO_CLASS
+  if (C.isImplicit()) {
+OS << "__IMPLICIT_CLAUSE_NO_CLASS(" << C.getFormattedName() << ", \""
+   << C.getFormattedName() << "\")\n";
+  } else {
+OS << "__CLAUSE_NO_CLASS(" << C.getFormattedName() << ")\n";
+  }
+} else { // CLASS
+  if (C.isImplicit()) {
+OS << "__IMPLICIT_CLAUSE_CLASS(" << C.getFormattedName() << ", \""
+   << C.getFormattedName() << "\", " << C.getClangClass() << ")\n";
+  } else {
+OS << "__CLAUSE(" << C.getFormattedName() << ", " << C.getClangClass()
+   << ")\n";
+  }
+}
+  }
+
+  OS << "\n";
+  OS << "#undef __IMPLICIT_CLAUSE_NO_CLASS\n";
+  OS << "#undef __IMPLICIT_CLAUSE_CLASS\n";
+  OS << "#undef __CLAUSE\n";
+  OS << "#undef CLAUSE_NO_CLASS\n";
+  OS << "#undef CLAUSE_CLASS\n";
+  OS << "#undef CLAUSE\n";
+}
+
 // Generate the implemenation section for the enumeration in the directive
 // language.
 void EmitDirectivesGen(RecordKeeper &Records, raw_ostream &OS) {
@@ -653,6 +719,8 @@
 return;
 
   EmitDirectivesFlangImpl(DirLang, OS);
+
+  GenerateClauseClassMacro(DirLang, OS);
 }
 
 // Generate the implemenation for the enumeration in the directive
Index: llvm/test/TableGen/directive2.td
===
--- llvm/test/TableGen/directive2.td
+++ llvm/test/TableGen/directive2.td
@@ -23,10 +23,15 @@
   let isValueList = 1;
 }
 def TDLC_ClauseC : Clause<"clausec"> {
+  let clangClass = "ClauseC";
   let flangClassValue = "Name";
   let defaultValue = "*";
   let isValueOptional = 1;
 }
+def TDLC_ClauseD : Clause<"claused"> {
+  let clangClass = "ClauseD";
+  let isImplicit = 1;
+}
 
 def TDL_DirA : Directive<"dira"> {
   let allowedClauses = [
@@ -53,9 +58,10 @@
 // CHECK-NEXT:TDLC_clausea,
 // CHECK-NEXT:TDLC_clauseb,
 // CHECK-NEXT:TDLC_clausec,
+// CHECK-NEXT:TDLC_claused,
 // CHECK-NEXT:  };
 // CHECK-EMPTY:
-// CHECK-NEXT:  static constexpr std::size_t Clause_enumSize = 3;
+// CHECK-NEXT:  static constexpr std::size_t 

[PATCH] D92955: [openmp] Remove clause from OMPKinds.def and use OMP.td info

2020-12-09 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I like this a lot. We might even look into generating the clang OpenMPClause 
classes via TableGen later, thanks a lot.

There is a file missing, right? The list of actual clauses.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92955/new/

https://reviews.llvm.org/D92955

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92956: Fix https://bugs.llvm.org/show_bug.cgi?id=48011

2020-12-09 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/test/SemaCXX/warn-range-loop-analysis.cpp:35
+  // operator.
+  ID1& operator=(ID1 const& other) { return *this; }
+};

I recommend adding `ID1(ID1 const&) = default;` here. My understanding is that 
C++20 has deprecated auto-generating a defaulted copy constructor for a class 
with a user-defined copy-assignment operator. See `-Wdeprecated-copy`.



Comment at: clang/test/SemaCXX/warn-range-loop-analysis.cpp:477
+  for (const ID1&x : C) {}
+  // No warning
+}

Isn't the point of https://bugs.llvm.org/show_bug.cgi?id=48011 that there 
should be no warning for `for (ID1 x : C) {}`?  There is already no warning for 
the `const&` case tested here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92956/new/

https://reviews.llvm.org/D92956

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92209: [ASTImporter] Support CXXDeductionGuideDecl with local typedef

2020-12-09 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 310591.
martong marked an inline comment as done.
martong added a comment.

- Remove not relevant param from test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92209/new/

https://reviews.llvm.org/D92209

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5925,6 +5925,22 @@
   EXPECT_TRUE(ToD->isExplicit());
 }
 
+TEST_P(ImportFunctions, CTADWithLocalTypedef) {
+  Decl *TU = getTuDecl(
+  R"(
+  template  struct A {
+typedef T U;
+A(U);
+  };
+  A a{(int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  auto *FromD = FirstDeclMatcher().match(
+  TU, cxxDeductionGuideDecl());
+  auto *ToD = Import(FromD, Lang_CXX17);
+  ASSERT_TRUE(ToD);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -385,6 +385,8 @@
 ExpectedType VisitObjCObjectPointerType(const ObjCObjectPointerType *T);
 
 // Importing declarations
+Error ImportDeclParts(NamedDecl *D, DeclarationName &Name, NamedDecl *&ToD,
+  SourceLocation &Loc);
 Error ImportDeclParts(
 NamedDecl *D, DeclContext *&DC, DeclContext *&LexicalDC,
 DeclarationName &Name, NamedDecl *&ToD, SourceLocation &Loc);
@@ -1644,6 +1646,25 @@
   return Error::success();
 }
 
+Error ASTNodeImporter::ImportDeclParts(NamedDecl *D, DeclarationName &Name,
+   NamedDecl *&ToD, SourceLocation &Loc) {
+
+  // Import the name of this declaration.
+  if (Error Err = importInto(Name, D->getDeclName()))
+return Err;
+
+  // Import the location of this declaration.
+  if (Error Err = importInto(Loc, D->getLocation()))
+return Err;
+
+  ToD = cast_or_null(Importer.GetAlreadyImportedOrNull(D));
+  if (ToD)
+if (Error Err = ASTNodeImporter(*this).ImportDefinitionIfNeeded(D, ToD))
+  return Err;
+
+  return Error::success();
+}
+
 Error ASTNodeImporter::ImportDefinitionIfNeeded(Decl *FromD, Decl *ToD) {
   if (!FromD)
 return Error::success();
@@ -2412,22 +2433,29 @@
 ExpectedDecl
 ASTNodeImporter::VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias) {
   // Import the major distinguishing characteristics of this typedef.
-  DeclContext *DC, *LexicalDC;
   DeclarationName Name;
   SourceLocation Loc;
   NamedDecl *ToD;
-  if (Error Err = ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
+  // Do not import the DeclContext, we will import it once the TypedefNameDecl
+  // is created.
+  if (Error Err = ImportDeclParts(D, Name, ToD, Loc))
 return std::move(Err);
   if (ToD)
 return ToD;
 
+  DeclContext *DC = cast_or_null(
+  Importer.GetAlreadyImportedOrNull(cast(D->getDeclContext(;
+  DeclContext *LexicalDC =
+  cast_or_null(Importer.GetAlreadyImportedOrNull(
+  cast(D->getLexicalDeclContext(;
+
   // If this typedef is not in block scope, determine whether we've
   // seen a typedef with the same name (that we can merge with) or any
   // other entity by that name (which name lookup could conflict with).
   // Note: Repeated typedefs are not valid in C99:
   // 'typedef int T; typedef int T;' is invalid
   // We do not care about this now.
-  if (!DC->isFunctionOrMethod()) {
+  if (DC && !DC->isFunctionOrMethod()) {
 SmallVector ConflictingDecls;
 unsigned IDNS = Decl::IDNS_Ordinary;
 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
@@ -2484,8 +2512,15 @@
   Name.getAsIdentifierInfo(), ToTypeSourceInfo))
 return ToTypedef;
 
-  ToTypedef->setAccess(D->getAccess());
+  // Import the DeclContext and set it to the Typedef.
+  if ((Err = ImportDeclContext(D, DC, LexicalDC)))
+return std::move(Err);
+  ToTypedef->setDeclContext(DC);
   ToTypedef->setLexicalDeclContext(LexicalDC);
+  // Add to the lookupTable because we could not do that in MapImported.
+  Importer.AddToLookupTable(ToTypedef);
+
+  ToTypedef->setAccess(D->getAccess());
 
   // Templated declarations should not appear in DeclContext.
   TypeAliasDecl *FromAlias = IsAlias ? cast(D) : nullptr;
@@ -9189,7 +9224,11 @@
   // This mapping should be maintained only in this function. Therefore do not
   // check for additional consistency.
   ImportedFromDecls[To] = From;
-  AddToLookupTable(To);
+  // In the case of TypedefNameDecl we create the Decl first and only then we
+  // import and set its DeclContext. So, the DC is still not set when we reach
+  // here from GetImportedOrCreateDecl.
+  if (To->getDeclContext())
+AddToLookupTable(To);
   retur

[PATCH] D92954: [clang-offload-bundler] Add option -list

2020-12-09 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:763
+
+// Create an intermediate temporary file for reading the bundles.
+TempFileHandlerRAII TempFiles;

Having to create a temporary file in order to *list* content of the bundle 
strikes me as rather odd.
It looks like in order to list the content we actually do bundle unpacking, 
printing bundled content in the process, and discard the results afterwards. Is 
that so?

Perhaps it would be better to refactor the code a bit and separate iteration 
over the bundle from what each iteration does.
E.g. make a function `forEachBundledFile(input, lambda)` and then pass a 
function that writes things out for normal operations and a function which just 
prints the info in case of `--list`. It may simplify the code a bit as right 
now you have to copy/paste the loops iterating over ReadBundleStart.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92954/new/

https://reviews.llvm.org/D92954

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92080: [Clang] Mutate long-double math builtins into f128 under IEEE-quad

2020-12-09 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I don't think I understand the whole picture here. Why would only builtins get 
mutated? Does a call to "modf" still call "modf"? But __builtin_modf will call 
modf128? Is there a corresponding patch to the runtime libcalls table in the 
backend? With -ffast-math __builtin_sinl becomes llvm.sin.f128 and the backend 
will emit a call to sinl if ISD::SIN isn't legal.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92080/new/

https://reviews.llvm.org/D92080

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >