[PATCH] D33820: [PowerPC] Pass CPU to assembler with -no-integrated-as

2017-06-01 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai updated this revision to Diff 101169.
nemanjai added a comment.

Initially, forgot to add a test case.


Repository:
  rL LLVM

https://reviews.llvm.org/D33820

Files:
  lib/Driver/ToolChains/Arch/PPC.cpp
  lib/Driver/ToolChains/Arch/PPC.h
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/linux-as.c

Index: test/Driver/linux-as.c
===
--- test/Driver/linux-as.c
+++ test/Driver/linux-as.c
@@ -174,3 +174,18 @@
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-Z-ARCH-Z196 %s
 // CHECK-Z-ARCH-Z196: as{{.*}} "-march=z196"
+//
+// RUN: %clang -target powerpc64le-linux -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PPC64LE %s
+// CHECK-PPC64LE: as{{.*}} "-mpower8"
+//
+// RUN: %clang -target powerpc64-linux -mcpu=pwr7 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PPC64 %s
+// CHECK-PPC64: as{{.*}} "-mpower7"
+//
+// RUN: %clang -target powerpc-linux -mcpu=pwr9 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PPC32 %s
+// CHECK-PPC32: as{{.*}} "-mpower9"
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -11,6 +11,7 @@
 #include "Linux.h"
 #include "Arch/ARM.h"
 #include "Arch/Mips.h"
+#include "Arch/PPC.h"
 #include "Arch/Sparc.h"
 #include "Arch/SystemZ.h"
 #include "CommonArgs.h"
@@ -674,22 +675,28 @@
 else
   CmdArgs.push_back("--64");
 break;
-  case llvm::Triple::ppc:
+  case llvm::Triple::ppc: {
 CmdArgs.push_back("-a32");
 CmdArgs.push_back("-mppc");
-CmdArgs.push_back("-many");
+std::string CPU = getCPUName(Args, getToolChain().getTriple());
+CmdArgs.push_back(ppc::getPPCAsmModeForCPU(CPU));
 break;
-  case llvm::Triple::ppc64:
+  }
+  case llvm::Triple::ppc64: {
 CmdArgs.push_back("-a64");
 CmdArgs.push_back("-mppc64");
-CmdArgs.push_back("-many");
+std::string CPU = getCPUName(Args, getToolChain().getTriple());
+CmdArgs.push_back(ppc::getPPCAsmModeForCPU(CPU));
 break;
-  case llvm::Triple::ppc64le:
+  }
+  case llvm::Triple::ppc64le: {
 CmdArgs.push_back("-a64");
 CmdArgs.push_back("-mppc64");
-CmdArgs.push_back("-many");
 CmdArgs.push_back("-mlittle-endian");
+std::string CPU = getCPUName(Args, getToolChain().getTriple());
+CmdArgs.push_back(ppc::getPPCAsmModeForCPU(CPU));
 break;
+  }
   case llvm::Triple::sparc:
   case llvm::Triple::sparcel: {
 CmdArgs.push_back("-32");
Index: lib/Driver/ToolChains/Arch/PPC.h
===
--- lib/Driver/ToolChains/Arch/PPC.h
+++ lib/Driver/ToolChains/Arch/PPC.h
@@ -32,6 +32,7 @@
 FloatABI getPPCFloatABI(const Driver , const llvm::opt::ArgList );
 
 std::string getPPCTargetCPU(const llvm::opt::ArgList );
+const char *getPPCAsmModeForCPU(StringRef Name);
 
 void getPPCTargetFeatures(const Driver , const llvm::Triple ,
   const llvm::opt::ArgList ,
Index: lib/Driver/ToolChains/Arch/PPC.cpp
===
--- lib/Driver/ToolChains/Arch/PPC.cpp
+++ lib/Driver/ToolChains/Arch/PPC.cpp
@@ -86,6 +86,18 @@
   return "";
 }
 
+const char *ppc::getPPCAsmModeForCPU(StringRef Name) {
+  return llvm::StringSwitch(Name)
+.Case("pwr7", "-mpower7")
+.Case("power7", "-mpower7")
+.Case("pwr8", "-mpower8")
+.Case("power8", "-mpower8")
+.Case("ppc64le", "-mpower8")
+.Case("pwr9", "-mpower9")
+.Case("power9", "-mpower9")
+.Default("-many");
+}
+
 void ppc::getPPCTargetFeatures(const Driver , const llvm::Triple ,
const ArgList ,
std::vector ) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33820: [PowerPC] Pass CPU to assembler with -no-integrated-as

2017-06-01 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai created this revision.

This just adds the CPU to a list of commands passed to GAS when not using the 
integrated assembler.


Repository:
  rL LLVM

https://reviews.llvm.org/D33820

Files:
  lib/Driver/ToolChains/Arch/PPC.cpp
  lib/Driver/ToolChains/Arch/PPC.h
  lib/Driver/ToolChains/Gnu.cpp


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -11,6 +11,7 @@
 #include "Linux.h"
 #include "Arch/ARM.h"
 #include "Arch/Mips.h"
+#include "Arch/PPC.h"
 #include "Arch/Sparc.h"
 #include "Arch/SystemZ.h"
 #include "CommonArgs.h"
@@ -674,22 +675,28 @@
 else
   CmdArgs.push_back("--64");
 break;
-  case llvm::Triple::ppc:
+  case llvm::Triple::ppc: {
 CmdArgs.push_back("-a32");
 CmdArgs.push_back("-mppc");
-CmdArgs.push_back("-many");
+std::string CPU = getCPUName(Args, getToolChain().getTriple());
+CmdArgs.push_back(ppc::getPPCAsmModeForCPU(CPU));
 break;
-  case llvm::Triple::ppc64:
+  }
+  case llvm::Triple::ppc64: {
 CmdArgs.push_back("-a64");
 CmdArgs.push_back("-mppc64");
-CmdArgs.push_back("-many");
+std::string CPU = getCPUName(Args, getToolChain().getTriple());
+CmdArgs.push_back(ppc::getPPCAsmModeForCPU(CPU));
 break;
-  case llvm::Triple::ppc64le:
+  }
+  case llvm::Triple::ppc64le: {
 CmdArgs.push_back("-a64");
 CmdArgs.push_back("-mppc64");
-CmdArgs.push_back("-many");
 CmdArgs.push_back("-mlittle-endian");
+std::string CPU = getCPUName(Args, getToolChain().getTriple());
+CmdArgs.push_back(ppc::getPPCAsmModeForCPU(CPU));
 break;
+  }
   case llvm::Triple::sparc:
   case llvm::Triple::sparcel: {
 CmdArgs.push_back("-32");
Index: lib/Driver/ToolChains/Arch/PPC.h
===
--- lib/Driver/ToolChains/Arch/PPC.h
+++ lib/Driver/ToolChains/Arch/PPC.h
@@ -32,6 +32,7 @@
 FloatABI getPPCFloatABI(const Driver , const llvm::opt::ArgList );
 
 std::string getPPCTargetCPU(const llvm::opt::ArgList );
+const char *getPPCAsmModeForCPU(StringRef Name);
 
 void getPPCTargetFeatures(const Driver , const llvm::Triple ,
   const llvm::opt::ArgList ,
Index: lib/Driver/ToolChains/Arch/PPC.cpp
===
--- lib/Driver/ToolChains/Arch/PPC.cpp
+++ lib/Driver/ToolChains/Arch/PPC.cpp
@@ -86,6 +86,18 @@
   return "";
 }
 
+const char *ppc::getPPCAsmModeForCPU(StringRef Name) {
+  return llvm::StringSwitch(Name)
+.Case("pwr7", "-mpower7")
+.Case("power7", "-mpower7")
+.Case("pwr8", "-mpower8")
+.Case("power8", "-mpower8")
+.Case("ppc64le", "-mpower8")
+.Case("pwr9", "-mpower9")
+.Case("power9", "-mpower9")
+.Default("-many");
+}
+
 void ppc::getPPCTargetFeatures(const Driver , const llvm::Triple ,
const ArgList ,
std::vector ) {


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -11,6 +11,7 @@
 #include "Linux.h"
 #include "Arch/ARM.h"
 #include "Arch/Mips.h"
+#include "Arch/PPC.h"
 #include "Arch/Sparc.h"
 #include "Arch/SystemZ.h"
 #include "CommonArgs.h"
@@ -674,22 +675,28 @@
 else
   CmdArgs.push_back("--64");
 break;
-  case llvm::Triple::ppc:
+  case llvm::Triple::ppc: {
 CmdArgs.push_back("-a32");
 CmdArgs.push_back("-mppc");
-CmdArgs.push_back("-many");
+std::string CPU = getCPUName(Args, getToolChain().getTriple());
+CmdArgs.push_back(ppc::getPPCAsmModeForCPU(CPU));
 break;
-  case llvm::Triple::ppc64:
+  }
+  case llvm::Triple::ppc64: {
 CmdArgs.push_back("-a64");
 CmdArgs.push_back("-mppc64");
-CmdArgs.push_back("-many");
+std::string CPU = getCPUName(Args, getToolChain().getTriple());
+CmdArgs.push_back(ppc::getPPCAsmModeForCPU(CPU));
 break;
-  case llvm::Triple::ppc64le:
+  }
+  case llvm::Triple::ppc64le: {
 CmdArgs.push_back("-a64");
 CmdArgs.push_back("-mppc64");
-CmdArgs.push_back("-many");
 CmdArgs.push_back("-mlittle-endian");
+std::string CPU = getCPUName(Args, getToolChain().getTriple());
+CmdArgs.push_back(ppc::getPPCAsmModeForCPU(CPU));
 break;
+  }
   case llvm::Triple::sparc:
   case llvm::Triple::sparcel: {
 CmdArgs.push_back("-32");
Index: lib/Driver/ToolChains/Arch/PPC.h
===
--- lib/Driver/ToolChains/Arch/PPC.h
+++ lib/Driver/ToolChains/Arch/PPC.h
@@ -32,6 +32,7 @@
 FloatABI getPPCFloatABI(const Driver , const llvm::opt::ArgList );
 
 std::string getPPCTargetCPU(const llvm::opt::ArgList );
+const char *getPPCAsmModeForCPU(StringRef Name);
 
 void getPPCTargetFeatures(const Driver , const llvm::Triple ,
   const 

[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-01 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 marked 12 inline comments as done.
jyu2 added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6341
+: Warning<"%0 has a non-throwing exception specification but can still "
+  "throw, may result in unexpected program termination.">, 
+  InGroup;

aaron.ballman wrote:
> throw, may -> throw, which may
> 
> Also, remove the period at the end of the diagnostic.
use you suggested.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:290
+
+static bool mayThrowBeCaughted(const CXXThrowExpr *Throw,
+   const CXXCatchStmt *Catch) {

aaron.ballman wrote:
> Caughted -> Caught
:-(



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:304
+  if (CaughtAsRecordType && ThrowTypeAsRecordType) {
+if (CaughtAsRecordType == ThrowTypeAsRecordType)
+  MayCaught = true;

aaron.ballman wrote:
> This does not seem quite correct. Consider:
> ```
> struct S{};
> 
> void f() {
>   try {
> throw S{};
>   } catch (const S *s) {
>   }
> }
> ```
Good catch.  Remove that check.


https://reviews.llvm.org/D3



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


[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-01 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

In https://reviews.llvm.org/D3#770238, @aaron.ballman wrote:

> In https://reviews.llvm.org/D3#768332, @jyu2 wrote:
>
> > Okay this CFG version of this change.  In this change I am basic using same 
> > algorithm with -Winfinite-recursion.
> >
> > In addition to my original implementation,  I add handler type checking 
> > which basic using  https://reviews.llvm.org/D19201 method.
>
>
> Thank you, I think this is a step in the right direction!
>
> > There are couple things I am worry about this implementation:
> >  1> compile time...
>
> Do you have any timing data on whether this has a negative performance impact?
>
> > 2> Correctness...
>
> Your implementation looks reasonable to me, but with further review (and good 
> tests), we should have a better grasp on correctness.
>
> > 3> Stack overflow for large CFG...
>
> I would be surprised if that were a problem, but is something we could 
> address if it ever arises.


Hope that is okay.


https://reviews.llvm.org/D3



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


[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-01 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 marked 8 inline comments as done.
jyu2 added inline comments.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:334
+  continue;
+else
+  HasThrowOutFunc = true;

aaron.ballman wrote:
> You can drop the `else` here and just set `HasThrowOutFunc` to true.
Can not do that, don't if block has throw expression yet. 


https://reviews.llvm.org/D3



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


[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-01 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 101167.
jyu2 marked an inline comment as done.
jyu2 added a comment.

Update to address review comments.


https://reviews.llvm.org/D3

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/AnalysisBasedWarnings.cpp
  test/CXX/except/except.spec/p11.cpp
  test/SemaCXX/warn-throw-out-noexcept-func.cpp

Index: lib/Sema/AnalysisBasedWarnings.cpp
===
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -279,6 +279,150 @@
 }
 
 //===--===//
+// Check for throw in a non-throwing function.
+//===--===//
+enum ThrowState {
+  FoundNoPathForThrow,
+  FoundPathForThrow,
+  FoundPathWithNoThrowOutFunction,
+};
+
+static bool isThrowBeCaught(const CXXThrowExpr *Throw,
+const CXXCatchStmt *Catch) {
+  bool isCaught = false;
+  const Type *ThrowType = Throw->getSubExpr()->getType().getTypePtrOrNull();
+  const Type *CaughtType = Catch->getCaughtType().getTypePtrOrNull();
+
+   if (ThrowType->isReferenceType())
+ ThrowType = ThrowType->castAs()
+ ->getPointeeType()
+ ->getUnqualifiedDesugaredType();
+  if (CaughtType && CaughtType->isReferenceType())
+ CaughtType = CaughtType->castAs()
+  ->getPointeeType()
+  ->getUnqualifiedDesugaredType();
+  if (CaughtType == nullptr || CaughtType == ThrowType)
+return true;
+
+   const CXXRecordDecl *CaughtAsRecordType =
+   CaughtType->getPointeeCXXRecordDecl();
+  const CXXRecordDecl *ThrowTypeAsRecordType = ThrowType->getAsCXXRecordDecl();
+  if (CaughtAsRecordType && ThrowTypeAsRecordType)
+isCaught = ThrowTypeAsRecordType->isDerivedFrom(CaughtAsRecordType);
+  return isCaught;
+}
+
+static bool isThrowBeCaughtByHandlers(const CXXThrowExpr *CE,
+  const CXXTryStmt *TryStmt) {
+  for (unsigned H = 0; H < TryStmt->getNumHandlers(); ++H) {
+const CXXCatchStmt *CS = TryStmt->getHandler(H);
+if (isThrowBeCaught(CE, CS))
+  return true;
+  }
+  return false;
+}
+
+static bool doesThrowEscapePath(CFGBlock , SourceLocation *OpLoc) {
+  bool HasThrowOutFunc = false;
+  for (const clang::CFGElement  : Block) {
+if (B.getKind() != CFGElement::Statement)
+  continue;
+const CXXThrowExpr *CE =
+dyn_cast(B.getAs()->getStmt());
+if (!CE)
+  continue;
+else
+  HasThrowOutFunc = true;
+
+*OpLoc = CE->getThrowLoc();
+for (const CFGBlock::AdjacentBlock I : Block.succs())
+  if (I && I->getTerminator() && isa(I->getTerminator())) {
+const CXXTryStmt *Terminator = cast(I->getTerminator());
+if (isThrowBeCaughtByHandlers(CE, Terminator))
+  return false;
+  }
+  }
+  return HasThrowOutFunc;
+}
+
+static bool hasThrowOutNonThrowingFunc(const FunctionDecl *FD,
+   SourceLocation *OpLoc, CFG *cfg) {
+
+  const unsigned ExitID = cfg->getExit().getBlockID();
+
+  SmallVector States(cfg->getNumBlockIDs(),
+ FoundNoPathForThrow);
+  States[cfg->getEntry().getBlockID()] = FoundPathWithNoThrowOutFunction;
+
+  SmallVector Stack;
+  Stack.push_back(>getEntry());
+  while (!Stack.empty()) {
+CFGBlock *CurBlock = Stack.back();
+Stack.pop_back();
+
+unsigned ID = CurBlock->getBlockID();
+ThrowState CurState = States[ID];
+if (CurState == FoundPathWithNoThrowOutFunction) {
+  if (ExitID == ID)
+continue;
+
+  if (doesThrowEscapePath(*CurBlock, OpLoc))
+CurState = FoundPathForThrow;
+}
+
+// Loop over successor blocks and add them to the Stack if their state
+// changes.
+for (const CFGBlock::AdjacentBlock I : CurBlock->succs())
+  if (I) {
+unsigned next_ID = (I)->getBlockID();
+if (next_ID == ExitID && CurState == FoundPathForThrow) {
+  States[next_ID] = CurState;
+} else if (States[next_ID] < CurState) {
+  States[next_ID] = CurState;
+  Stack.push_back(I);
+}
+  }
+  }
+  // Return true if the exit node is reachable, and only reachable through
+  // a throw expression.
+  return States[ExitID] == FoundPathForThrow;
+}
+
+static void EmitDiagForCXXThrowInNonThrowingFunc(SourceLocation OpLoc, Sema ,
+ const FunctionDecl *FD) {
+  if (!S.getSourceManager().isInSystemHeader(OpLoc)) {
+S.Diag(OpLoc, diag::warn_throw_in_noexcept_func) << FD;
+if (S.getLangOpts().CPlusPlus11 &&
+(isa(FD) ||
+ FD->getDeclName().getCXXOverloadedOperator() == OO_Delete ||
+ FD->getDeclName().getCXXOverloadedOperator() == OO_Array_Delete))
+  S.Diag(FD->getLocation(), diag::note_throw_in_dtor);
+else
+  

r304519 - Minor fixes to for-loop warning.

2017-06-01 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Thu Jun  1 23:24:46 2017
New Revision: 304519

URL: http://llvm.org/viewvc/llvm-project?rev=304519=rev
Log:
Minor fixes to for-loop warning.

The warning for unchanged loop variables outputted a diagnostic that was
dependent on iteration order from a pointer set, which is not always
deterministic.  Switch to a set vector, which allows fast querying and
preserves ordering.

Also make other minor changes in this area.
Use more range-based for-loops.
Remove limitation on SourceRanges that no logner exists.

Modified:
cfe/trunk/lib/Sema/SemaStmt.cpp

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=304519=304518=304519=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Thu Jun  1 23:24:46 2017
@@ -1288,17 +1288,22 @@ Sema::ActOnDoStmt(SourceLocation DoLoc,
 }
 
 namespace {
+  // Use SetVector since the diagnostic cares about the ordering of the Decl's.
+  using DeclSetVector =
+  llvm::SetVector,
+  llvm::SmallPtrSet>;
+
   // This visitor will traverse a conditional statement and store all
   // the evaluated decls into a vector.  Simple is set to true if none
   // of the excluded constructs are used.
   class DeclExtractor : public EvaluatedExprVisitor {
-llvm::SmallPtrSetImpl 
+DeclSetVector 
 SmallVectorImpl 
 bool Simple;
   public:
 typedef EvaluatedExprVisitor Inherited;
 
-DeclExtractor(Sema , llvm::SmallPtrSetImpl ,
+DeclExtractor(Sema , DeclSetVector ,
   SmallVectorImpl ) :
 Inherited(S.Context),
 Decls(Decls),
@@ -1370,14 +1375,13 @@ namespace {
   // DeclMatcher checks to see if the decls are used in a non-evaluated
   // context.
   class DeclMatcher : public EvaluatedExprVisitor {
-llvm::SmallPtrSetImpl 
+DeclSetVector 
 bool FoundDecl;
 
   public:
 typedef EvaluatedExprVisitor Inherited;
 
-DeclMatcher(Sema , llvm::SmallPtrSetImpl ,
-Stmt *Statement) :
+DeclMatcher(Sema , DeclSetVector , Stmt *Statement) :
 Inherited(S.Context), Decls(Decls), FoundDecl(false) {
   if (!Statement) return;
 
@@ -1459,7 +1463,7 @@ namespace {
   return;
 
 PartialDiagnostic PDiag = S.PDiag(diag::warn_variables_not_in_loop_body);
-llvm::SmallPtrSet Decls;
+DeclSetVector Decls;
 SmallVector Ranges;
 DeclExtractor DE(S, Decls, Ranges);
 DE.Visit(Second);
@@ -1471,11 +1475,9 @@ namespace {
 if (Decls.size() == 0) return;
 
 // Don't warn on volatile, static, or global variables.
-for (llvm::SmallPtrSetImpl::iterator I = Decls.begin(),
-   E = Decls.end();
- I != E; ++I)
-  if ((*I)->getType().isVolatileQualified() ||
-  (*I)->hasGlobalStorage()) return;
+for (auto *VD : Decls)
+  if (VD->getType().isVolatileQualified() || VD->hasGlobalStorage())
+return;
 
 if (DeclMatcher(S, Decls, Second).FoundDeclInUse() ||
 DeclMatcher(S, Decls, Third).FoundDeclInUse() ||
@@ -1483,25 +1485,16 @@ namespace {
   return;
 
 // Load decl names into diagnostic.
-if (Decls.size() > 4)
+if (Decls.size() > 4) {
   PDiag << 0;
-else {
-  PDiag << Decls.size();
-  for (llvm::SmallPtrSetImpl::iterator I = Decls.begin(),
- E = Decls.end();
-   I != E; ++I)
-PDiag << (*I)->getDeclName();
-}
-
-// Load SourceRanges into diagnostic if there is room.
-// Otherwise, load the SourceRange of the conditional expression.
-if (Ranges.size() <= PartialDiagnostic::MaxArguments)
-  for (SmallVectorImpl::iterator I = Ranges.begin(),
-  E = Ranges.end();
-   I != E; ++I)
-PDiag << *I;
-else
-  PDiag << Second->getSourceRange();
+} else {
+  PDiag << (unsigned)Decls.size();
+  for (auto *VD : Decls)
+PDiag << VD->getDeclName();
+}
+
+for (auto Range : Ranges)
+  PDiag << Range;
 
 S.Diag(Ranges.begin()->getBegin(), PDiag);
   }


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


[PATCH] D32269: [Driver] Add iSOFTLinux to GNU ToolChains X86Triple

2017-06-01 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: test/Driver/linux-ld.c:467-471
+// RUN: %clang %s -### -o %t.o 2>&1 --target=x86_64-everest-linux
+// RUN: %clang %s -### -o %t.o 2>&1 --target=x86_64-pure64-linux
+// RUN: %clang %s -### -o %t.o 2>&1 --target=i686-isoft-linux
+// RUN: %clang %s -### -o %t.o 2>&1 --target=i686-everest-linux
+// RUN: %clang %s -### -o %t.o 2>&1 --target=i686-pure64-linux

These only invoke clang, but don't actually test anything.


Repository:
  rL LLVM

https://reviews.llvm.org/D32269



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


[PATCH] D33703: Support lazy stat'ing of files referenced by module maps

2017-06-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304515: Support lazy stat'ing of files referenced by module 
maps. (authored by rsmith).

Changed prior to commit:
  https://reviews.llvm.org/D33703?vs=101157=101162#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33703

Files:
  cfe/trunk/docs/Modules.rst
  cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
  cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
  cfe/trunk/include/clang/Basic/Module.h
  cfe/trunk/include/clang/Lex/ModuleMap.h
  cfe/trunk/lib/Basic/Module.cpp
  cfe/trunk/lib/Frontend/FrontendAction.cpp
  cfe/trunk/lib/Lex/HeaderSearch.cpp
  cfe/trunk/lib/Lex/ModuleMap.cpp
  cfe/trunk/lib/Lex/PPDirectives.cpp
  cfe/trunk/lib/Serialization/ASTWriter.cpp
  cfe/trunk/test/Modules/Inputs/header-attribs/bar.h
  cfe/trunk/test/Modules/Inputs/header-attribs/baz.h
  cfe/trunk/test/Modules/Inputs/header-attribs/foo.h
  cfe/trunk/test/Modules/Inputs/header-attribs/modular.modulemap
  cfe/trunk/test/Modules/Inputs/header-attribs/textual.modulemap
  cfe/trunk/test/Modules/diagnostics.modulemap
  cfe/trunk/test/Modules/header-attribs.cpp
  cfe/trunk/test/Modules/preprocess-missing.modulemap
  cfe/trunk/test/Modules/preprocess-module.cpp

Index: cfe/trunk/include/clang/Lex/ModuleMap.h
===
--- cfe/trunk/include/clang/Lex/ModuleMap.h
+++ cfe/trunk/include/clang/Lex/ModuleMap.h
@@ -26,6 +26,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/TinyPtrVector.h"
 #include "llvm/ADT/Twine.h"
 #include 
 #include 
@@ -116,6 +117,11 @@
 // Adjust ModuleMap::addHeader.
   };
 
+  /// Convert a header kind to a role. Requires Kind to not be HK_Excluded.
+  static ModuleHeaderRole headerKindToRole(Module::HeaderKind Kind);
+  /// Convert a header role to a kind.
+  static Module::HeaderKind headerRoleToKind(ModuleHeaderRole Role);
+
   /// \brief A header that is known to reside within a given module,
   /// whether it was included or excluded.
   class KnownHeader {
@@ -165,7 +171,13 @@
   /// \brief Mapping from each header to the module that owns the contents of
   /// that header.
   HeadersMap Headers;
-  
+
+  /// Map from file sizes to modules with lazy header directives of that size.
+  mutable llvm::DenseMap> LazyHeadersBySize;
+  /// Map from mtimes to modules with lazy header directives with those mtimes.
+  mutable llvm::DenseMap>
+  LazyHeadersByModTime;
+
   /// \brief Mapping from directories with umbrella headers to the module
   /// that is generated from the umbrella header.
   ///
@@ -257,22 +269,30 @@
   /// resolved.
   Module *resolveModuleId(const ModuleId , Module *Mod, bool Complain) const;
 
-  /// Resolve the given header directive to an actual header file.
+  /// Add an unresolved header to a module.
+  void addUnresolvedHeader(Module *Mod,
+   Module::UnresolvedHeaderDirective Header);
+
+  /// Look up the given header directive to find an actual header file.
   ///
   /// \param M The module in which we're resolving the header directive.
   /// \param Header The header directive to resolve.
   /// \param RelativePathName Filled in with the relative path name from the
   ///module to the resolved header.
   /// \return The resolved file, if any.
-  const FileEntry *resolveHeader(Module *M,
- Module::UnresolvedHeaderDirective Header,
- SmallVectorImpl );
+  const FileEntry *findHeader(Module *M,
+  const Module::UnresolvedHeaderDirective ,
+  SmallVectorImpl );
+
+  /// Resolve the given header directive.
+  void resolveHeader(Module *M,
+ const Module::UnresolvedHeaderDirective );
 
   /// Attempt to resolve the specified header directive as naming a builtin
   /// header.
-  const FileEntry *
-  resolveAsBuiltinHeader(Module *M, Module::UnresolvedHeaderDirective Header,
- SmallVectorImpl );
+  /// \return \c true if a corresponding builtin header was found.
+  bool resolveAsBuiltinHeader(Module *M,
+  const Module::UnresolvedHeaderDirective );
 
   /// \brief Looks up the modules that \p File corresponds to.
   ///
@@ -368,6 +388,15 @@
   /// the preferred module for the header.
   ArrayRef findAllModulesForHeader(const FileEntry *File) const;
 
+  /// Resolve all lazy header directives for the specified file.
+  ///
+  /// This ensures that the HeaderFileInfo on HeaderSearch is up to date. This
+  /// is effectively internal, but is exposed so HeaderSearch can call it.
+  void resolveHeaderDirectives(const FileEntry *File) const;
+
+  /// Resolve all lazy header directives for the specified module.
+  void resolveHeaderDirectives(Module 

r304515 - Support lazy stat'ing of files referenced by module maps.

2017-06-01 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jun  1 20:55:39 2017
New Revision: 304515

URL: http://llvm.org/viewvc/llvm-project?rev=304515=rev
Log:
Support lazy stat'ing of files referenced by module maps.

This patch adds support for a `header` declaration in a module map to specify
certain `stat` information (currently, size and mtime) about that header file.
This has two purposes:

- It removes the need to eagerly `stat` every file referenced by a module map.
  Instead, we track a list of unresolved header files with each size / mtime
  (actually, for simplicity, we track submodules with such headers), and when
  attempting to look up a header file based on a `FileEntry`, we check if there
  are any unresolved header directives with that `FileEntry`'s size / mtime and
  perform deferred `stat`s if so.

- It permits a preprocessed module to be compiled without the original files
  being present on disk. The only reason we used to need those files was to get
  the `stat` information in order to do header -> module lookups when using the
  module. If we're provided with the `stat` information in the preprocessed
  module, we can avoid requiring the files to exist.

Unlike most `header` directives, if a `header` directive with `stat`
information has no corresponding on-disk file the enclosing module is *not*
marked unavailable (so that behavior is consistent regardless of whether we've
resolved a header directive, and so that preprocessed modules don't get marked
unavailable). We could actually do this for all `header` directives: the only
reason we mark the module unavailable if headers are missing is to give a
diagnostic slightly earlier (rather than waiting until we actually try to build
the module / load and validate its .pcm file).

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

Added:
cfe/trunk/test/Modules/Inputs/header-attribs/
cfe/trunk/test/Modules/Inputs/header-attribs/bar.h
cfe/trunk/test/Modules/Inputs/header-attribs/baz.h
cfe/trunk/test/Modules/Inputs/header-attribs/foo.h
cfe/trunk/test/Modules/Inputs/header-attribs/modular.modulemap
cfe/trunk/test/Modules/Inputs/header-attribs/textual.modulemap
cfe/trunk/test/Modules/header-attribs.cpp
cfe/trunk/test/Modules/preprocess-missing.modulemap
Modified:
cfe/trunk/docs/Modules.rst
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/Modules/diagnostics.modulemap
cfe/trunk/test/Modules/preprocess-module.cpp

Modified: cfe/trunk/docs/Modules.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=304515=304514=304515=diff
==
--- cfe/trunk/docs/Modules.rst (original)
+++ cfe/trunk/docs/Modules.rst Thu Jun  1 20:55:39 2017
@@ -469,9 +469,16 @@ A header declaration specifies that a pa
 .. parsed-literal::
 
   *header-declaration*:
-``private``:sub:`opt` ``textual``:sub:`opt` ``header`` *string-literal*
-``umbrella`` ``header`` *string-literal*
-``exclude`` ``header`` *string-literal*
+``private``:sub:`opt` ``textual``:sub:`opt` ``header`` *string-literal* 
*header-attrs*:sub:`opt`
+``umbrella`` ``header`` *string-literal* *header-attrs*:sub:`opt`
+``exclude`` ``header`` *string-literal* *header-attrs*:sub:`opt`
+
+  *header-attrs*:
+'{' *header-attr** '}'
+
+  *header-attr*:
+``size`` *integer-literal*
+``mtime`` *integer-literal*
 
 A header declaration that does not contain ``exclude`` nor ``textual`` 
specifies a header that contributes to the enclosing module. Specifically, when 
the module is built, the named header will be parsed and its declarations will 
be (logically) placed into the enclosing submodule.
 
@@ -504,6 +511,18 @@ A header with the ``exclude`` specifier
 
 A given header shall not be referenced by more than one *header-declaration*.
 
+Two *header-declaration*\s, or a *header-declaration* and a ``#include``, are
+considered to refer to the same file if the paths resolve to the same file
+and the specified *header-attr*\s (if any) match the attributes of that file,
+even if the file is named differently (for instance, by a relative path or
+via symlinks).
+
+.. note::
+The use of *header-attr*\s avoids the need for Clang to speculatively
+``stat`` every header referenced by a module map. It is recommended that
+*header-attr*\s only be used in machine-generated module maps, to avoid
+mismatches between attribute values and the corresponding files.
+
 Umbrella directory declaration
 ~~
 An umbrella directory declaration 

[PATCH] D33788: Return a canonical path from getClangResourcePath()

2017-06-01 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a reviewer: bruno.
bruno added a comment.

Hi Aaron,

Nice catch! Any chance you can add a testcase to this?


https://reviews.llvm.org/D33788



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


[PATCH] D33703: Support lazy stat'ing of files referenced by module maps

2017-06-01 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D33703



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


[PATCH] D33703: Support lazy stat'ing of files referenced by module maps

2017-06-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 101157.
rsmith marked an inline comment as done.
rsmith added a comment.

Rebased and added requested test.


https://reviews.llvm.org/D33703

Files:
  docs/Modules.rst
  include/clang/Basic/DiagnosticLexKinds.td
  include/clang/Basic/DiagnosticSerializationKinds.td
  include/clang/Basic/Module.h
  include/clang/Lex/ModuleMap.h
  lib/Basic/Module.cpp
  lib/Frontend/FrontendAction.cpp
  lib/Lex/HeaderSearch.cpp
  lib/Lex/ModuleMap.cpp
  lib/Lex/PPDirectives.cpp
  lib/Serialization/ASTWriter.cpp
  test/Modules/Inputs/header-attribs/bar.h
  test/Modules/Inputs/header-attribs/baz.h
  test/Modules/Inputs/header-attribs/foo.h
  test/Modules/Inputs/header-attribs/modular.modulemap
  test/Modules/Inputs/header-attribs/textual.modulemap
  test/Modules/diagnostics.modulemap
  test/Modules/preprocess-missing.modulemap
  test/Modules/preprocess-module.cpp

Index: test/Modules/preprocess-module.cpp
===
--- test/Modules/preprocess-module.cpp
+++ test/Modules/preprocess-module.cpp
@@ -28,12 +28,21 @@
 // RUN: %clang_cc1 -fmodules -fmodule-file=%t/no-rewrite.pcm %s -I%t -verify -fno-modules-error-recovery -DINCLUDE -I%S/Inputs/preprocess
 // RUN: %clang_cc1 -fmodules -fmodule-file=%t/rewrite.pcm %s -I%t -verify -fno-modules-error-recovery -DREWRITE -DINCLUDE -I%S/Inputs/preprocess
 
+// Now try building the module when the header files are missing.
+// RUN: cp %S/Inputs/preprocess/fwd.h %S/Inputs/preprocess/file.h %S/Inputs/preprocess/file2.h %S/Inputs/preprocess/module.modulemap %t
+// RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm -I%t -x c++-module-map %t/module.modulemap -E -frewrite-includes -o %t/copy.ii
+// RUN: rm %t/fwd.h %t/file.h %t/file2.h %t/module.modulemap
+// RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm -x c++-module-map-cpp-output %t/copy.ii -emit-module -o %t/copy.pcm
+
+// Finally, check that our module contains correct mapping information for the headers.
+// RUN: cp %S/Inputs/preprocess/fwd.h %S/Inputs/preprocess/file.h %S/Inputs/preprocess/file2.h %S/Inputs/preprocess/module.modulemap %t
+// RUN: %clang_cc1 -fmodules -fmodule-file=%t/copy.pcm %s -I%t -verify -fno-modules-error-recovery -DCOPY -DINCLUDE
 
 // == module map
 // CHECK: # 1 "{{.*}}module.modulemap"
 // CHECK: module file {
-// CHECK:   header "file.h"
-// CHECK:   header "file2.h"
+// CHECK:   header "file.h" { size
+// CHECK:   header "file2.h" { size
 // CHECK: }
 
 // == file.h
@@ -98,6 +107,8 @@
 __FILE *a; // expected-error {{declaration of '__FILE' must be imported}}
 #ifdef REWRITE
 // expected-n...@rewrite.ii:1 {{here}}
+#elif COPY
+// expected-n...@copy.ii:1 {{here}}
 #else
 // expected-n...@no-rewrite.ii:1 {{here}}
 #endif
Index: test/Modules/preprocess-missing.modulemap
===
--- test/Modules/preprocess-missing.modulemap
+++ test/Modules/preprocess-missing.modulemap
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fmodules -fmodule-name=A -x c++-module-map %s -emit-module -o /dev/null -verify
+module A {
+  header "does not exist" { size 12345 } // ok, do not need mtime for explicit module build
+  header "also does not exist" { mtime 12345 }
+}
+#pragma clang module contents
+// expected-error@4 {{cannot emit module A: size must be explicitly specified for missing header file "also does not exist"}}
Index: test/Modules/diagnostics.modulemap
===
--- test/Modules/diagnostics.modulemap
+++ test/Modules/diagnostics.modulemap
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodule-map-file=%S/Inputs/diagnostics-aux.modulemap -fmodule-map-file=%s -fsyntax-only -x c++ /dev/null 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodule-map-file=%S/Inputs/diagnostics-aux.modulemap -fmodule-map-file=%s -fsyntax-only -x c++ /dev/null 2>&1 | FileCheck %s --implicit-check-not error:
 
 // CHECK: In file included from {{.*}}diagnostics-aux.modulemap:3:
 // CHECK: diagnostics-aux-2.modulemap:2:3: error: expected
@@ -15,3 +15,15 @@
   // CHECK: diagnostics.modulemap:[[@LINE+1]]:22: error: use declarations are only allowed in top-level modules
   module submodule { use foo }
 }
+
+module header_attr {
+  // CHECK: diagnostics.modulemap:[[@LINE+1]]:20: error: expected a header attribute name
+  header "foo.h" { x }
+  // CHECK: diagnostics.modulemap:[[@LINE+1]]:27: error: header attribute 'size' specified multiple times
+  header "bar.h" { size 1 size 2 }
+  // CHECK: diagnostics.modulemap:[[@LINE+1]]:25: error: expected integer literal as value for header attribute 'size'
+  header "baz.h" { size "30 kilobytes" }
+
+  header "quux.h" { size 1 mtime 2 }
+  header "no_attrs.h" {}
+}
Index: test/Modules/Inputs/header-attribs/textual.modulemap
===
--- 

[PATCH] D33719: Add _Float16 as a C/C++ source language type

2017-06-01 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Hi Sjoerd,

Thanks for working on this. Can you add context to your patch?




Comment at: test/CodeGenCXX/float16-declarations-error.cpp:1
+// RUN: not %clang -S -emit-llvm --target=aarch64 %s -o - 2>&1 | FileCheck %s 
--check-prefix=CHECK-ERROR
+

You don't need codegen to test this. Please move this test to test/Lexer, (see 
test/Lexer/half-literal.cpp).

Also, is `--target=aarch64` really needed here? I don't see anything ARM 
specific in this patch (maybe because I'm missing more context on the patch?).



Comment at: test/CodeGenCXX/float16-declarations.cpp:59
+func1t(f1l) + s1.mem2 - f1n + f2n;
+#if (__cplusplus >= 201103L)
+  auto f5l = -1.f16, *f6l = , f7l = func1t(f3l);

Please use `-std=c++11` in the RUN line on top of the file and remove the `#if` 
here. Can you provide a more reduced testcase and try to put the CHECK lines 
closer to the statements you want to check? The same ARM question from the 
comment above also applies here.


https://reviews.llvm.org/D33719



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


[PATCH] D33816: [Sema][ObjC] Don't allow -Wunguarded-availability to be silenced with redeclarations

2017-06-01 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.

This patch drops support for suppressing -Wunguarded-availability with 
redeclarations. This was behavior left over from the -Wpartial-availability 
days, where it was the only way of silencing the diagnostic. Now that we have 
@available and better support for annotating contexts with availability 
attributes, this behavior should be dropped. 
This would emit warnings on code that used the old way of silencing the 
diagnostic, but this method:

- Didn't have many users; it was clunky to use
- Has a simple upgrade path that is mentioned in the diagnostics we emit
- Allows for availability violations to go undetected

@thakis: I know the chromium project uses this warning, is this OK with you?

rdar://32388777

Thanks for taking a look,
Erik


https://reviews.llvm.org/D33816

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExpr.cpp
  test/Sema/attr-availability.c
  test/Sema/attr-deprecated.c
  test/Sema/attr-unavailable-message.c
  test/SemaCXX/attr-deprecated.cpp
  test/SemaObjC/attr-availability.m
  test/SemaObjC/unguarded-availability.m

Index: test/SemaObjC/unguarded-availability.m
===
--- test/SemaObjC/unguarded-availability.m
+++ test/SemaObjC/unguarded-availability.m
@@ -5,6 +5,8 @@
 #define AVAILABLE_10_11 __attribute__((availability(macos, introduced = 10.11)))
 #define AVAILABLE_10_12 __attribute__((availability(macos, introduced = 10.12)))
 
+typedef int AVAILABLE_10_12 new_int; // expected-note + {{marked partial here}}
+
 int func_10_11() AVAILABLE_10_11; // expected-note 4 {{'func_10_11' has been explicitly marked partial here}}
 
 #ifdef OBJCPP
@@ -70,9 +72,9 @@
 }
 
 __attribute__((objc_root_class))
-AVAILABLE_10_11 @interface Class_10_11 {
+AVAILABLE_10_11 @interface Class_10_11 { // expected-note{{annotate 'Class_10_11' with an availability attribute to silence}}
   int_10_11 foo;
-  int_10_12 bar; // expected-warning {{'int_10_12' is partial: introduced in macOS 10.12}} expected-note{{redeclare}}
+  int_10_12 bar; // expected-warning {{'int_10_12' is partial: introduced in macOS 10.12}}
 }
 - (void)method1;
 - (void)method2;
@@ -125,7 +127,7 @@
   };
 }
 
-void test_params(int_10_12 x); // expected-warning {{'int_10_12' is partial: introduced in macOS 10.12}} expected-note{{redeclare}}
+void test_params(int_10_12 x); // expected-warning {{'int_10_12' is partial: introduced in macOS 10.12}} expected-note{{annotate 'test_params' with an availability attribute to silence}}
 
 void test_params2(int_10_12 x) AVAILABLE_10_12; // no warn
 
@@ -234,3 +236,23 @@
 }
 
 #endif
+
+struct InStruct { // expected-note{{annotate 'InStruct' with an availability attribute to silence}}
+  new_int mem; // expected-warning{{'new_int' is partial}}
+
+  struct { new_int mem; } anon; // expected-warning{{'new_int' is partial}} expected-note{{annotate '' with an availability attribute}}
+};
+
+@interface InInterface
+-(new_int)meth; // expected-warning{{'new_int' is partial}} expected-note{{annotate 'meth' with an availability attribute}}
+@end
+
+@interface Proper // expected-note{{annotate 'Proper' with an availability attribute}}
+@property (class) new_int x; // expected-warning{{'new_int' is partial}}
+@end
+
+void with_local_struct() {
+  struct local { // expected-note{{annotate 'local' with an availability attribute}}
+new_int x; // expected-warning{{'new_int' is partial}}
+  };
+}
Index: test/SemaObjC/attr-availability.m
===
--- test/SemaObjC/attr-availability.m
+++ test/SemaObjC/attr-availability.m
@@ -13,7 +13,7 @@
 @interface A 
 - (void)method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); // expected-note {{'method' has been explicitly marked deprecated here}}
 #if defined(WARN_PARTIAL)
-  // expected-note@+2 {{'partialMethod' has been explicitly marked partial here}}
+  // expected-note@+2 2 {{'partialMethod' has been explicitly marked partial here}}
 #endif
 - (void)partialMethod __attribute__((availability(macosx,introduced=10.8)));
 
@@ -66,7 +66,10 @@
 @end
 
 void f_after_redecl(A *a, B *b) {
-  [a partialMethod]; // no warning
+#ifdef WARN_PARTIAL
+  // expected-warning@+2{{'partialMethod' is only available on macOS 10.8 or newer}} expected-note@+2 {{@available}}
+#endif
+  [a partialMethod];
   [b partialMethod]; // no warning
   [a partial_proto_method]; // no warning
   [b partial_proto_method]; // no warning
@@ -133,6 +136,10 @@
 @end
 
 @interface PartialI 
+#ifdef WARN_PARTIAL
+// expected-note@+3{{marked partial here}}
+// expected-note@+3{{marked partial here}}
+#endif
 - (void)partialMethod __attribute__((availability(macosx,introduced=10.8)));
 + (void)partialMethod __attribute__((availability(macosx,introduced=10.8)));
 @end
@@ -160,13 +167,19 @@
 @end
 
 void partialfun(PartialI* a) {
-  [a partialMethod]; // no warning
+#ifdef WARN_PARTIAL

[PATCH] D33739: [Sema] Improve -Wstrict-prototypes diagnostic message for blocks

2017-06-01 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304507: [Sema] Improve -Wstrict-prototypes diagnostic 
message for blocks. (authored by ahatanak).

Changed prior to commit:
  https://reviews.llvm.org/D33739?vs=100916=101155#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33739

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/Sema/warn-strict-prototypes.m

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4584,7 +4584,7 @@
 def note_declaration_not_a_prototype : Note<
   "this declaration is not a prototype; add 'void' to make it a prototype for a zero-parameter function">; 
 def warn_strict_prototypes : Warning<
-  "this %select{function declaration is not|"
+  "this %select{function declaration is not|block declaration is not|"
   "old-style function definition is not preceded by}0 a prototype">,
   InGroup>, DefaultIgnore;
 def warn_missing_variable_declarations : Warning<
Index: cfe/trunk/test/Sema/warn-strict-prototypes.m
===
--- cfe/trunk/test/Sema/warn-strict-prototypes.m
+++ cfe/trunk/test/Sema/warn-strict-prototypes.m
@@ -2,20 +2,25 @@
 
 @interface Foo
 
-@property (nonatomic, copy) void (^noProtoBlock)(); // expected-warning {{this function declaration is not a prototype}}
+@property (nonatomic, copy) void (^noProtoBlock)(); // expected-warning {{this block declaration is not a prototype}}
 @property (nonatomic, copy) void (^block)(void); // no warning
 
-- doStuff:(void (^)()) completionHandler; // expected-warning {{this function declaration is not a prototype}}
+- doStuff:(void (^)()) completionHandler; // expected-warning {{this block declaration is not a prototype}}
 - doOtherStuff:(void (^)(void)) completionHandler; // no warning
 
 @end
 
 void foo() {
-  void (^block)() = // expected-warning {{this function declaration is not a prototype}}
+  void (^block)() = // expected-warning {{this block declaration is not a prototype}}
 ^void(int arg) { // no warning
   };
   void (^block2)(void) = ^void() { // no warning
   };
   void (^block3)(void) = ^ { // no warning
   };
 }
+
+void (*(^(*(^block4)()) // expected-warning {{this block declaration is not a prototype}}
+ ()) // expected-warning {{this function declaration is not a prototype}}
+ ()) // expected-warning {{this block declaration is not a prototype}}
+ (); // expected-warning {{this function declaration is not a prototype}}
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -12309,7 +12309,7 @@
 TypeSourceInfo *TI = FD->getTypeSourceInfo();
 TypeLoc TL = TI->getTypeLoc();
 FunctionTypeLoc FTL = TL.getAsAdjusted();
-Diag(FTL.getLParenLoc(), diag::warn_strict_prototypes) << 1;
+Diag(FTL.getLParenLoc(), diag::warn_strict_prototypes) << 2;
   }
 }
 
Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -4347,19 +4347,6 @@
   if (FTI.isAmbiguous)
 warnAboutAmbiguousFunction(S, D, DeclType, T);
 
-  // GNU warning -Wstrict-prototypes
-  //   Warn if a function declaration is without a prototype.
-  //   This warning is issued for all kinds of unprototyped function
-  //   declarations (i.e. function type typedef, function pointer etc.)
-  //   C99 6.7.5.3p14:
-  //   The empty list in a function declarator that is not part of a
-  //   definition of that function specifies that no information
-  //   about the number or types of the parameters is supplied.
-  if (D.getFunctionDefinitionKind() == FDK_Declaration &&
-  FTI.NumParams == 0 && !LangOpts.CPlusPlus)
-S.Diag(DeclType.Loc, diag::warn_strict_prototypes)
-<< 0 << FixItHint::CreateInsertion(FTI.getRParenLoc(), "void");
-
   FunctionType::ExtInfo EI(getCCForDeclaratorChunk(S, D, FTI, chunkIndex));
 
   if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus) {
@@ -4602,6 +4589,36 @@
  const_cast(DeclType.getAttrs()));
   }
 
+  // GNU warning -Wstrict-prototypes
+  //   Warn if a function declaration is without a prototype.
+  //   This warning is issued for all kinds of unprototyped function
+  //   declarations (i.e. function type typedef, function pointer etc.)
+  //   C99 6.7.5.3p14:
+  //   The empty list in a function declarator that is not part of a definition
+  //   of that function specifies that no 

r304507 - [Sema] Improve -Wstrict-prototypes diagnostic message for blocks.

2017-06-01 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Jun  1 20:07:08 2017
New Revision: 304507

URL: http://llvm.org/viewvc/llvm-project?rev=304507=rev
Log:
[Sema] Improve -Wstrict-prototypes diagnostic message for blocks.

Print "this block declaration is not a prototype" for non-prototype
declarations of blocks instead of "this function declaration ...".

rdar://problem/32461723

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Sema/warn-strict-prototypes.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=304507=304506=304507=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jun  1 20:07:08 
2017
@@ -4584,7 +4584,7 @@ def warn_missing_prototype : Warning<
 def note_declaration_not_a_prototype : Note<
   "this declaration is not a prototype; add 'void' to make it a prototype for 
a zero-parameter function">; 
 def warn_strict_prototypes : Warning<
-  "this %select{function declaration is not|"
+  "this %select{function declaration is not|block declaration is not|"
   "old-style function definition is not preceded by}0 a prototype">,
   InGroup>, DefaultIgnore;
 def warn_missing_variable_declarations : Warning<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=304507=304506=304507=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jun  1 20:07:08 2017
@@ -12309,7 +12309,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl
 TypeSourceInfo *TI = FD->getTypeSourceInfo();
 TypeLoc TL = TI->getTypeLoc();
 FunctionTypeLoc FTL = TL.getAsAdjusted();
-Diag(FTL.getLParenLoc(), diag::warn_strict_prototypes) << 1;
+Diag(FTL.getLParenLoc(), diag::warn_strict_prototypes) << 2;
   }
 }
 

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=304507=304506=304507=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Jun  1 20:07:08 2017
@@ -4347,19 +4347,6 @@ static TypeSourceInfo *GetFullTypeForDec
   if (FTI.isAmbiguous)
 warnAboutAmbiguousFunction(S, D, DeclType, T);
 
-  // GNU warning -Wstrict-prototypes
-  //   Warn if a function declaration is without a prototype.
-  //   This warning is issued for all kinds of unprototyped function
-  //   declarations (i.e. function type typedef, function pointer etc.)
-  //   C99 6.7.5.3p14:
-  //   The empty list in a function declarator that is not part of a
-  //   definition of that function specifies that no information
-  //   about the number or types of the parameters is supplied.
-  if (D.getFunctionDefinitionKind() == FDK_Declaration &&
-  FTI.NumParams == 0 && !LangOpts.CPlusPlus)
-S.Diag(DeclType.Loc, diag::warn_strict_prototypes)
-<< 0 << FixItHint::CreateInsertion(FTI.getRParenLoc(), "void");
-
   FunctionType::ExtInfo EI(getCCForDeclaratorChunk(S, D, FTI, chunkIndex));
 
   if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus) {
@@ -4602,6 +4589,36 @@ static TypeSourceInfo *GetFullTypeForDec
  const_cast(DeclType.getAttrs()));
   }
 
+  // GNU warning -Wstrict-prototypes
+  //   Warn if a function declaration is without a prototype.
+  //   This warning is issued for all kinds of unprototyped function
+  //   declarations (i.e. function type typedef, function pointer etc.)
+  //   C99 6.7.5.3p14:
+  //   The empty list in a function declarator that is not part of a definition
+  //   of that function specifies that no information about the number or types
+  //   of the parameters is supplied.
+  if (!LangOpts.CPlusPlus && D.getFunctionDefinitionKind() == FDK_Declaration) 
{
+bool IsBlock = false;
+for (const DeclaratorChunk  : D.type_objects()) {
+  switch (DeclType.Kind) {
+  case DeclaratorChunk::BlockPointer:
+IsBlock = true;
+break;
+  case DeclaratorChunk::Function: {
+const DeclaratorChunk::FunctionTypeInfo  = DeclType.Fun;
+if (FTI.NumParams == 0)
+  S.Diag(DeclType.Loc, diag::warn_strict_prototypes)
+  << IsBlock
+  << FixItHint::CreateInsertion(FTI.getRParenLoc(), "void");
+IsBlock = false;
+break;
+  }
+  default:
+break;
+  }
+}
+  }
+
   assert(!T.isNull() && "T must not be 

r304506 - PR32848: There isn't necessarily a FileChanged or FileSkipped for every InclusionDirective callback.

2017-06-01 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jun  1 20:05:44 2017
New Revision: 304506

URL: http://llvm.org/viewvc/llvm-project?rev=304506=rev
Log:
PR32848: There isn't necessarily a FileChanged or FileSkipped for every 
InclusionDirective callback.

In particular, you don't get one if the inclusion directive encountered an
error. Don't assert in that case.

Added:
cfe/trunk/test/Frontend/rewrite-includes-filenotfound.c
Modified:
cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp

Modified: cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp?rev=304506=304505=304506=diff
==
--- cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp (original)
+++ cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp Thu Jun  1 20:05:44 
2017
@@ -177,7 +177,9 @@ void InclusionRewriter::FileSkipped(cons
 /// directives. It does not say whether the file has been included, but it
 /// provides more information about the directive (hash location instead
 /// of location inside the included file). It is assumed that the matching
-/// FileChanged() or FileSkipped() is called after this.
+/// FileChanged() or FileSkipped() is called after this (or neither is
+/// called if this #include results in an error or does not textually include
+/// anything).
 void InclusionRewriter::InclusionDirective(SourceLocation HashLoc,
const Token &/*IncludeTok*/,
StringRef /*FileName*/,
@@ -187,9 +189,6 @@ void InclusionRewriter::InclusionDirecti
StringRef /*SearchPath*/,
StringRef /*RelativePath*/,
const Module *Imported) {
-  assert(LastInclusionLocation.isInvalid() &&
- "Another inclusion directive was found before the previous one "
- "was processed");
   if (Imported) {
 auto P = ModuleIncludes.insert(
 std::make_pair(HashLoc.getRawEncoding(), Imported));

Added: cfe/trunk/test/Frontend/rewrite-includes-filenotfound.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/rewrite-includes-filenotfound.c?rev=304506=auto
==
--- cfe/trunk/test/Frontend/rewrite-includes-filenotfound.c (added)
+++ cfe/trunk/test/Frontend/rewrite-includes-filenotfound.c Thu Jun  1 20:05:44 
2017
@@ -0,0 +1,6 @@
+// RUN: not %clang_cc1 -E -frewrite-includes %s -o - 2>&1 | FileCheck %s
+
+#include "this file does not exist.foo"
+#include "this file also does not exist.foo"
+
+CHECK: fatal error: {{.*}} file not found


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


[PATCH] D32520: Support __fp16 vectors

2017-06-01 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Hi Akira,

This is nice, thanks for doing it!




Comment at: include/clang/Sema/Sema.h:9270
+   QualType RHSType,
+   bool CompAssign = false);
 

Can you change `CompAssign` to `IsCompAssign` so that we match the pattern used 
in other methods?



Comment at: include/clang/Sema/Sema.h:9279
+   bool ConvertRHS = true,
+   bool CompAssign = false);
 

Same here.



Comment at: lib/CodeGen/CGExprScalar.cpp:997
 
-  // Allow bitcast from vector to integer/fp of the same size.
-  if (isa(SrcTy) ||
-  isa(DstTy))
-return Builder.CreateBitCast(Src, DstTy, "conv");
+  if (isa(SrcTy) || isa(DstTy)) {
+auto GetSize = [](const llvm::Type *Ty) {

Please also add a comment explaining what's going on here, like we see for 
other snippets of logic above.

It also sounds like this is more generic than it should (which can have 
unexpected side effects due to the lack of testcases covering vector with other 
element sizes). I suggest you either (a) add testcases for other sizes or (b) 
make the condition more restrictive to be sure you're only changing the logic 
you intend to (i.e., half and i16).

After these changes, if it makes sense, can you refactor the logic under this 
condition into its own function? Seems like this function is too big already. 



Comment at: lib/Sema/SemaExpr.cpp:11433
   ExprObjectKind OK = OK_Ordinary;
+  bool ConvertHalfVec = false;
 

Assuming we're able to handle other vector types here, is it in 
`ConvertHalfVec` really necessary? It seems odd to me that we need to special 
case it in every case below. 



Comment at: test/Sema/fp16vec-sema.c:47
+  // clang currently disallows using these operators on vectors, which is
+  // allowed by gcc.
+  sv0 = !hv0; // expected-error{{invalid argument type}}

Can you add a FIXME here?


https://reviews.llvm.org/D32520



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


Re: r304376 - PR33232: implement support for MSVC's __is_trivially_destructible trait.

2017-06-01 Thread Richard Smith via cfe-commits
On 31 May 2017 at 17:41, Eric Fiselier  wrote:

> I'm assuming libc++ should move to this trait instead?
>

Yes, that'd be a good idea. Though now that you mention it, I'm not sure we
have a good feature detection story for these builtins. Looks like a bunch
of the existing ones are (oddly) covered by __has_feature, and they can all
be discovered through !__is_identifier, but __has_extension or
__has_builtin seem like the right detection mechanism and neither of them
works here. ;-(

Thoughts?


> /Eric
>
> On Wed, May 31, 2017 at 6:28 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Wed May 31 19:28:16 2017
>> New Revision: 304376
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=304376=rev
>> Log:
>> PR33232: implement support for MSVC's __is_trivially_destructible trait.
>>
>> Unlike the GCC-compatible __has_trivial_destructor trait, this one
>> computes the
>> right answer rather than performing the quirky set of checks described in
>> GCC's
>> documentation (https://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html).
>>
>> MSVC also has a __has_trivial_destructor trait which is the same as its
>> (and
>> now Clang's) __is_trivially_destructible trait; we might want to consider
>> changing the behavior of __has_trivial_destructor if we're targeting an
>> MSVC
>> platform, but I'm not doing so for now.
>>
>> While implementing this I found that we were incorrectly rejecting
>> __is_destructible queries on arrays of unknown bound of incomplete types;
>> that
>> too is fixed, and I've added similar tests for other traits for good
>> measure.
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/TokenKinds.def
>> cfe/trunk/include/clang/Basic/TypeTraits.h
>> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>> cfe/trunk/test/SemaCXX/type-traits.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/TokenKinds.def?rev=304376=304375=304376=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
>> +++ cfe/trunk/include/clang/Basic/TokenKinds.def Wed May 31 19:28:16 2017
>> @@ -411,6 +411,7 @@ TYPE_TRAIT_1(__is_sealed, IsSealed, KEYM
>>
>>  // MSVC12.0 / VS2013 Type Traits
>>  TYPE_TRAIT_1(__is_destructible, IsDestructible, KEYMS)
>> +TYPE_TRAIT_1(__is_trivially_destructible, IsTriviallyDestructible,
>> KEYCXX)
>>  TYPE_TRAIT_1(__is_nothrow_destructible, IsNothrowDestructible, KEYMS)
>>  TYPE_TRAIT_2(__is_nothrow_assignable, IsNothrowAssignable, KEYCXX)
>>  TYPE_TRAIT_N(__is_constructible, IsConstructible, KEYCXX)
>> @@ -439,7 +440,6 @@ TYPE_TRAIT_2(__is_convertible_to, IsConv
>>  TYPE_TRAIT_1(__is_empty, IsEmpty, KEYCXX)
>>  TYPE_TRAIT_1(__is_enum, IsEnum, KEYCXX)
>>  TYPE_TRAIT_1(__is_final, IsFinal, KEYCXX)
>> -// Tentative name - there's no implementation of std::is_literal_type
>> yet.
>>  TYPE_TRAIT_1(__is_literal, IsLiteral, KEYCXX)
>>  // Name for GCC 4.6 compatibility - people have already written
>> libraries using
>>  // this name unfortunately.
>>
>> Modified: cfe/trunk/include/clang/Basic/TypeTraits.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/TypeTraits.h?rev=304376=304375=304376=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/TypeTraits.h (original)
>> +++ cfe/trunk/include/clang/Basic/TypeTraits.h Wed May 31 19:28:16 2017
>> @@ -65,6 +65,7 @@ namespace clang {
>>  UTT_IsStandardLayout,
>>  UTT_IsTrivial,
>>  UTT_IsTriviallyCopyable,
>> +UTT_IsTriviallyDestructible,
>>  UTT_IsUnion,
>>  UTT_IsUnsigned,
>>  UTT_IsVoid,
>>
>> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaE
>> xprCXX.cpp?rev=304376=304375=304376=diff
>> 
>> ==
>> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed May 31 19:28:16 2017
>> @@ -4080,24 +4080,23 @@ static bool CheckUnaryTypeTraitTypeCompl
>>Loc, ArgTy, diag::err_incomplete_type_used
>> _in_type_trait_expr);
>>  return true;
>>
>> -  // C++0x [meta.unary.prop] Table 49 requires the following traits to be
>> -  // applied to a complete type.
>> +  // C++1z [meta.unary.prop]:
>> +  //   remove_all_extents_t shall be a complete type or cv void.
>>case UTT_IsAggregate:
>>case UTT_IsTrivial:
>>case UTT_IsTriviallyCopyable:
>>case UTT_IsStandardLayout:
>>case UTT_IsPOD:
>>case UTT_IsLiteral:
>> +ArgTy = QualType(ArgTy->getBaseElementTypeUnsafe(), 0);
>> +LLVM_FALLTHROUGH;
>>
>> +  // C++1z [meta.unary.prop]:
>> +  //   T shall be a complete type, cv void, or an array of unknown bound.
>>case UTT_IsDestructible:
>>case UTT_IsNothrowDestructible:
>> -// 

[PATCH] D33706: CodeGen: Cast temporary variable to proper address space

2017-06-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:3805
+Address Addr =
+CreateMemTemp(I->Ty, ArgInfo.getIndirectAlign(), "tmp", false);
 IRCallArgs[FirstIRArg] = Addr.getPointer();

How about "indirect-arg-temp" as the name here?



Comment at: lib/CodeGen/CGCall.cpp:3835
+  Address AI =
+  CreateMemTemp(I->Ty, ArgInfo.getIndirectAlign(), "tmp", false);
   IRCallArgs[FirstIRArg] = AI.getPointer();

"byval-temp"



Comment at: lib/CodeGen/CodeGenFunction.h:1937
+  /// address space.
+
+  llvm::AllocaInst *CreateTempAlloca(llvm::Type *Ty, const Twine  = "tmp",

You have an extra newline here.

Hmm.  I see what you're getting at with your addition to the comment, but I 
think the
real problem is that my original recommendation is just wrong.  Let's fix that.

"LangAS::Default is the address space of pointers to local variables and 
temporaries,
as exposed in the source language.  In certain configurations, this is not the 
same as
the alloca address space, and a cast is needed to lift the pointer from the 
alloca AS
into LangAS::Default.  This can happen when the target uses a restricted 
address space
for the stack but the source language requires LangAS::Default to be a generic 
address
space.  The latter condition is common for most programming languages; OpenCL 
is an
exception in that LangAS::Default is the private address space, which naturally 
maps
to the stack.

Because the address of a temporary is often exposed to the program in various 
ways,
this function will perform the cast by default.  The cast may be avoided by 
passing false
as \p CastToDefaultAddrSpace; this is more efficient if the caller knows that 
the address
will not be exposed."

And you should rename the parameter to CastToDefaultAddrSpace here and the other
places.


https://reviews.llvm.org/D33706



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


r304501 - [ThinLTO] Add x86 requires to thin_link_bitcode. NFC.

2017-06-01 Thread Tim Shen via cfe-commits
Author: timshen
Date: Thu Jun  1 19:08:58 2017
New Revision: 304501

URL: http://llvm.org/viewvc/llvm-project?rev=304501=rev
Log:
[ThinLTO] Add x86 requires to thin_link_bitcode. NFC.

It already specifies the triples, so the intention was to test x86 for
now (or then).

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

Modified:
cfe/trunk/test/CodeGen/thin_link_bitcode.c

Modified: cfe/trunk/test/CodeGen/thin_link_bitcode.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thin_link_bitcode.c?rev=304501=304500=304501=diff
==
--- cfe/trunk/test/CodeGen/thin_link_bitcode.c (original)
+++ cfe/trunk/test/CodeGen/thin_link_bitcode.c Thu Jun  1 19:08:58 2017
@@ -1,3 +1,5 @@
+// REQUIRES: x86-registered-target
+//
 // RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -triple 
x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
 // RUN: llvm-bcanalyzer -dump %t | FileCheck %s
 // RUN: llvm-bcanalyzer -dump %t.nodebug | FileCheck %s --check-prefix=NO_DEBUG


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


[PATCH] D33703: Support lazy stat'ing of files referenced by module maps

2017-06-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D33703#770896, @bruno wrote:

> - I've noticed in the patch that on the ASTWriter side we serialize the 
> introduced size / mtime, but there are no changes to the ASTReader, so I 
> assume in the reader side you still need the module map around to fetch those 
> infos, right?


On the reader side, we already support the case where the module map is absent, 
and already use the size / mtime as a key for `HeaderFileInfo` lookups, and 
when reading the SUBMODULE records we don't actually read the header file list 
at all, instead taking the relevant information from the `HeaderFileInfo` 
lookups. As a consequence, no changes to the reader are required.

> - Does this patch provide any benefits for the case where we don't provide a 
> size / mtime for the header in the module map? Since Size / ModTime are only 
> updated when parsing the module map I would assume no, but I might have 
> missed something.

No, it shouldn't change anything in the case where neither size nor mtime are 
provided. In those cases, we still eagerly stat the header so we can try to 
match later `#include`d files against it.


Repository:
  rL LLVM

https://reviews.llvm.org/D33703



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


[PATCH] D33108: Generate extra .ll files before/after optimization when using -save-temps.

2017-06-01 Thread Jorge Gorbe via Phabricator via cfe-commits
jgorbe added inline comments.



Comment at: lib/Driver/Driver.cpp:2603-2614
+  // lipo-able.
+  if (!MultiArchUniversalBuild) {
+if (isSaveTempsEnabled() && Phase == phases::Compile) {
+  Actions.push_back(
+  C.MakeAction(Current, types::TY_LLVM_IR));
+}
+if (isSaveTempsEnabled() && Phase == phases::Backend) {

tra wrote:
> Can this be moved below addHostDependenceToDeviceActions() on line 2626?
> See my comment in cuda-options.cu below for the reasons why it may be 
> necessary.
I have tried but it didn't cause the test to go back to the previous ordering 
where all device-side actions are executed before all host-side actions.

I have noticed that, before applying my patch, the action graph produced by 
clang with -ccc-print-phases doesn't seem to introduce any explicit dependency 
to guarantee that device-side actions are executed before host-side actions:

0: input, "cuda-options.cu", cuda, (host-cuda)
1: preprocessor, {0}, cuda-cpp-output, (host-cuda)
2: compiler, {1}, ir, (host-cuda)
3: input, "cuda-options.cu", cuda, (device-cuda, sm_20)
4: preprocessor, {3}, cuda-cpp-output, (device-cuda, sm_20)
5: compiler, {4}, ir, (device-cuda, sm_20)
6: backend, {5}, assembler, (device-cuda, sm_20)
7: assembler, {6}, object, (device-cuda, sm_20)
8: offload, "device-cuda (nvptx64-nvidia-cuda:sm_20)" {7}, object
9: offload, "device-cuda (nvptx64-nvidia-cuda:sm_20)" {6}, assembler
10: linker, {8, 9}, cuda-fatbin, (device-cuda)
11: offload, "host-cuda (x86_64--linux-gnu)" {2}, "device-cuda 
(nvptx64-nvidia-cuda)" {10}, ir
12: backend, {11}, assembler, (host-cuda)
13: assembler, {12}, object, (host-cuda)

I'm trying to figure out now if there's something else that enforces that 
restriction, or the current compilation order being the right one is a happy 
coincidence that my patch happened to disturb. I'm new to the project, so I'm 
working under the assumption that I'm missing something, any hints will be 
appreciated :)


https://reviews.llvm.org/D33108



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


r304499 - [CodeGen] Surround assertion with parentheses.

2017-06-01 Thread Davide Italiano via cfe-commits
Author: davide
Date: Thu Jun  1 18:55:18 2017
New Revision: 304499

URL: http://llvm.org/viewvc/llvm-project?rev=304499=rev
Log:
[CodeGen] Surround assertion with parentheses.

This should placate GCC's -Wparentheses.

Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=304499=304498=304499=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Thu Jun  1 18:55:18 2017
@@ -3887,7 +3887,7 @@ Value *CodeGenFunction::EmitCheckedInBou
   /// Return the result of the given binary operation.
   auto eval = [&](BinaryOperator::Opcode Opcode, llvm::Value *LHS,
   llvm::Value *RHS) -> llvm::Value * {
-assert(Opcode == BO_Add || Opcode == BO_Mul && "Can't eval binop");
+assert((Opcode == BO_Add || Opcode == BO_Mul) && "Can't eval binop");
 
 // If the operands are constants, return a constant result.
 if (auto *LHSCI = dyn_cast(LHS)) {


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


[PATCH] D33703: Support lazy stat'ing of files referenced by module maps

2017-06-01 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Hi Richard,

Thanks for improving this further!

Questions / comments:

- I've noticed in the patch that on the ASTWriter side we serialize the 
introduced size / mtime, but there are no changes to the ASTReader, so I assume 
in the reader side you still need the module map around to fetch those infos, 
right?
- Does this patch provide any benefits for the case where we don't provide a 
size / mtime for the header in the module map? Since Size / ModTime are only 
updated when parsing the module map I would assume no, but I might have missed 
something.




Comment at: include/clang/Basic/DiagnosticSerializationKinds.td:193
+  "cannot emit module %0: %select{size|mtime}1 must be explicitly specified "
+  "for missing header file \"%2\"">;
 } // let CategoryName

Can you add a testcase that test this error?


Repository:
  rL LLVM

https://reviews.llvm.org/D33703



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


[PATCH] D33692: [ThinLTO] Wire up ThinLTO and new PM

2017-06-01 Thread Tim Shen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304496: [ThinLTO] Wire up ThinLTO and new PM (authored by 
timshen).

Changed prior to commit:
  https://reviews.llvm.org/D33692?vs=101106=101135#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33692

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/test/CodeGen/thin_link_bitcode.c


Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -49,6 +49,7 @@
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
+#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
@@ -897,16 +898,32 @@
   // create that pass manager here and use it as needed below.
   legacy::PassManager CodeGenPasses;
   bool NeedCodeGen = false;
+  Optional ThinLinkOS;
 
   // Append any output we need to the pass manager.
   switch (Action) {
   case Backend_EmitNothing:
 break;
 
   case Backend_EmitBC:
-MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
-  CodeGenOpts.EmitSummaryIndex,
-  CodeGenOpts.EmitSummaryIndex));
+if (CodeGenOpts.EmitSummaryIndex) {
+  if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
+std::error_code EC;
+ThinLinkOS.emplace(CodeGenOpts.ThinLinkBitcodeFile, EC,
+   llvm::sys::fs::F_None);
+if (EC) {
+  Diags.Report(diag::err_fe_unable_to_open_output)
+  << CodeGenOpts.ThinLinkBitcodeFile << EC.message();
+  return;
+}
+  }
+  MPM.addPass(
+  ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &*ThinLinkOS : nullptr));
+} else {
+  MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
+CodeGenOpts.EmitSummaryIndex,
+CodeGenOpts.EmitSummaryIndex));
+}
 break;
 
   case Backend_EmitLL:
@@ -1029,6 +1046,7 @@
   Conf.CGOptLevel = getCGOptLevel(CGOpts);
   initTargetOptions(Conf.Options, CGOpts, TOpts, LOpts, HeaderOpts);
   Conf.SampleProfile = std::move(SampleProfile);
+  Conf.UseNewPM = CGOpts.ExperimentalNewPassManager;
   switch (Action) {
   case Backend_EmitNothing:
 Conf.PreCodeGenModuleHook = [](size_t Task, const Module ) {
Index: cfe/trunk/test/CodeGen/thin_link_bitcode.c
===
--- cfe/trunk/test/CodeGen/thin_link_bitcode.c
+++ cfe/trunk/test/CodeGen/thin_link_bitcode.c
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -triple 
x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
 // RUN: llvm-bcanalyzer -dump %t | FileCheck %s
 // RUN: llvm-bcanalyzer -dump %t.nodebug | FileCheck %s --check-prefix=NO_DEBUG
+// RUN: %clang_cc1 -o %t.newpm -flto=thin -fexperimental-new-pass-manager 
-fthin-link-bitcode=%t.newpm.nodebug -triple x86_64-unknown-linux-gnu 
-emit-llvm-bc -debug-info-kind=limited  %s
+// RUN: llvm-bcanalyzer -dump %t.newpm | FileCheck %s
+// RUN: llvm-bcanalyzer -dump %t.newpm.nodebug | FileCheck %s 
--check-prefix=NO_DEBUG
 int main (void) {
   return 0;
 }


Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -49,6 +49,7 @@
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
+#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
@@ -897,16 +898,32 @@
   // create that pass manager here and use it as needed below.
   legacy::PassManager CodeGenPasses;
   bool NeedCodeGen = false;
+  Optional ThinLinkOS;
 
   // Append any output we need to the pass manager.
   switch (Action) {
   case Backend_EmitNothing:
 break;
 
   case Backend_EmitBC:
-MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
-  CodeGenOpts.EmitSummaryIndex,
-  CodeGenOpts.EmitSummaryIndex));
+if (CodeGenOpts.EmitSummaryIndex) {
+  if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
+std::error_code EC;
+ThinLinkOS.emplace(CodeGenOpts.ThinLinkBitcodeFile, EC,
+   llvm::sys::fs::F_None);
+if (EC) {
+  Diags.Report(diag::err_fe_unable_to_open_output)
+  << CodeGenOpts.ThinLinkBitcodeFile << EC.message();
+  return;
+}
+  }
+  MPM.addPass(
+  

r304496 - [ThinLTO] Wire up ThinLTO and new PM

2017-06-01 Thread Tim Shen via cfe-commits
Author: timshen
Date: Thu Jun  1 18:27:51 2017
New Revision: 304496

URL: http://llvm.org/viewvc/llvm-project?rev=304496=rev
Log:
[ThinLTO] Wire up ThinLTO and new PM

Summary: This patch teaches clang to use and propagate new PM in ThinLTO.

Reviewers: davide, chandlerc, tejohnson

Subscribers: mehdi_amini, Prazek, inglorion, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CodeGen/thin_link_bitcode.c

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=304496=304495=304496=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun  1 18:27:51 2017
@@ -49,6 +49,7 @@
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
+#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
@@ -897,6 +898,7 @@ void EmitAssemblyHelper::EmitAssemblyWit
   // create that pass manager here and use it as needed below.
   legacy::PassManager CodeGenPasses;
   bool NeedCodeGen = false;
+  Optional ThinLinkOS;
 
   // Append any output we need to the pass manager.
   switch (Action) {
@@ -904,9 +906,24 @@ void EmitAssemblyHelper::EmitAssemblyWit
 break;
 
   case Backend_EmitBC:
-MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
-  CodeGenOpts.EmitSummaryIndex,
-  CodeGenOpts.EmitSummaryIndex));
+if (CodeGenOpts.EmitSummaryIndex) {
+  if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
+std::error_code EC;
+ThinLinkOS.emplace(CodeGenOpts.ThinLinkBitcodeFile, EC,
+   llvm::sys::fs::F_None);
+if (EC) {
+  Diags.Report(diag::err_fe_unable_to_open_output)
+  << CodeGenOpts.ThinLinkBitcodeFile << EC.message();
+  return;
+}
+  }
+  MPM.addPass(
+  ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &*ThinLinkOS : nullptr));
+} else {
+  MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
+CodeGenOpts.EmitSummaryIndex,
+CodeGenOpts.EmitSummaryIndex));
+}
 break;
 
   case Backend_EmitLL:
@@ -1029,6 +1046,7 @@ static void runThinLTOBackend(ModuleSumm
   Conf.CGOptLevel = getCGOptLevel(CGOpts);
   initTargetOptions(Conf.Options, CGOpts, TOpts, LOpts, HeaderOpts);
   Conf.SampleProfile = std::move(SampleProfile);
+  Conf.UseNewPM = CGOpts.ExperimentalNewPassManager;
   switch (Action) {
   case Backend_EmitNothing:
 Conf.PreCodeGenModuleHook = [](size_t Task, const Module ) {

Modified: cfe/trunk/test/CodeGen/thin_link_bitcode.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thin_link_bitcode.c?rev=304496=304495=304496=diff
==
--- cfe/trunk/test/CodeGen/thin_link_bitcode.c (original)
+++ cfe/trunk/test/CodeGen/thin_link_bitcode.c Thu Jun  1 18:27:51 2017
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -triple 
x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
 // RUN: llvm-bcanalyzer -dump %t | FileCheck %s
 // RUN: llvm-bcanalyzer -dump %t.nodebug | FileCheck %s --check-prefix=NO_DEBUG
+// RUN: %clang_cc1 -o %t.newpm -flto=thin -fexperimental-new-pass-manager 
-fthin-link-bitcode=%t.newpm.nodebug -triple x86_64-unknown-linux-gnu 
-emit-llvm-bc -debug-info-kind=limited  %s
+// RUN: llvm-bcanalyzer -dump %t.newpm | FileCheck %s
+// RUN: llvm-bcanalyzer -dump %t.newpm.nodebug | FileCheck %s 
--check-prefix=NO_DEBUG
 int main (void) {
   return 0;
 }


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


[libcxx] r304487 - [test] Allow non-libc++ coroutine_handle::done to strengthen noexcept

2017-06-01 Thread Casey Carter via cfe-commits
Author: caseycarter
Date: Thu Jun  1 17:40:16 2017
New Revision: 304487

URL: http://llvm.org/viewvc/llvm-project?rev=304487=rev
Log:
[test] Allow non-libc++ coroutine_handle::done to strengthen noexcept

Modified:

libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.completion/done.pass.cpp

libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/await_result.pass.cpp

libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp

libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.completion/done.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.completion/done.pass.cpp?rev=304487=304486=304487=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.completion/done.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.completion/done.pass.cpp
 Thu Jun  1 17:40:16 2017
@@ -33,7 +33,7 @@ void do_test(coro::coroutine_handlehttp://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/await_result.pass.cpp?rev=304487=304486=304487=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/await_result.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/await_result.pass.cpp
 Thu Jun  1 17:40:16 2017
@@ -23,7 +23,7 @@ struct coro_t {
 }
 suspend_never initial_suspend() { return {}; }
 suspend_never final_suspend() { return {}; }
-void return_void(){}
+void return_void() {}
 static void unhandled_exception() {}
   };
 };
@@ -37,7 +37,7 @@ struct B {
 
 
 struct A {
-  ~A(){}
+  ~A() {}
   bool await_ready() { return true; }
   int await_resume() { return 42; }
   template  void await_suspend(F) {}

Modified: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp?rev=304487=304486=304487=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
 Thu Jun  1 17:40:16 2017
@@ -25,7 +25,7 @@ struct coro_t {
 }
 suspend_never initial_suspend() { return {}; }
 suspend_never final_suspend() { return {}; }
-void return_void(){}
+void return_void() {}
 void unhandled_exception() {}
   };
   coro_t(coroutine_handle hh) : h(hh) {}

Modified: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp?rev=304487=304486=304487=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp
 Thu Jun  1 17:40:16 2017
@@ -68,10 +68,10 @@ private:
 
 std::vector yielded_values = {};
 int yield(int x) { yielded_values.push_back(x); return x + 1; }
-float fyield(int x) { yielded_values.push_back(x); return x + 2; }
+float fyield(int x) { yielded_values.push_back(x); return static_cast(x 
+ 2); }
 
 void Do1(func f) { yield(f()); }
-void Do2(func f) { yield(f()); }
+void Do2(func f) { yield(static_cast(f())); }
 
 int main() {
   Do1([] { return yield(43); });


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


Re: r304459 - [ubsan] Add a check for pointer overflow UB

2017-06-01 Thread Vedant Kumar via cfe-commits
I checked in r304486 to try and address the issue.

thanks,
vedant

> On Jun 1, 2017, at 3:21 PM, Vedant Kumar via cfe-commits 
>  wrote:
> 
> Taking a look.
> 
> vedant
> 
>> On Jun 1, 2017, at 2:45 PM, Galina Kistanova > > wrote:
>> 
>> Hello Vedant,
>> 
>> This commit broke tests on some of our builders:
>> 
>> Failing Tests (1):
>> Clang :: CodeGen/ubsan-pointer-overflow.m
>> 
>> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/2865/steps/test-check-all/logs/stdio
>>  
>> 
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/10259
>>  
>> 
>> http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/3097 
>> 
>> etc
>> 
>> Thanks
>> 
>> Galina
>> 
>> On Thu, Jun 1, 2017 at 12:22 PM, Vedant Kumar via cfe-commits 
>> > wrote:
>> Author: vedantk
>> Date: Thu Jun  1 14:22:18 2017
>> New Revision: 304459
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=304459=rev 
>> 
>> Log:
>> [ubsan] Add a check for pointer overflow UB
>> 
>> Check pointer arithmetic for overflow.
>> 
>> For some more background on this check, see:
>> 
>>   https://wdtz.org/catching-pointer-overflow-bugs.html 
>> 
>>   https://reviews.llvm.org/D20322 
>> 
>> Patch by Will Dietz and John Regehr!
>> 
>> This version of the patch is different from the original in a few ways:
>> 
>>   - It introduces the EmitCheckedInBoundsGEP utility which inserts
>> checks when the pointer overflow check is enabled.
>> 
>>   - It does some constant-folding to reduce instrumentation overhead.
>> 
>>   - It does not check some GEPs in CGExprCXX. I'm not sure that
>> inserting checks here, or in CGClass, would catch many bugs.
>> 
>> Possible future directions for this check:
>> 
>>   - Introduce CGF.EmitCheckedStructGEP, to detect overflows when
>> accessing structures.
>> 
>> Testing: Apart from the added lit test, I ran check-llvm and check-clang
>> with a stage2, ubsan-instrumented clang. Will and John have also done
>> extensive testing on numerous open source projects.
>> 
>> Differential Revision: https://reviews.llvm.org/D33305 
>> 
>> 
>> Added:
>> cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
>> Modified:
>> cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
>> cfe/trunk/include/clang/Basic/Sanitizers.def
>> cfe/trunk/lib/CodeGen/CGExpr.cpp
>> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
>> cfe/trunk/lib/CodeGen/CodeGenFunction.h
>> cfe/trunk/test/Driver/fsanitize.c
>> 
>> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=304459=304458=304459=diff
>>  
>> 
>> ==
>> --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
>> +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Thu Jun  1 14:22:18 2017
>> @@ -106,6 +106,8 @@ Available checks are:
>>   invalid pointers. These checks are made in terms of
>>   ``__builtin_object_size``, and consequently may be able to detect more
>>   problems at higher optimization levels.
>> +  -  ``-fsanitize=pointer-overflow``: Performing pointer arithmetic which
>> + overflows.
>>-  ``-fsanitize=return``: In C++, reaching the end of a
>>   value-returning function without returning a value.
>>-  ``-fsanitize=returns-nonnull-attribute``: Returning null pointer
>> 
>> Modified: cfe/trunk/include/clang/Basic/Sanitizers.def
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.def?rev=304459=304458=304459=diff
>>  
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/Sanitizers.def (original)
>> +++ cfe/trunk/include/clang/Basic/Sanitizers.def Thu Jun  1 14:22:18 2017
>> @@ -73,6 +73,7 @@ SANITIZER("nullability-return", Nullabil
>>  SANITIZER_GROUP("nullability", Nullability,
>>  NullabilityArg | NullabilityAssign | NullabilityReturn)
>>  SANITIZER("object-size", ObjectSize)
>> +SANITIZER("pointer-overflow", PointerOverflow)
>>  SANITIZER("return", Return)
>>  

r304486 - Relax test to try and appease builders. NFC.

2017-06-01 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Jun  1 17:27:39 2017
New Revision: 304486

URL: http://llvm.org/viewvc/llvm-project?rev=304486=rev
Log:
Relax test to try and appease builders. NFC.

I'm not sure why, but on some bots, the order of two instructions are
swapped (as compared to the output on my machine). Loosen up the
CHECK-NEXT directives to deal with this.

Failing bot: http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/3097

Modified:
cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m

Modified: cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m?rev=304486=304485=304486=diff
==
--- cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m (original)
+++ cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m Thu Jun  1 17:27:39 2017
@@ -37,9 +37,9 @@ void binary_arith(char *p, int i) {
   // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], 
!nosanitize
   // CHECK-NEXT: [[NEGVALID:%.*]] = icmp ult i64 [[COMPGEP]], [[BASE]], 
!nosanitize
   // CHECK-NEXT: [[POSOFFSET:%.*]] = icmp sge i64 [[SMULVAL]], 0, !nosanitize
-  // CHECK-NEXT: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, 
!nosanitize
-  // CHECK-NEXT: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], 
i1 [[NEGVALID]], !nosanitize
-  // CHECK-NEXT: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[DIFFVALID]], 
!nosanitize
+  // CHECK-DAG: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, !nosanitize
+  // CHECK-DAG: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], 
i1 [[NEGVALID]], !nosanitize
+  // CHECK: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[DIFFVALID]], !nosanitize
   // CHECK-NEXT: br i1 [[VALID]]{{.*}}, !nosanitize
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}, i64 [[BASE]], 
i64 [[COMPGEP]]){{.*}}, !nosanitize
   p + i;
@@ -62,9 +62,9 @@ void fixed_len_array(int k) {
   // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], 
!nosanitize
   // CHECK-NEXT: [[NEGVALID:%.*]] = icmp ult i64 [[COMPGEP]], [[BASE]], 
!nosanitize
   // CHECK-NEXT: [[POSOFFSET:%.*]] = icmp sge i64 [[SMULVAL]], 0, !nosanitize
-  // CHECK-NEXT: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, 
!nosanitize
-  // CHECK-NEXT: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], 
i1 [[NEGVALID]], !nosanitize
-  // CHECK-NEXT: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[DIFFVALID]], 
!nosanitize
+  // CHECK-DAG: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, !nosanitize
+  // CHECK-DAG: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], 
i1 [[NEGVALID]], !nosanitize
+  // CHECK: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[DIFFVALID]], !nosanitize
   // CHECK-NEXT: br i1 [[VALID]]{{.*}}, !nosanitize
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}, i64 [[BASE]], 
i64 [[COMPGEP]]){{.*}}, !nosanitize
 


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


Re: r304459 - [ubsan] Add a check for pointer overflow UB

2017-06-01 Thread Vedant Kumar via cfe-commits
Taking a look.

vedant

> On Jun 1, 2017, at 2:45 PM, Galina Kistanova  wrote:
> 
> Hello Vedant,
> 
> This commit broke tests on some of our builders:
> 
> Failing Tests (1):
> Clang :: CodeGen/ubsan-pointer-overflow.m
> 
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/2865/steps/test-check-all/logs/stdio
>  
> 
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/10259
>  
> 
> http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/3097 
> 
> etc
> 
> Thanks
> 
> Galina
> 
> On Thu, Jun 1, 2017 at 12:22 PM, Vedant Kumar via cfe-commits 
> > wrote:
> Author: vedantk
> Date: Thu Jun  1 14:22:18 2017
> New Revision: 304459
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=304459=rev 
> 
> Log:
> [ubsan] Add a check for pointer overflow UB
> 
> Check pointer arithmetic for overflow.
> 
> For some more background on this check, see:
> 
>   https://wdtz.org/catching-pointer-overflow-bugs.html 
> 
>   https://reviews.llvm.org/D20322 
> 
> Patch by Will Dietz and John Regehr!
> 
> This version of the patch is different from the original in a few ways:
> 
>   - It introduces the EmitCheckedInBoundsGEP utility which inserts
> checks when the pointer overflow check is enabled.
> 
>   - It does some constant-folding to reduce instrumentation overhead.
> 
>   - It does not check some GEPs in CGExprCXX. I'm not sure that
> inserting checks here, or in CGClass, would catch many bugs.
> 
> Possible future directions for this check:
> 
>   - Introduce CGF.EmitCheckedStructGEP, to detect overflows when
> accessing structures.
> 
> Testing: Apart from the added lit test, I ran check-llvm and check-clang
> with a stage2, ubsan-instrumented clang. Will and John have also done
> extensive testing on numerous open source projects.
> 
> Differential Revision: https://reviews.llvm.org/D33305 
> 
> 
> Added:
> cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
> Modified:
> cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> cfe/trunk/include/clang/Basic/Sanitizers.def
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/test/Driver/fsanitize.c
> 
> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=304459=304458=304459=diff
>  
> 
> ==
> --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
> +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Thu Jun  1 14:22:18 2017
> @@ -106,6 +106,8 @@ Available checks are:
>   invalid pointers. These checks are made in terms of
>   ``__builtin_object_size``, and consequently may be able to detect more
>   problems at higher optimization levels.
> +  -  ``-fsanitize=pointer-overflow``: Performing pointer arithmetic which
> + overflows.
>-  ``-fsanitize=return``: In C++, reaching the end of a
>   value-returning function without returning a value.
>-  ``-fsanitize=returns-nonnull-attribute``: Returning null pointer
> 
> Modified: cfe/trunk/include/clang/Basic/Sanitizers.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.def?rev=304459=304458=304459=diff
>  
> 
> ==
> --- cfe/trunk/include/clang/Basic/Sanitizers.def (original)
> +++ cfe/trunk/include/clang/Basic/Sanitizers.def Thu Jun  1 14:22:18 2017
> @@ -73,6 +73,7 @@ SANITIZER("nullability-return", Nullabil
>  SANITIZER_GROUP("nullability", Nullability,
>  NullabilityArg | NullabilityAssign | NullabilityReturn)
>  SANITIZER("object-size", ObjectSize)
> +SANITIZER("pointer-overflow", PointerOverflow)
>  SANITIZER("return", Return)
>  SANITIZER("returns-nonnull-attribute", ReturnsNonnullAttribute)
>  SANITIZER("shift-base", ShiftBase)
> @@ -108,9 +109,9 @@ SANITIZER("safe-stack", SafeStack)
>  SANITIZER_GROUP("undefined", Undefined,
>  Alignment | Bool | ArrayBounds | Enum | FloatCastOverflow |
>  FloatDivideByZero | 

Re: r304459 - [ubsan] Add a check for pointer overflow UB

2017-06-01 Thread Galina Kistanova via cfe-commits
Hello Vedant,

This commit broke tests on some of our builders:

Failing Tests (1):
Clang :: CodeGen/ubsan-pointer-overflow.m

http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/2865/steps/test-check-all/logs/stdio
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/10259
http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/3097
etc

Thanks

Galina

On Thu, Jun 1, 2017 at 12:22 PM, Vedant Kumar via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: vedantk
> Date: Thu Jun  1 14:22:18 2017
> New Revision: 304459
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304459=rev
> Log:
> [ubsan] Add a check for pointer overflow UB
>
> Check pointer arithmetic for overflow.
>
> For some more background on this check, see:
>
>   https://wdtz.org/catching-pointer-overflow-bugs.html
>   https://reviews.llvm.org/D20322
>
> Patch by Will Dietz and John Regehr!
>
> This version of the patch is different from the original in a few ways:
>
>   - It introduces the EmitCheckedInBoundsGEP utility which inserts
> checks when the pointer overflow check is enabled.
>
>   - It does some constant-folding to reduce instrumentation overhead.
>
>   - It does not check some GEPs in CGExprCXX. I'm not sure that
> inserting checks here, or in CGClass, would catch many bugs.
>
> Possible future directions for this check:
>
>   - Introduce CGF.EmitCheckedStructGEP, to detect overflows when
> accessing structures.
>
> Testing: Apart from the added lit test, I ran check-llvm and check-clang
> with a stage2, ubsan-instrumented clang. Will and John have also done
> extensive testing on numerous open source projects.
>
> Differential Revision: https://reviews.llvm.org/D33305
>
> Added:
> cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
> Modified:
> cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> cfe/trunk/include/clang/Basic/Sanitizers.def
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/test/Driver/fsanitize.c
>
> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
> UndefinedBehaviorSanitizer.rst?rev=304459=304458=304459=diff
> 
> ==
> --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
> +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Thu Jun  1 14:22:18 2017
> @@ -106,6 +106,8 @@ Available checks are:
>   invalid pointers. These checks are made in terms of
>   ``__builtin_object_size``, and consequently may be able to detect
> more
>   problems at higher optimization levels.
> +  -  ``-fsanitize=pointer-overflow``: Performing pointer arithmetic which
> + overflows.
>-  ``-fsanitize=return``: In C++, reaching the end of a
>   value-returning function without returning a value.
>-  ``-fsanitize=returns-nonnull-attribute``: Returning null pointer
>
> Modified: cfe/trunk/include/clang/Basic/Sanitizers.def
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/Sanitizers.def?rev=304459=304458=304459=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/Sanitizers.def (original)
> +++ cfe/trunk/include/clang/Basic/Sanitizers.def Thu Jun  1 14:22:18 2017
> @@ -73,6 +73,7 @@ SANITIZER("nullability-return", Nullabil
>  SANITIZER_GROUP("nullability", Nullability,
>  NullabilityArg | NullabilityAssign | NullabilityReturn)
>  SANITIZER("object-size", ObjectSize)
> +SANITIZER("pointer-overflow", PointerOverflow)
>  SANITIZER("return", Return)
>  SANITIZER("returns-nonnull-attribute", ReturnsNonnullAttribute)
>  SANITIZER("shift-base", ShiftBase)
> @@ -108,9 +109,9 @@ SANITIZER("safe-stack", SafeStack)
>  SANITIZER_GROUP("undefined", Undefined,
>  Alignment | Bool | ArrayBounds | Enum | FloatCastOverflow
> |
>  FloatDivideByZero | IntegerDivideByZero |
> NonnullAttribute |
> -Null | ObjectSize | Return | ReturnsNonnullAttribute |
> -Shift | SignedIntegerOverflow | Unreachable |
> VLABound |
> -Function | Vptr)
> +Null | ObjectSize | PointerOverflow | Return |
> +ReturnsNonnullAttribute | Shift |
> SignedIntegerOverflow |
> +Unreachable | VLABound | Function | Vptr)
>
>  // -fsanitize=undefined-trap is an alias for -fsanitize=undefined.
>  SANITIZER_GROUP("undefined-trap", UndefinedTrap, Undefined)
>
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGExpr.cpp?rev=304459=304458=304459=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> +++ 

Re: [PATCH] D33424: Lexer: allow imaginary constants in GNU mode (only).

2017-06-01 Thread Richard Smith via cfe-commits
On 1 June 2017 at 14:36, Tim Northover  wrote:

> On 26 May 2017 at 11:29, Richard Smith  wrote:
> > If we generally think that distinction is a good thing, then (because
> this
> > is a conforming extension) consistency weakly suggests that it should
> not be
> > controlled by GNU mode. But I don't find that argument decisive; the
> > important thing is that we don't enable non-conforming extensions by
> default
> > in non-GNU (and non-MS-compat) modes, not that GNU mode consists of
> /only/
> > non-conforming extensions.
>
> I'm pretty convinced by the conforming/non-conforming distinction and
> consistency argument. And think that the Microsoft way seems even
> better for the future.
>
> Making the libc++ test pass is pretty ugly, but I've managed to get it
> working by building with "-Werror=gnu-imaginary-constant".
>
> Marshall, I know this really isn't your preferred solution but can you
> stomach it if I also make sure we do the extra diagnostics so it's
> difficult to misuse?
>
> > Looking at the
> >
> >   std::complex x = 1.0if;
> >
> > case again, I think there's another problem here: we support an implicit
> > conversion from _Complex float to float in C++ (without even a warning).
> > This conversion is valid in C, but at least GCC disallows it in its C++
> > mode. We should probably at least warn on that.
>
> Definitely. I think the error from G++ is probably the right choice.
> I'll get cracking on that, it's a good idea regardless of what happens
> here.
>

Great, thanks, your intended direction makes sense to me.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33721: [ARM] Add support for target("arm") and target("thumb").

2017-06-01 Thread Eric Christopher via Phabricator via cfe-commits
echristo added inline comments.



Comment at: lib/Basic/Targets.cpp:5439-5442
+// [-|+]thumb-mode target features respectively.
+std::vector UpdatedFeaturesVec(FeaturesVec);
+for (auto  : UpdatedFeaturesVec) {
+  if (Feature.compare("+arm") == 0)

Won't work below in handleTargetFeatures?


https://reviews.llvm.org/D33721



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


[PATCH] D33692: [ThinLTO] Wire up ThinLTO and new PM

2017-06-01 Thread Davide Italiano via Phabricator via cfe-commits
davide added a comment.

LGTM once the other patch lands.


https://reviews.llvm.org/D33692



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


Re: [PATCH] D33424: Lexer: allow imaginary constants in GNU mode (only).

2017-06-01 Thread Tim Northover via cfe-commits
On 26 May 2017 at 11:29, Richard Smith  wrote:
> If we generally think that distinction is a good thing, then (because this
> is a conforming extension) consistency weakly suggests that it should not be
> controlled by GNU mode. But I don't find that argument decisive; the
> important thing is that we don't enable non-conforming extensions by default
> in non-GNU (and non-MS-compat) modes, not that GNU mode consists of /only/
> non-conforming extensions.

I'm pretty convinced by the conforming/non-conforming distinction and
consistency argument. And think that the Microsoft way seems even
better for the future.

Making the libc++ test pass is pretty ugly, but I've managed to get it
working by building with "-Werror=gnu-imaginary-constant".

Marshall, I know this really isn't your preferred solution but can you
stomach it if I also make sure we do the extra diagnostics so it's
difficult to misuse?

> Looking at the
>
>   std::complex x = 1.0if;
>
> case again, I think there's another problem here: we support an implicit
> conversion from _Complex float to float in C++ (without even a warning).
> This conversion is valid in C, but at least GCC disallows it in its C++
> mode. We should probably at least warn on that.

Definitely. I think the error from G++ is probably the right choice.
I'll get cracking on that, it's a good idea regardless of what happens
here.

Cheers.

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


[PATCH] D33692: [ThinLTO] Wire up ThinLTO and new PM

2017-06-01 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

This patch LGTM whenever the underlying LLVM change lands, thanks


https://reviews.llvm.org/D33692



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


r304481 - Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

2017-06-01 Thread Galina Kistanova via cfe-commits
Author: gkistanova
Date: Thu Jun  1 16:29:45 2017
New Revision: 304481

URL: http://llvm.org/viewvc/llvm-project?rev=304481=rev
Log:
Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

Modified:
cfe/trunk/lib/Parse/ParseTentative.cpp

Modified: cfe/trunk/lib/Parse/ParseTentative.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=304481=304480=304481=diff
==
--- cfe/trunk/lib/Parse/ParseTentative.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTentative.cpp Thu Jun  1 16:29:45 2017
@@ -1450,6 +1450,7 @@ Parser::isCXXDeclarationSpecifier(Parser
   return TPResult::False;
 }
 // If that succeeded, fallthrough into the generic simple-type-id case.
+LLVM_FALLTHROUGH;
 
 // The ambiguity resides in a simple-type-specifier/typename-specifier
 // followed by a '('. The '(' could either be the start of:
@@ -1492,6 +1493,7 @@ Parser::isCXXDeclarationSpecifier(Parser
   
   return TPResult::True;
 }
+LLVM_FALLTHROUGH;
   
   case tok::kw_char:
   case tok::kw_wchar_t:


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


r304479 - Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

2017-06-01 Thread Galina Kistanova via cfe-commits
Author: gkistanova
Date: Thu Jun  1 16:28:26 2017
New Revision: 304479

URL: http://llvm.org/viewvc/llvm-project?rev=304479=rev
Log:
Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

Modified:
cfe/trunk/lib/Parse/ParseStmt.cpp

Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=304479=304478=304479=diff
==
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Thu Jun  1 16:28:26 2017
@@ -203,6 +203,7 @@ Retry:
 }
 
 // Fall through
+LLVM_FALLTHROUGH;
   }
 
   default: {


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


r304478 - Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

2017-06-01 Thread Galina Kistanova via cfe-commits
Author: gkistanova
Date: Thu Jun  1 16:26:38 2017
New Revision: 304478

URL: http://llvm.org/viewvc/llvm-project?rev=304478=rev
Log:
Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

Modified:
cfe/trunk/lib/Parse/ParseOpenMP.cpp

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=304478=304477=304478=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Thu Jun  1 16:26:38 2017
@@ -192,6 +192,7 @@ static DeclarationName parseOpenMPReduct
   case tok::identifier: // identifier
 if (!WithOperator)
   break;
+LLVM_FALLTHROUGH;
   default:
 P.Diag(Tok.getLocation(), diag::err_omp_expected_reduction_identifier);
 P.SkipUntil(tok::colon, tok::r_paren, tok::annot_pragma_openmp_end,
@@ -869,6 +870,7 @@ StmtResult Parser::ParseOpenMPDeclarativ
   // pseudo-clause OMPFlushClause.
   PP.EnterToken(Tok);
 }
+LLVM_FALLTHROUGH;
   case OMPD_taskyield:
   case OMPD_barrier:
   case OMPD_taskwait:
@@ -883,6 +885,7 @@ StmtResult Parser::ParseOpenMPDeclarativ
 }
 HasAssociatedStatement = false;
 // Fall through for further analysis.
+LLVM_FALLTHROUGH;
   case OMPD_parallel:
   case OMPD_simd:
   case OMPD_for:
@@ -1184,6 +1187,7 @@ OMPClause *Parser::ParseOpenMPClause(Ope
   << getOpenMPDirectiveName(DKind) << getOpenMPClauseName(CKind) << 0;
   ErrorFound = true;
 }
+LLVM_FALLTHROUGH;
 
   case OMPC_if:
 Clause = ParseOpenMPSingleExprWithArgClause(CKind);


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


r304477 - Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

2017-06-01 Thread Galina Kistanova via cfe-commits
Author: gkistanova
Date: Thu Jun  1 16:23:52 2017
New Revision: 304477

URL: http://llvm.org/viewvc/llvm-project?rev=304477=rev
Log:
Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

Modified:
cfe/trunk/lib/Parse/ParseInit.cpp

Modified: cfe/trunk/lib/Parse/ParseInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseInit.cpp?rev=304477=304476=304477=diff
==
--- cfe/trunk/lib/Parse/ParseInit.cpp (original)
+++ cfe/trunk/lib/Parse/ParseInit.cpp Thu Jun  1 16:23:52 2017
@@ -501,7 +501,8 @@ bool Parser::ParseMicrosoftIfExistsBrace
 Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
   << Result.IsIfExists;
 // Fall through to skip.
-  
+LLVM_FALLTHROUGH;
+
   case IEB_Skip:
 Braces.skipToEnd();
 return false;


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


r304475 - Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

2017-06-01 Thread Galina Kistanova via cfe-commits
Author: gkistanova
Date: Thu Jun  1 16:21:49 2017
New Revision: 304475

URL: http://llvm.org/viewvc/llvm-project?rev=304475=rev
Log:
Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=304475=304474=304475=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Thu Jun  1 16:21:49 2017
@@ -1314,6 +1314,7 @@ ExprResult Parser::ParseCastExpression(b
 }
 
 // Fall through to treat the template-id as an id-expression.
+LLVM_FALLTHROUGH;
   }
 
   case tok::kw_operator: // [C++] id-expression: 
operator/conversion-function-id
@@ -1484,9 +1485,9 @@ Parser::ParsePostfixExpressionSuffix(Exp
  nullptr, LHS.get());
 break;
   }
-
   // Fall through; this isn't a message send.
-
+  LLVM_FALLTHROUGH;
+
 default:  // Not a postfix-expression suffix.
   return LHS;
 case tok::l_square: {  // postfix-expression: p-e '[' expression ']'


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


r304473 - Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

2017-06-01 Thread Galina Kistanova via cfe-commits
Author: gkistanova
Date: Thu Jun  1 16:19:06 2017
New Revision: 304473

URL: http://llvm.org/viewvc/llvm-project?rev=304473=rev
Log:
Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

Modified:
cfe/trunk/lib/Parse/ParseDeclCXX.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=304473=304472=304473=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Thu Jun  1 16:19:06 2017
@@ -4215,6 +4215,7 @@ void Parser::ParseMicrosoftIfExistsClass
 Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
   << Result.IsIfExists;
 // Fall through to skip.
+LLVM_FALLTHROUGH;
   
   case IEB_Skip:
 Braces.skipToEnd();


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


r304472 - Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

2017-06-01 Thread Galina Kistanova via cfe-commits
Author: gkistanova
Date: Thu Jun  1 16:15:34 2017
New Revision: 304472

URL: http://llvm.org/viewvc/llvm-project?rev=304472=rev
Log:
Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=304472=304471=304472=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Jun  1 16:15:34 2017
@@ -2552,6 +2552,7 @@ bool Parser::ParseImplicitInt(DeclSpec &
 }
   }
   // Fall through.
+  LLVM_FALLTHROUGH;
 }
 case tok::comma:
 case tok::equal:
@@ -3678,6 +3679,7 @@ void Parser::ParseDeclarationSpecifiers(
 isInvalid = true;
 break;
   };
+  LLVM_FALLTHROUGH;
 case tok::kw___private:
 case tok::kw___global:
 case tok::kw___local:
@@ -5045,6 +5047,7 @@ void Parser::ParseTypeQualifierListOpt(
 if (TryKeywordIdentFallback(false))
   continue;
   }
+  LLVM_FALLTHROUGH;
 case tok::kw___sptr:
 case tok::kw___w64:
 case tok::kw___ptr64:
@@ -5094,6 +5097,7 @@ void Parser::ParseTypeQualifierListOpt(
 continue; // do *not* consume the next token!
   }
   // otherwise, FALL THROUGH!
+  LLVM_FALLTHROUGH;
 default:
   DoneWithTypeQuals:
   // If this is not a type-qualifier token, we're done reading type


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


[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it

2017-06-01 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304470: [CGDebugInfo] Finalize SubPrograms when we're done 
with them (authored by kfischer).

Changed prior to commit:
  https://reviews.llvm.org/D33705?vs=101092=101107#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33705

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.h
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -3263,7 +3263,7 @@
 
 void CGDebugInfo::EmitInlineFunctionEnd(CGBuilderTy ) {
   assert(CurInlinedAt && "unbalanced inline scope stack");
-  EmitFunctionEnd(Builder);
+  EmitFunctionEnd(Builder, nullptr);
   setInlinedAt(llvm::DebugLoc(CurInlinedAt).getInlinedAt());
 }
 
@@ -3332,7 +3332,7 @@
   LexicalBlockStack.pop_back();
 }
 
-void CGDebugInfo::EmitFunctionEnd(CGBuilderTy ) {
+void CGDebugInfo::EmitFunctionEnd(CGBuilderTy , llvm::Function *Fn) {
   assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
   unsigned RCount = FnBeginRegionCount.back();
   assert(RCount <= LexicalBlockStack.size() && "Region stack mismatch");
@@ -3344,6 +3344,9 @@
 LexicalBlockStack.pop_back();
   }
   FnBeginRegionCount.pop_back();
+
+  if (Fn && Fn->getSubprogram())
+DBuilder.finalizeSubprogram(Fn->getSubprogram());
 }
 
 llvm::DIType *CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.h
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h
@@ -367,7 +367,7 @@
   void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc, QualType FnType);
 
   /// Constructs the debug code for exiting a function.
-  void EmitFunctionEnd(CGBuilderTy );
+  void EmitFunctionEnd(CGBuilderTy , llvm::Function *Fn);
 
   /// Emit metadata to indicate the beginning of a new lexical block
   /// and push the block onto the stack.
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -348,7 +348,7 @@
 
   // Emit debug descriptor for function end.
   if (CGDebugInfo *DI = getDebugInfo())
-DI->EmitFunctionEnd(Builder);
+DI->EmitFunctionEnd(Builder, CurFn);
 
   // Reset the debug location to that of the simple 'return' expression, if any
   // rather than that of the end of the function's scope '}'.


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -3263,7 +3263,7 @@
 
 void CGDebugInfo::EmitInlineFunctionEnd(CGBuilderTy ) {
   assert(CurInlinedAt && "unbalanced inline scope stack");
-  EmitFunctionEnd(Builder);
+  EmitFunctionEnd(Builder, nullptr);
   setInlinedAt(llvm::DebugLoc(CurInlinedAt).getInlinedAt());
 }
 
@@ -3332,7 +3332,7 @@
   LexicalBlockStack.pop_back();
 }
 
-void CGDebugInfo::EmitFunctionEnd(CGBuilderTy ) {
+void CGDebugInfo::EmitFunctionEnd(CGBuilderTy , llvm::Function *Fn) {
   assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
   unsigned RCount = FnBeginRegionCount.back();
   assert(RCount <= LexicalBlockStack.size() && "Region stack mismatch");
@@ -3344,6 +3344,9 @@
 LexicalBlockStack.pop_back();
   }
   FnBeginRegionCount.pop_back();
+
+  if (Fn && Fn->getSubprogram())
+DBuilder.finalizeSubprogram(Fn->getSubprogram());
 }
 
 llvm::DIType *CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.h
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h
@@ -367,7 +367,7 @@
   void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc, QualType FnType);
 
   /// Constructs the debug code for exiting a function.
-  void EmitFunctionEnd(CGBuilderTy );
+  void EmitFunctionEnd(CGBuilderTy , llvm::Function *Fn);
 
   /// Emit metadata to indicate the beginning of a new lexical block
   /// and push the block onto the stack.
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -348,7 +348,7 @@
 
   // Emit debug descriptor for function end.
   if (CGDebugInfo *DI = getDebugInfo())
-DI->EmitFunctionEnd(Builder);
+DI->EmitFunctionEnd(Builder, CurFn);
 
   // Reset the debug location to that of the simple 'return' expression, if any
   // rather than that of the end of the function's scope '}'.
___
cfe-commits mailing list

r304470 - [CGDebugInfo] Finalize SubPrograms when we're done with them

2017-06-01 Thread Keno Fischer via cfe-commits
Author: kfischer
Date: Thu Jun  1 16:14:03 2017
New Revision: 304470

URL: http://llvm.org/viewvc/llvm-project?rev=304470=rev
Log:
[CGDebugInfo] Finalize SubPrograms when we're done with them

`GenerateVarArgsThunk` in `CGVTables` clones a function before the frontend
is done emitting the compilation unit. Because of the way that DIBuilder
works, this means that the attached subprogram had incomplete (temporary)
metadata. Cloning such metadata is semantically disallowed, but happened
to work anyway due to bugs in the cloning logic. rL304226 attempted to fix
up that logic, but in the process exposed the incorrect API use here and
had to be reverted. To be able to fix this, I added a new method to
DIBuilder in rL304467, to allow finalizing a subprogram independently
of the entire compilation unit. Use that here, in preparation of re-applying
rL304226.

Reviewers: aprantl, dblaikie
Differential Revision: https://reviews.llvm.org/D33705

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=304470=304469=304470=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jun  1 16:14:03 2017
@@ -3263,7 +3263,7 @@ void CGDebugInfo::EmitInlineFunctionStar
 
 void CGDebugInfo::EmitInlineFunctionEnd(CGBuilderTy ) {
   assert(CurInlinedAt && "unbalanced inline scope stack");
-  EmitFunctionEnd(Builder);
+  EmitFunctionEnd(Builder, nullptr);
   setInlinedAt(llvm::DebugLoc(CurInlinedAt).getInlinedAt());
 }
 
@@ -3332,7 +3332,7 @@ void CGDebugInfo::EmitLexicalBlockEnd(CG
   LexicalBlockStack.pop_back();
 }
 
-void CGDebugInfo::EmitFunctionEnd(CGBuilderTy ) {
+void CGDebugInfo::EmitFunctionEnd(CGBuilderTy , llvm::Function *Fn) {
   assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
   unsigned RCount = FnBeginRegionCount.back();
   assert(RCount <= LexicalBlockStack.size() && "Region stack mismatch");
@@ -3344,6 +3344,9 @@ void CGDebugInfo::EmitFunctionEnd(CGBuil
 LexicalBlockStack.pop_back();
   }
   FnBeginRegionCount.pop_back();
+
+  if (Fn && Fn->getSubprogram())
+DBuilder.finalizeSubprogram(Fn->getSubprogram());
 }
 
 llvm::DIType *CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=304470=304469=304470=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Jun  1 16:14:03 2017
@@ -367,7 +367,7 @@ public:
   void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc, QualType FnType);
 
   /// Constructs the debug code for exiting a function.
-  void EmitFunctionEnd(CGBuilderTy );
+  void EmitFunctionEnd(CGBuilderTy , llvm::Function *Fn);
 
   /// Emit metadata to indicate the beginning of a new lexical block
   /// and push the block onto the stack.

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=304470=304469=304470=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Jun  1 16:14:03 2017
@@ -348,7 +348,7 @@ void CodeGenFunction::FinishFunction(Sou
 
   // Emit debug descriptor for function end.
   if (CGDebugInfo *DI = getDebugInfo())
-DI->EmitFunctionEnd(Builder);
+DI->EmitFunctionEnd(Builder, CurFn);
 
   // Reset the debug location to that of the simple 'return' expression, if any
   // rather than that of the end of the function's scope '}'.


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


[PATCH] D33692: [ThinLTO] Migrate ThinLTOBitcodeWriter to the new PM.

2017-06-01 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 101106.
timshen added a comment.

Rebase the patch onto https://reviews.llvm.org/D33799.


https://reviews.llvm.org/D33692

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/thin_link_bitcode.c


Index: clang/test/CodeGen/thin_link_bitcode.c
===
--- clang/test/CodeGen/thin_link_bitcode.c
+++ clang/test/CodeGen/thin_link_bitcode.c
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -triple 
x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
 // RUN: llvm-bcanalyzer -dump %t | FileCheck %s
 // RUN: llvm-bcanalyzer -dump %t.nodebug | FileCheck %s --check-prefix=NO_DEBUG
+// RUN: %clang_cc1 -o %t.newpm -flto=thin -fexperimental-new-pass-manager 
-fthin-link-bitcode=%t.newpm.nodebug -triple x86_64-unknown-linux-gnu 
-emit-llvm-bc -debug-info-kind=limited  %s
+// RUN: llvm-bcanalyzer -dump %t.newpm | FileCheck %s
+// RUN: llvm-bcanalyzer -dump %t.newpm.nodebug | FileCheck %s 
--check-prefix=NO_DEBUG
 int main (void) {
   return 0;
 }
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -49,6 +49,7 @@
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
+#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
@@ -897,16 +898,32 @@
   // create that pass manager here and use it as needed below.
   legacy::PassManager CodeGenPasses;
   bool NeedCodeGen = false;
+  Optional ThinLinkOS;
 
   // Append any output we need to the pass manager.
   switch (Action) {
   case Backend_EmitNothing:
 break;
 
   case Backend_EmitBC:
-MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
-  CodeGenOpts.EmitSummaryIndex,
-  CodeGenOpts.EmitSummaryIndex));
+if (CodeGenOpts.EmitSummaryIndex) {
+  if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
+std::error_code EC;
+ThinLinkOS.emplace(CodeGenOpts.ThinLinkBitcodeFile, EC,
+   llvm::sys::fs::F_None);
+if (EC) {
+  Diags.Report(diag::err_fe_unable_to_open_output)
+  << CodeGenOpts.ThinLinkBitcodeFile << EC.message();
+  return;
+}
+  }
+  MPM.addPass(
+  ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &*ThinLinkOS : nullptr));
+} else {
+  MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
+CodeGenOpts.EmitSummaryIndex,
+CodeGenOpts.EmitSummaryIndex));
+}
 break;
 
   case Backend_EmitLL:
@@ -1029,6 +1046,7 @@
   Conf.CGOptLevel = getCGOptLevel(CGOpts);
   initTargetOptions(Conf.Options, CGOpts, TOpts, LOpts, HeaderOpts);
   Conf.SampleProfile = std::move(SampleProfile);
+  Conf.UseNewPM = CGOpts.ExperimentalNewPassManager;
   switch (Action) {
   case Backend_EmitNothing:
 Conf.PreCodeGenModuleHook = [](size_t Task, const Module ) {


Index: clang/test/CodeGen/thin_link_bitcode.c
===
--- clang/test/CodeGen/thin_link_bitcode.c
+++ clang/test/CodeGen/thin_link_bitcode.c
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -triple x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
 // RUN: llvm-bcanalyzer -dump %t | FileCheck %s
 // RUN: llvm-bcanalyzer -dump %t.nodebug | FileCheck %s --check-prefix=NO_DEBUG
+// RUN: %clang_cc1 -o %t.newpm -flto=thin -fexperimental-new-pass-manager -fthin-link-bitcode=%t.newpm.nodebug -triple x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited  %s
+// RUN: llvm-bcanalyzer -dump %t.newpm | FileCheck %s
+// RUN: llvm-bcanalyzer -dump %t.newpm.nodebug | FileCheck %s --check-prefix=NO_DEBUG
 int main (void) {
   return 0;
 }
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -49,6 +49,7 @@
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
+#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
@@ -897,16 +898,32 @@
   // create that pass manager here and use it as needed below.
   legacy::PassManager CodeGenPasses;
   bool NeedCodeGen = false;
+  Optional ThinLinkOS;
 
   // Append any output we need to the pass manager.
   switch (Action) {
   case Backend_EmitNothing:
 break;
 
   case Backend_EmitBC:
-

[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it

2017-06-01 Thread Keno Fischer via Phabricator via cfe-commits
loladiro added a comment.

I don't think that change is entirely necessary. I don't have any strong 
objections to it, but I also don't see a good reason to require it. In any 
case, let me get this in to be able to re-land https://reviews.llvm.org/D33655 
and we can revisit the more disruptive change later.


https://reviews.llvm.org/D33705



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


[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it

2017-06-01 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Looks good.. Are you also planning to change DIBuilder to not finalize 
subprograms automatically any more (and not insert them into AllSubprograms)? 
(That will be the more impactful change as it will force all non-clang 
frontends to make a similar change).


https://reviews.llvm.org/D33705



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


[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it

2017-06-01 Thread Keno Fischer via Phabricator via cfe-commits
loladiro added a comment.

There's already such a test case, but the cloning currently doesn't assert 
properly (but it can generate incorrect code). https://reviews.llvm.org/D33655 
fixes that up, so I think the testing is covered once that LLVM commit goes in. 
I'll hold off a little while to give @aprantl a chance to look at this as well, 
but I do want to get this in in short order, so I can recommit 
https://reviews.llvm.org/D33655.


https://reviews.llvm.org/D33705



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


r304465 - Don't assume that a store source is a vector type just because the destination is (PR26099)

2017-06-01 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Jun  1 15:13:34 2017
New Revision: 304465

URL: http://llvm.org/viewvc/llvm-project?rev=304465=rev
Log:
Don't assume that a store source is a vector type just because the destination 
is (PR26099)

Added:
cfe/trunk/test/CodeGen/pr26099.c
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=304465=304464=304465=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Jun  1 15:13:34 2017
@@ -1487,9 +1487,9 @@ void CodeGenFunction::EmitStoreOfScalar(
 // Handle vectors differently to get better performance.
 if (Ty->isVectorType()) {
   llvm::Type *SrcTy = Value->getType();
-  auto *VecTy = cast(SrcTy);
+  auto *VecTy = dyn_cast(SrcTy);
   // Handle vec3 special.
-  if (VecTy->getNumElements() == 3) {
+  if (VecTy && VecTy->getNumElements() == 3) {
 // Our source is a vec3, do a shuffle vector to make it a vec4.
 llvm::Constant *Mask[] = {Builder.getInt32(0), Builder.getInt32(1),
   Builder.getInt32(2),

Added: cfe/trunk/test/CodeGen/pr26099.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pr26099.c?rev=304465=auto
==
--- cfe/trunk/test/CodeGen/pr26099.c (added)
+++ cfe/trunk/test/CodeGen/pr26099.c Thu Jun  1 15:13:34 2017
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -ffreestanding %s -triple=i686-apple-darwin -target-feature 
+mmx -emit-llvm -o - -Wall -Werror
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +mmx -emit-llvm -o - -Wall -Werror
+// REQUIRES: asserts
+
+#include 
+
+int __attribute__ ((__vector_size__ (8))) b;
+
+void bar(int a)
+{
+  b = __builtin_ia32_vec_init_v2si (0, a);
+}
\ No newline at end of file


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


[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it

2017-06-01 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

I guess this would need a cross-project test case (ie: it'd have to run LLVM 
optimizations to fail/pass/demonstrate the fix). I think it'd be OK to add one 
if there's a neat/clean/obvious optimization that can be reliably triggered to 
do the cloning that would assert/crash - please add one if you think that's 
practical/reasonable.


https://reviews.llvm.org/D33705



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


Re: r304346 - [modules] When compiling a preprocessed module map, look for headers relative

2017-06-01 Thread Richard Smith via cfe-commits
On 1 June 2017 at 12:53, Richard Smith  wrote:

> On 1 June 2017 at 11:10, Galina Kistanova  wrote:
>
>> Hello Richard,
>>
>> This commit broke tests on few of our builders:
>>
>> Failing Tests (2):
>> Clang :: Modules/preprocess-module.cpp
>> Clang :: Modules/preprocess-nested.cpp
>>
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei
>> -ps4-windows10pro-fast/builds/10199
>> and
>> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensiv
>> e-checks-win/builds/2819
>>
>> Please have a look at this?
>>
>
> Sure, looking.
>

Should be fixed in r304464.


> Also I see that email notifications on these failures were sent.
>>
>
> They certainly did not arrive here. As I've mentioned before, I have not
> received any mail from any lab.llvm.org bots since early March.
>
>
>> Thanks
>>
>> Galina
>>
>>
>> On Wed, May 31, 2017 at 1:56 PM, Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: rsmith
>>> Date: Wed May 31 15:56:55 2017
>>> New Revision: 304346
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=304346=rev
>>> Log:
>>> [modules] When compiling a preprocessed module map, look for headers
>>> relative
>>> to the original module map.
>>>
>>> Also use the path and name of the original module map when emitting that
>>> information into the .pcm file. The upshot of this is that the produced
>>> .pcm
>>> file will track information for headers in their original locations
>>> (where the
>>> module was preprocessed), not relative to whatever directory the
>>> preprocessed
>>> module map was in when it was built.
>>>
>>> Modified:
>>> cfe/trunk/include/clang/Basic/Module.h
>>> cfe/trunk/include/clang/Lex/HeaderSearch.h
>>> cfe/trunk/lib/Frontend/FrontendAction.cpp
>>> cfe/trunk/lib/Lex/HeaderSearch.cpp
>>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>>> cfe/trunk/test/Modules/preprocess-module.cpp
>>> cfe/trunk/test/Modules/preprocess-nested.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Basic/Module.h
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>>> Basic/Module.h?rev=304346=304345=304346=diff
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/Basic/Module.h (original)
>>> +++ cfe/trunk/include/clang/Basic/Module.h Wed May 31 15:56:55 2017
>>> @@ -83,6 +83,10 @@ public:
>>>/// are found.
>>>const DirectoryEntry *Directory;
>>>
>>> +  /// \brief The presumed file name for the module map defining this
>>> module.
>>> +  /// Only non-empty when building from preprocessed source.
>>> +  std::string PresumedModuleMapFile;
>>> +
>>>/// \brief The umbrella header or directory.
>>>llvm::PointerUnion
>>> Umbrella;
>>>
>>>
>>> Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>>> Lex/HeaderSearch.h?rev=304346=304345=304346=diff
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
>>> +++ cfe/trunk/include/clang/Lex/HeaderSearch.h Wed May 31 15:56:55 2017
>>> @@ -543,10 +543,13 @@ public:
>>>/// \param Offset [inout] An offset within ID to start parsing. On
>>> exit,
>>>///filled by the end of the parsed contents (either EOF or the
>>>///location of an end-of-module-map pragma).
>>> -  ///
>>> +  /// \param OriginalModuleMapFile The original path to the module map
>>> file,
>>> +  ///used to resolve paths within the module (this is required
>>> when
>>> +  ///building the module from preprocessed source).
>>>/// \returns true if an error occurred, false otherwise.
>>>bool loadModuleMapFile(const FileEntry *File, bool IsSystem,
>>> - FileID ID = FileID(), unsigned *Offset =
>>> nullptr);
>>> + FileID ID = FileID(), unsigned *Offset =
>>> nullptr,
>>> + StringRef OriginalModuleMapFile = StringRef());
>>>
>>>/// \brief Collect the set of all known, top-level modules.
>>>///
>>>
>>> Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/F
>>> rontendAction.cpp?rev=304346=304345=304346=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
>>> +++ cfe/trunk/lib/Frontend/FrontendAction.cpp Wed May 31 15:56:55 2017
>>> @@ -373,10 +373,11 @@ collectModuleHeaderIncludes(const LangOp
>>>return std::error_code();
>>>  }
>>>
>>> -static bool
>>> -loadModuleMapForModuleBuild(CompilerInstance , StringRef Filename,
>>> -bool IsSystem, bool IsPreprocessed,
>>> -unsigned ) {
>>> +static bool loadModuleMapForModuleBuild(CompilerInstance ,
>>> +

r304464 - Escape filenames in module map line marker directives, to unbreak Windows build bots.

2017-06-01 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jun  1 15:10:35 2017
New Revision: 304464

URL: http://llvm.org/viewvc/llvm-project?rev=304464=rev
Log:
Escape filenames in module map line marker directives, to unbreak Windows build 
bots.

Modified:
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp

Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=304464=304463=304464=diff
==
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Thu Jun  1 15:10:35 2017
@@ -546,8 +546,11 @@ void PrintPreprocessedAction::ExecuteAct
   // module itself before switching to the input buffer.
   auto  = getCurrentInput();
   if (Input.getKind().getFormat() == InputKind::ModuleMap) {
-if (Input.isFile())
-  (*OS) << "# 1 \"" << Input.getFile() << "\"\n";
+if (Input.isFile()) {
+  (*OS) << "# 1 \"";
+  OS->write_escaped(Input.getFile());
+  (*OS) << "\"\n";
+}
 // FIXME: Include additional information here so that we don't need the
 // original source files to exist on disk.
 getCurrentModule()->print(*OS);

Modified: cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp?rev=304464=304463=304464=diff
==
--- cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp Thu Jun  1 15:10:35 2017
@@ -200,8 +200,11 @@ void RewriteIncludesAction::ExecuteActio
   // module itself before switching to the input buffer.
   auto  = getCurrentInput();
   if (Input.getKind().getFormat() == InputKind::ModuleMap) {
-if (Input.isFile())
-  (*OS) << "# 1 \"" << Input.getFile() << "\"\n";
+if (Input.isFile()) {
+  (*OS) << "# 1 \"";
+  OS->write_escaped(Input.getFile());
+  (*OS) << "\"\n";
+}
 // FIXME: Include additional information here so that we don't need the
 // original source files to exist on disk.
 getCurrentModule()->print(*OS);


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


[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it

2017-06-01 Thread Keno Fischer via Phabricator via cfe-commits
loladiro added a comment.

@aprantl @dblaikie See if you like this better.


https://reviews.llvm.org/D33705



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


[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it

2017-06-01 Thread Keno Fischer via Phabricator via cfe-commits
loladiro updated this revision to Diff 101092.
loladiro added a comment.

Finalize all subprograms when we're done emitting them.
The one we're interested in is a side effect, but doing
this uniformly might be cleaner and help avoid similar errors in the future.


https://reviews.llvm.org/D33705

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CodeGenFunction.cpp


Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -348,7 +348,7 @@
 
   // Emit debug descriptor for function end.
   if (CGDebugInfo *DI = getDebugInfo())
-DI->EmitFunctionEnd(Builder);
+DI->EmitFunctionEnd(Builder, CurFn);
 
   // Reset the debug location to that of the simple 'return' expression, if any
   // rather than that of the end of the function's scope '}'.
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -367,7 +367,7 @@
   void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc, QualType FnType);
 
   /// Constructs the debug code for exiting a function.
-  void EmitFunctionEnd(CGBuilderTy );
+  void EmitFunctionEnd(CGBuilderTy , llvm::Function *Fn);
 
   /// Emit metadata to indicate the beginning of a new lexical block
   /// and push the block onto the stack.
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3263,7 +3263,7 @@
 
 void CGDebugInfo::EmitInlineFunctionEnd(CGBuilderTy ) {
   assert(CurInlinedAt && "unbalanced inline scope stack");
-  EmitFunctionEnd(Builder);
+  EmitFunctionEnd(Builder, nullptr);
   setInlinedAt(llvm::DebugLoc(CurInlinedAt).getInlinedAt());
 }
 
@@ -3332,7 +3332,7 @@
   LexicalBlockStack.pop_back();
 }
 
-void CGDebugInfo::EmitFunctionEnd(CGBuilderTy ) {
+void CGDebugInfo::EmitFunctionEnd(CGBuilderTy , llvm::Function *Fn) {
   assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
   unsigned RCount = FnBeginRegionCount.back();
   assert(RCount <= LexicalBlockStack.size() && "Region stack mismatch");
@@ -3344,6 +3344,9 @@
 LexicalBlockStack.pop_back();
   }
   FnBeginRegionCount.pop_back();
+
+  if (Fn && Fn->getSubprogram())
+DBuilder.finalizeSubprogram(Fn->getSubprogram());
 }
 
 llvm::DIType *CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,


Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -348,7 +348,7 @@
 
   // Emit debug descriptor for function end.
   if (CGDebugInfo *DI = getDebugInfo())
-DI->EmitFunctionEnd(Builder);
+DI->EmitFunctionEnd(Builder, CurFn);
 
   // Reset the debug location to that of the simple 'return' expression, if any
   // rather than that of the end of the function's scope '}'.
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -367,7 +367,7 @@
   void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc, QualType FnType);
 
   /// Constructs the debug code for exiting a function.
-  void EmitFunctionEnd(CGBuilderTy );
+  void EmitFunctionEnd(CGBuilderTy , llvm::Function *Fn);
 
   /// Emit metadata to indicate the beginning of a new lexical block
   /// and push the block onto the stack.
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3263,7 +3263,7 @@
 
 void CGDebugInfo::EmitInlineFunctionEnd(CGBuilderTy ) {
   assert(CurInlinedAt && "unbalanced inline scope stack");
-  EmitFunctionEnd(Builder);
+  EmitFunctionEnd(Builder, nullptr);
   setInlinedAt(llvm::DebugLoc(CurInlinedAt).getInlinedAt());
 }
 
@@ -3332,7 +3332,7 @@
   LexicalBlockStack.pop_back();
 }
 
-void CGDebugInfo::EmitFunctionEnd(CGBuilderTy ) {
+void CGDebugInfo::EmitFunctionEnd(CGBuilderTy , llvm::Function *Fn) {
   assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
   unsigned RCount = FnBeginRegionCount.back();
   assert(RCount <= LexicalBlockStack.size() && "Region stack mismatch");
@@ -3344,6 +3344,9 @@
 LexicalBlockStack.pop_back();
   }
   FnBeginRegionCount.pop_back();
+
+  if (Fn && Fn->getSubprogram())
+DBuilder.finalizeSubprogram(Fn->getSubprogram());
 }
 
 llvm::DIType *CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33398: Mangle __unaligned in Itanium ABI

2017-06-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

Looks great, thanks!




Comment at: lib/AST/ItaniumMangle.cpp:2210
+  if (Quals.hasUnaligned())
+  mangleVendorQualifier("__unaligned");
+

rogfer01 wrote:
> rsmith wrote:
> > Too much indentation here. Also, the ABI requires the "unordered" vendor 
> > qualifiers to be emitted in reverse alphabetical order, so this should be 
> > emitted after `__weak` and `__strong` but before `__autoreleasing`.
> I think you meant after `__weak` but before `__strong` and `__autoreleasing`? 
> Maybe I'm misinterpreting something here.
> 
> The current patch emits `__weak`, then `__unaligned` and then the remaining 
> ARC ones.
The alphabet is hard, apparently :) Yes, thanks!



Comment at: lib/AST/ItaniumMangle.cpp:2184
+  //
+  // Note: we emit first __weak to preserve the order as
+  // required by the Itanium ABI.

first `__weak` -> `__weak` first


https://reviews.llvm.org/D33398



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


[PATCH] D33797: [coroutines] Fix rebuilding of dependent coroutine parameters

2017-06-01 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov created this revision.

We were not handling correctly rebuilding of parameter and were not creating 
copies for them.
With this checking, we will be always rebuilding parameter moves in 
TreeTransform's TransformCoroutineBodyStmt.


https://reviews.llvm.org/D33797

Files:
  lib/Sema/CoroutineStmtBuilder.h
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/TreeTransform.h
  test/CodeGenCoroutines/coro-params.cpp


Index: test/CodeGenCoroutines/coro-params.cpp
===
--- test/CodeGenCoroutines/coro-params.cpp
+++ test/CodeGenCoroutines/coro-params.cpp
@@ -93,3 +93,26 @@
   // CHECK-NEXT: call void @_ZN8MoveOnlyD1Ev(%struct.MoveOnly* %[[MoCopy]]
   // CHECK-NEXT: call i8* @llvm.coro.free(
 }
+
+// CHECK-LABEL: void @_Z16dependent_paramsI1AEvT_(%struct.A* %x
+template 
+void dependent_params(T x) {
+  // CHECK: %[[x_copy:.+]] = alloca %struct.A
+
+  // CHECK: call i8* @llvm.coro.begin
+  // CHECK-NEXT: call void @_ZN1AC1EOS_(%struct.A* %x1, %struct.A* 
dereferenceable(512) %x)
+  // CHECK-NEXT: call void 
@_ZNSt12experimental16coroutine_traitsIJv1AEE12promise_typeC1Ev
+
+  co_return;
+}
+
+struct A {
+  int WontFitIntoRegisterForSure[128];
+  A();
+  A(A&&);
+  ~A();
+};
+
+void call_dependent_params() {
+  dependent_params(A{});
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -6959,6 +6959,7 @@
   Builder.ReturnStmt = Res.get();
 }
   }
+  Builder.buildParameterMoves();
 
   return getDerived().RebuildCoroutineBodyStmt(Builder);
 }
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -822,6 +822,12 @@
   return this->IsValid;
 }
 
+bool CoroutineStmtBuilder::buildParameterMoves() {
+  assert(this->IsValid && "coroutine already invalid");
+  assert(this->ParamMoves.empty() && "param moves already built");
+  return this->IsValid = makeParamMoves();
+}
+
 bool CoroutineStmtBuilder::buildDependentStatements() {
   assert(this->IsValid && "coroutine already invalid");
   assert(!this->IsPromiseDependentType &&
Index: lib/Sema/CoroutineStmtBuilder.h
===
--- lib/Sema/CoroutineStmtBuilder.h
+++ lib/Sema/CoroutineStmtBuilder.h
@@ -51,6 +51,9 @@
   /// name lookup.
   bool buildDependentStatements();
 
+  /// \brief Build just parameter moves. To use for rebuilding in 
TreeTransform.
+  bool buildParameterMoves();
+
   bool isInvalid() const { return !this->IsValid; }
 
 private:


Index: test/CodeGenCoroutines/coro-params.cpp
===
--- test/CodeGenCoroutines/coro-params.cpp
+++ test/CodeGenCoroutines/coro-params.cpp
@@ -93,3 +93,26 @@
   // CHECK-NEXT: call void @_ZN8MoveOnlyD1Ev(%struct.MoveOnly* %[[MoCopy]]
   // CHECK-NEXT: call i8* @llvm.coro.free(
 }
+
+// CHECK-LABEL: void @_Z16dependent_paramsI1AEvT_(%struct.A* %x
+template 
+void dependent_params(T x) {
+  // CHECK: %[[x_copy:.+]] = alloca %struct.A
+
+  // CHECK: call i8* @llvm.coro.begin
+  // CHECK-NEXT: call void @_ZN1AC1EOS_(%struct.A* %x1, %struct.A* dereferenceable(512) %x)
+  // CHECK-NEXT: call void @_ZNSt12experimental16coroutine_traitsIJv1AEE12promise_typeC1Ev
+
+  co_return;
+}
+
+struct A {
+  int WontFitIntoRegisterForSure[128];
+  A();
+  A(A&&);
+  ~A();
+};
+
+void call_dependent_params() {
+  dependent_params(A{});
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -6959,6 +6959,7 @@
   Builder.ReturnStmt = Res.get();
 }
   }
+  Builder.buildParameterMoves();
 
   return getDerived().RebuildCoroutineBodyStmt(Builder);
 }
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -822,6 +822,12 @@
   return this->IsValid;
 }
 
+bool CoroutineStmtBuilder::buildParameterMoves() {
+  assert(this->IsValid && "coroutine already invalid");
+  assert(this->ParamMoves.empty() && "param moves already built");
+  return this->IsValid = makeParamMoves();
+}
+
 bool CoroutineStmtBuilder::buildDependentStatements() {
   assert(this->IsValid && "coroutine already invalid");
   assert(!this->IsPromiseDependentType &&
Index: lib/Sema/CoroutineStmtBuilder.h
===
--- lib/Sema/CoroutineStmtBuilder.h
+++ lib/Sema/CoroutineStmtBuilder.h
@@ -51,6 +51,9 @@
   /// name lookup.
   bool buildDependentStatements();
 
+  /// \brief Build just parameter moves. To use for rebuilding in TreeTransform.
+  bool buildParameterMoves();
+
   bool isInvalid() const { return !this->IsValid; }
 
 private:
___
cfe-commits mailing 

[PATCH] D32724: [Modules] Handle sanitizer feature mismatches when importing modules

2017-06-01 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304463: [Modules] Handle sanitizer feature mismatches when 
importing modules (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D32724?vs=98371=101088#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32724

Files:
  cfe/trunk/include/clang/Basic/Sanitizers.h
  cfe/trunk/lib/Basic/LangOptions.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Serialization/ASTReader.cpp
  cfe/trunk/test/Modules/Inputs/check-for-sanitizer-feature/check.h
  cfe/trunk/test/Modules/Inputs/check-for-sanitizer-feature/map
  cfe/trunk/test/Modules/check-for-sanitizer-feature.cpp

Index: cfe/trunk/include/clang/Basic/Sanitizers.h
===
--- cfe/trunk/include/clang/Basic/Sanitizers.h
+++ cfe/trunk/include/clang/Basic/Sanitizers.h
@@ -61,8 +61,8 @@
 Mask = Value ? (Mask | K) : (Mask & ~K);
   }
 
-  /// \brief Disable all sanitizers.
-  void clear() { Mask = 0; }
+  /// Disable the sanitizers specified in \p K.
+  void clear(SanitizerMask K = SanitizerKind::All) { Mask &= ~K; }
 
   /// \brief Returns true if at least one sanitizer is enabled.
   bool empty() const { return Mask == 0; }
@@ -79,6 +79,12 @@
 /// this group enables.
 SanitizerMask expandSanitizerGroups(SanitizerMask Kinds);
 
+/// Return the sanitizers which do not affect preprocessing.
+static inline SanitizerMask getPPTransparentSanitizers() {
+  return SanitizerKind::CFI | SanitizerKind::Integer |
+ SanitizerKind::Nullability | SanitizerKind::Undefined;
+}
+
 }  // end namespace clang
 
 #endif
Index: cfe/trunk/test/Modules/check-for-sanitizer-feature.cpp
===
--- cfe/trunk/test/Modules/check-for-sanitizer-feature.cpp
+++ cfe/trunk/test/Modules/check-for-sanitizer-feature.cpp
@@ -0,0 +1,66 @@
+// RUN: rm -rf %t.1 %t.2
+// RUN: mkdir %t.1 %t.2
+
+// Build and use an ASan-enabled module.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 2
+
+// Force a module rebuild by disabling ASan.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Enable ASan again: check that there is no import failure, and no rebuild.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Some sanitizers can not affect AST generation when enabled. Check that
+// module rebuilds don't occur when these sanitizers are enabled.
+//
+// First, build without any sanitization.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+//
+// Next, build with sanitization, and check that a new module isn't built.
+// RUN: %clang_cc1 -fsanitize=cfi-vcall,unsigned-integer-overflow,nullability-arg,null -fmodules \
+// RUN:   -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+
+// Finally, test that including enabled sanitizers in the module hash isn't
+// required to ensure correctness of module imports.
+//
+// Emit a PCH with ASan enabled.
+// RUN: %clang_cc1 -x c -fsanitize=address %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.asan_pch
+//
+// Import the PCH without ASan enabled (we expect an error).
+// RUN: not %clang_cc1 -x c -include-pch %t.asan_pch %s -verify 2>&1 | FileCheck %s --check-prefix=PCH_MISMATCH
+// PCH_MISMATCH: AST file was compiled with the target feature'-fsanitize=address' but the current translation unit is not
+//
+// Emit a PCH with UBSan enabled.
+// RUN: %clang_cc1 -x c -fsanitize=null %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.ubsan_pch
+//
+// Import the PCH without UBSan enabled (should work just fine).
+// RUN: %clang_cc1 -x c -include-pch %t.ubsan_pch %s -I %S/Inputs/check-for-sanitizer-feature -verify
+
+#include "check.h"
+
+#if __has_feature(address_sanitizer)
+#if HAS_ASAN != 1
+#error Module doesn't have the address_sanitizer feature, but main program does.
+#endif
+#else
+#if HAS_ASAN != 0
+#error Module has the address_sanitizer feature, but main program doesn't.
+#endif
+#endif
+
+// expected-no-diagnostics
Index: cfe/trunk/test/Modules/Inputs/check-for-sanitizer-feature/map

r304463 - [Modules] Handle sanitizer feature mismatches when importing modules

2017-06-01 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Jun  1 15:01:01 2017
New Revision: 304463

URL: http://llvm.org/viewvc/llvm-project?rev=304463=rev
Log:
[Modules] Handle sanitizer feature mismatches when importing modules

This patch makes it an error to have a mismatch between the enabled
sanitizers in a CU, and in any module being imported into the CU. Only
mismatches between non-modular sanitizers are treated as errors.

This patch also includes non-modular sanitizers in module hashes, in
order to ensure module rebuilds occur when -fsanitize=X is toggled on
and off for non-modular sanitizers, and to cut down on module rebuilds
when the option is toggled for modular sanitizers.

This fixes a longstanding issue with implicit modules and sanitizers,
which Duncan originally diagnosed.

When building with implicit modules it's possible to hit a scenario
where modules are built without -fsanitize=address, and are subsequently
imported into CUs with -fsanitize=address enabled. This causes strange
failures at runtime. The case Duncan found affects libcxx, since its
vector implementation behaves differently when ASan is enabled.

Implicit module builds should "just work" when -fsanitize=X is toggled
on and off across multiple compiler invocations, which is what this
patch does.

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

Added:
cfe/trunk/test/Modules/Inputs/check-for-sanitizer-feature/
cfe/trunk/test/Modules/Inputs/check-for-sanitizer-feature/check.h
cfe/trunk/test/Modules/Inputs/check-for-sanitizer-feature/map
cfe/trunk/test/Modules/check-for-sanitizer-feature.cpp
Modified:
cfe/trunk/include/clang/Basic/Sanitizers.h
cfe/trunk/lib/Basic/LangOptions.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Basic/Sanitizers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.h?rev=304463=304462=304463=diff
==
--- cfe/trunk/include/clang/Basic/Sanitizers.h (original)
+++ cfe/trunk/include/clang/Basic/Sanitizers.h Thu Jun  1 15:01:01 2017
@@ -61,8 +61,8 @@ struct SanitizerSet {
 Mask = Value ? (Mask | K) : (Mask & ~K);
   }
 
-  /// \brief Disable all sanitizers.
-  void clear() { Mask = 0; }
+  /// Disable the sanitizers specified in \p K.
+  void clear(SanitizerMask K = SanitizerKind::All) { Mask &= ~K; }
 
   /// \brief Returns true if at least one sanitizer is enabled.
   bool empty() const { return Mask == 0; }
@@ -79,6 +79,12 @@ SanitizerMask parseSanitizerValue(String
 /// this group enables.
 SanitizerMask expandSanitizerGroups(SanitizerMask Kinds);
 
+/// Return the sanitizers which do not affect preprocessing.
+static inline SanitizerMask getPPTransparentSanitizers() {
+  return SanitizerKind::CFI | SanitizerKind::Integer |
+ SanitizerKind::Nullability | SanitizerKind::Undefined;
+}
+
 }  // end namespace clang
 
 #endif

Modified: cfe/trunk/lib/Basic/LangOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/LangOptions.cpp?rev=304463=304462=304463=diff
==
--- cfe/trunk/lib/Basic/LangOptions.cpp (original)
+++ cfe/trunk/lib/Basic/LangOptions.cpp Thu Jun  1 15:01:01 2017
@@ -29,9 +29,7 @@ void LangOptions::resetNonModularOptions
   Name = Default;
 #include "clang/Basic/LangOptions.def"
 
-  // FIXME: This should not be reset; modules can be different with different
-  // sanitizer options (this affects __has_feature(address_sanitizer) etc).
-  Sanitize.clear();
+  // These options do not affect AST generation.
   SanitizerBlacklistFiles.clear();
   XRayAlwaysInstrumentFiles.clear();
   XRayNeverInstrumentFiles.clear();

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=304463=304462=304463=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Jun  1 15:01:01 2017
@@ -2700,6 +2700,13 @@ std::string CompilerInvocation::getModul
 code = ext->hashExtension(code);
   }
 
+  // Extend the signature with the enabled sanitizers, if at least one is
+  // enabled. Sanitizers which cannot affect AST generation aren't hashed.
+  SanitizerSet SanHash = LangOpts->Sanitize;
+  SanHash.clear(getPPTransparentSanitizers());
+  if (!SanHash.empty())
+code = hash_combine(code, SanHash.Mask);
+
   return llvm::APInt(64, code).toString(36, /*Signed=*/false);
 }
 

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=304463=304462=304463=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ 

[libcxx] r304462 - Mark two coroutine tests as unsupported under ubsan

2017-06-01 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Jun  1 15:00:40 2017
New Revision: 304462

URL: http://llvm.org/viewvc/llvm-project?rev=304462=rev
Log:
Mark two coroutine tests as unsupported under ubsan

They appear to crash inside of SelectionDAG on some Linux bots, when
ubsan is enabled.

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

Modified:

libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp

libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp?rev=304462=304461=304462=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
 Thu Jun  1 15:00:40 2017
@@ -10,6 +10,9 @@
 
 // UNSUPPORTED: c++98, c++03, c++11
 
+// See https://bugs.llvm.org/show_bug.cgi?id=33271
+// UNSUPPORTED: ubsan
+
 #include 
 #include 
 

Modified: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp?rev=304462=304461=304462=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
 Thu Jun  1 15:00:40 2017
@@ -10,6 +10,9 @@
 
 // UNSUPPORTED: c++98, c++03, c++11
 
+// See https://bugs.llvm.org/show_bug.cgi?id=33271
+// UNSUPPORTED: ubsan
+
 #include 
 #include 
 #include 


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


Re: r304346 - [modules] When compiling a preprocessed module map, look for headers relative

2017-06-01 Thread Richard Smith via cfe-commits
On 1 June 2017 at 11:10, Galina Kistanova  wrote:

> Hello Richard,
>
> This commit broke tests on few of our builders:
>
> Failing Tests (2):
> Clang :: Modules/preprocess-module.cpp
> Clang :: Modules/preprocess-nested.cpp
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-
> scei-ps4-windows10pro-fast/builds/10199
> and
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensiv
> e-checks-win/builds/2819
>
> Please have a look at this?
>

Sure, looking.


> Also I see that email notifications on these failures were sent.
>

They certainly did not arrive here. As I've mentioned before, I have not
received any mail from any lab.llvm.org bots since early March.


> Thanks
>
> Galina
>
>
> On Wed, May 31, 2017 at 1:56 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Wed May 31 15:56:55 2017
>> New Revision: 304346
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=304346=rev
>> Log:
>> [modules] When compiling a preprocessed module map, look for headers
>> relative
>> to the original module map.
>>
>> Also use the path and name of the original module map when emitting that
>> information into the .pcm file. The upshot of this is that the produced
>> .pcm
>> file will track information for headers in their original locations
>> (where the
>> module was preprocessed), not relative to whatever directory the
>> preprocessed
>> module map was in when it was built.
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/Module.h
>> cfe/trunk/include/clang/Lex/HeaderSearch.h
>> cfe/trunk/lib/Frontend/FrontendAction.cpp
>> cfe/trunk/lib/Lex/HeaderSearch.cpp
>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>> cfe/trunk/test/Modules/preprocess-module.cpp
>> cfe/trunk/test/Modules/preprocess-nested.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/Module.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/Module.h?rev=304346=304345=304346=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/Module.h (original)
>> +++ cfe/trunk/include/clang/Basic/Module.h Wed May 31 15:56:55 2017
>> @@ -83,6 +83,10 @@ public:
>>/// are found.
>>const DirectoryEntry *Directory;
>>
>> +  /// \brief The presumed file name for the module map defining this
>> module.
>> +  /// Only non-empty when building from preprocessed source.
>> +  std::string PresumedModuleMapFile;
>> +
>>/// \brief The umbrella header or directory.
>>llvm::PointerUnion Umbrella;
>>
>>
>> Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Lex/HeaderSearch.h?rev=304346=304345=304346=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
>> +++ cfe/trunk/include/clang/Lex/HeaderSearch.h Wed May 31 15:56:55 2017
>> @@ -543,10 +543,13 @@ public:
>>/// \param Offset [inout] An offset within ID to start parsing. On
>> exit,
>>///filled by the end of the parsed contents (either EOF or the
>>///location of an end-of-module-map pragma).
>> -  ///
>> +  /// \param OriginalModuleMapFile The original path to the module map
>> file,
>> +  ///used to resolve paths within the module (this is required
>> when
>> +  ///building the module from preprocessed source).
>>/// \returns true if an error occurred, false otherwise.
>>bool loadModuleMapFile(const FileEntry *File, bool IsSystem,
>> - FileID ID = FileID(), unsigned *Offset =
>> nullptr);
>> + FileID ID = FileID(), unsigned *Offset =
>> nullptr,
>> + StringRef OriginalModuleMapFile = StringRef());
>>
>>/// \brief Collect the set of all known, top-level modules.
>>///
>>
>> Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/F
>> rontendAction.cpp?rev=304346=304345=304346=diff
>> 
>> ==
>> --- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
>> +++ cfe/trunk/lib/Frontend/FrontendAction.cpp Wed May 31 15:56:55 2017
>> @@ -373,10 +373,11 @@ collectModuleHeaderIncludes(const LangOp
>>return std::error_code();
>>  }
>>
>> -static bool
>> -loadModuleMapForModuleBuild(CompilerInstance , StringRef Filename,
>> -bool IsSystem, bool IsPreprocessed,
>> -unsigned ) {
>> +static bool loadModuleMapForModuleBuild(CompilerInstance ,
>> +StringRef Filename, bool
>> IsSystem,
>> +bool IsPreprocessed,
>> +std::string
>> ,
>> +unsigned ) {
>>auto  = 

[PATCH] D33305: [ubsan] Add a check for pointer overflow UB

2017-06-01 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304459: [ubsan] Add a check for pointer overflow UB 
(authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D33305?vs=100475=101078#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33305

Files:
  cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
  cfe/trunk/include/clang/Basic/Sanitizers.def
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
  cfe/trunk/test/Driver/fsanitize.c

Index: cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
===
--- cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
+++ cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
@@ -0,0 +1,171 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -w -emit-llvm -o - %s -fsanitize=pointer-overflow | FileCheck %s
+
+// CHECK-LABEL: define void @unary_arith
+void unary_arith(char *p) {
+  // CHECK:  [[BASE:%.*]] = ptrtoint i8* {{.*}} to i64, !nosanitize
+  // CHECK-NEXT: [[COMPGEP:%.*]] = add i64 [[BASE]], 1, !nosanitize
+  // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], !nosanitize
+  // CHECK-NEXT: [[NEGVALID:%.*]] = icmp ult i64 [[COMPGEP]], [[BASE]], !nosanitize
+  // CHECK-NEXT: [[DIFFVALID:%.*]] = select i1 true, i1 [[POSVALID]], i1 [[NEGVALID]], !nosanitize
+  // CHECK-NEXT: [[VALID:%.*]] = and i1 true, [[DIFFVALID]], !nosanitize
+  // CHECK-NEXT: br i1 [[VALID]]{{.*}}, !nosanitize
+  // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}, i64 [[BASE]], i64 [[COMPGEP]]){{.*}}, !nosanitize
+  ++p;
+
+  // CHECK: ptrtoint i8* {{.*}} to i64, !nosanitize
+  // CHECK-NEXT: add i64 {{.*}}, -1, !nosanitize
+  // CHECK: select i1 false{{.*}}, !nosanitize
+  // CHECK-NEXT: and i1 true{{.*}}, !nosanitize
+  // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
+  --p;
+
+  // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
+  p++;
+
+  // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
+  p--;
+}
+
+// CHECK-LABEL: define void @binary_arith
+void binary_arith(char *p, int i) {
+  // CHECK: [[SMUL:%.*]] = call { i64, i1 } @llvm.smul.with.overflow.i64(i64 1, i64 %{{.*}}), !nosanitize
+  // CHECK-NEXT: [[SMULOFLOW:%.*]] = extractvalue { i64, i1 } [[SMUL]], 1, !nosanitize
+  // CHECK-NEXT: [[OFFSETOFLOW:%.*]] = or i1 false, [[SMULOFLOW]], !nosanitize
+  // CHECK-NEXT: [[SMULVAL:%.*]] = extractvalue { i64, i1 } [[SMUL]], 0, !nosanitize
+  // CHECK-NEXT: [[BASE:%.*]] = ptrtoint i8* {{.*}} to i64, !nosanitize
+  // CHECK-NEXT: [[COMPGEP:%.*]] = add i64 [[BASE]], [[SMULVAL]], !nosanitize
+  // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], !nosanitize
+  // CHECK-NEXT: [[NEGVALID:%.*]] = icmp ult i64 [[COMPGEP]], [[BASE]], !nosanitize
+  // CHECK-NEXT: [[POSOFFSET:%.*]] = icmp sge i64 [[SMULVAL]], 0, !nosanitize
+  // CHECK-NEXT: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, !nosanitize
+  // CHECK-NEXT: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], i1 [[NEGVALID]], !nosanitize
+  // CHECK-NEXT: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[DIFFVALID]], !nosanitize
+  // CHECK-NEXT: br i1 [[VALID]]{{.*}}, !nosanitize
+  // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}, i64 [[BASE]], i64 [[COMPGEP]]){{.*}}, !nosanitize
+  p + i;
+
+  // CHECK: [[OFFSET:%.*]] = sub i64 0, {{.*}}
+  // CHECK-NEXT: getelementptr inbounds {{.*}} [[OFFSET]]
+  // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
+  p - i;
+}
+
+// CHECK-LABEL: define void @fixed_len_array
+void fixed_len_array(int k) {
+  // CHECK: getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* [[ARR:%.*]], i64 0, i64 [[IDXPROM:%.*]]
+  // CHECK-NEXT: [[SMUL:%.*]] = call { i64, i1 } @llvm.smul.with.overflow.i64(i64 40, i64 [[IDXPROM]]), !nosanitize
+  // CHECK-NEXT: [[SMULOFLOW:%.*]] = extractvalue { i64, i1 } [[SMUL]], 1, !nosanitize
+  // CHECK-NEXT: [[OFFSETOFLOW:%.*]] = or i1 false, [[SMULOFLOW]], !nosanitize
+  // CHECK-NEXT: [[SMULVAL:%.*]] = extractvalue { i64, i1 } [[SMUL]], 0, !nosanitize
+  // CHECK-NEXT: [[BASE:%.*]] = ptrtoint [10 x [10 x i32]]* [[ARR]] to i64, !nosanitize
+  // CHECK-NEXT: [[COMPGEP:%.*]] = add i64 [[BASE]], [[SMULVAL]], !nosanitize
+  // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], !nosanitize
+  // CHECK-NEXT: [[NEGVALID:%.*]] = icmp ult i64 [[COMPGEP]], [[BASE]], !nosanitize
+  // CHECK-NEXT: [[POSOFFSET:%.*]] = icmp sge i64 [[SMULVAL]], 0, !nosanitize
+  // CHECK-NEXT: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, !nosanitize
+  // CHECK-NEXT: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], i1 [[NEGVALID]], !nosanitize
+  // CHECK-NEXT: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[DIFFVALID]], !nosanitize
+  // CHECK-NEXT: br i1 [[VALID]]{{.*}}, !nosanitize
+  // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}, i64 [[BASE]], i64 

r304459 - [ubsan] Add a check for pointer overflow UB

2017-06-01 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Jun  1 14:22:18 2017
New Revision: 304459

URL: http://llvm.org/viewvc/llvm-project?rev=304459=rev
Log:
[ubsan] Add a check for pointer overflow UB

Check pointer arithmetic for overflow.

For some more background on this check, see:

  https://wdtz.org/catching-pointer-overflow-bugs.html
  https://reviews.llvm.org/D20322

Patch by Will Dietz and John Regehr!

This version of the patch is different from the original in a few ways:

  - It introduces the EmitCheckedInBoundsGEP utility which inserts
checks when the pointer overflow check is enabled.

  - It does some constant-folding to reduce instrumentation overhead.

  - It does not check some GEPs in CGExprCXX. I'm not sure that
inserting checks here, or in CGClass, would catch many bugs.

Possible future directions for this check:

  - Introduce CGF.EmitCheckedStructGEP, to detect overflows when
accessing structures.

Testing: Apart from the added lit test, I ran check-llvm and check-clang
with a stage2, ubsan-instrumented clang. Will and John have also done
extensive testing on numerous open source projects.

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

Added:
cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
Modified:
cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
cfe/trunk/include/clang/Basic/Sanitizers.def
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=304459=304458=304459=diff
==
--- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
+++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Thu Jun  1 14:22:18 2017
@@ -106,6 +106,8 @@ Available checks are:
  invalid pointers. These checks are made in terms of
  ``__builtin_object_size``, and consequently may be able to detect more
  problems at higher optimization levels.
+  -  ``-fsanitize=pointer-overflow``: Performing pointer arithmetic which
+ overflows.
   -  ``-fsanitize=return``: In C++, reaching the end of a
  value-returning function without returning a value.
   -  ``-fsanitize=returns-nonnull-attribute``: Returning null pointer

Modified: cfe/trunk/include/clang/Basic/Sanitizers.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.def?rev=304459=304458=304459=diff
==
--- cfe/trunk/include/clang/Basic/Sanitizers.def (original)
+++ cfe/trunk/include/clang/Basic/Sanitizers.def Thu Jun  1 14:22:18 2017
@@ -73,6 +73,7 @@ SANITIZER("nullability-return", Nullabil
 SANITIZER_GROUP("nullability", Nullability,
 NullabilityArg | NullabilityAssign | NullabilityReturn)
 SANITIZER("object-size", ObjectSize)
+SANITIZER("pointer-overflow", PointerOverflow)
 SANITIZER("return", Return)
 SANITIZER("returns-nonnull-attribute", ReturnsNonnullAttribute)
 SANITIZER("shift-base", ShiftBase)
@@ -108,9 +109,9 @@ SANITIZER("safe-stack", SafeStack)
 SANITIZER_GROUP("undefined", Undefined,
 Alignment | Bool | ArrayBounds | Enum | FloatCastOverflow |
 FloatDivideByZero | IntegerDivideByZero | NonnullAttribute 
|
-Null | ObjectSize | Return | ReturnsNonnullAttribute |
-Shift | SignedIntegerOverflow | Unreachable | VLABound |
-Function | Vptr)
+Null | ObjectSize | PointerOverflow | Return |
+ReturnsNonnullAttribute | Shift | SignedIntegerOverflow |
+Unreachable | VLABound | Function | Vptr)
 
 // -fsanitize=undefined-trap is an alias for -fsanitize=undefined.
 SANITIZER_GROUP("undefined-trap", UndefinedTrap, Undefined)

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=304459=304458=304459=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Jun  1 14:22:18 2017
@@ -3002,9 +3002,10 @@ static llvm::Value *emitArraySubscriptGE
   llvm::Value *ptr,
   ArrayRef indices,
   bool inbounds,
+  SourceLocation loc,
 const llvm::Twine  = "arrayidx") {
   if (inbounds) {
-return CGF.Builder.CreateInBoundsGEP(ptr, indices, name);
+return CGF.EmitCheckedInBoundsGEP(ptr, indices, loc, name);
   } else {
 return CGF.Builder.CreateGEP(ptr, indices, name);
   }
@@ -3035,8 +3036,9 @@ static QualType getFixedSizeElementType(
 }
 
 static Address 

[PATCH] D31972: Do not force the frame pointer by default for ARM EABI

2017-06-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:569
 
+  if (Triple.getEnvironment() == llvm::Triple::EABI) {
+switch (Triple.getArch()) {

chrib wrote:
> efriedma wrote:
> > Specifically checking for "llvm::Triple::EABI" is suspicious... what are 
> > you trying to distinguish?
> I'm targeting the AAPCS for bare toolsets, (we could also test EABIHF by the 
> way)
> 
> I'm not sure about the other ABIs (such as llvm::Triple::OpenBSD) so it is 
> probably conservative and stick to what I can test. Do you think this 
> pertains to more, for instance to AAPCS-LINUX, without breaking anything ?
> 
So... something like isTargetAEABI() in ARMSubtarget.h?

Please clarify the comment, and add a check for EABIHF.


https://reviews.llvm.org/D31972



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


r304456 - Add compatibility alias for -Wno-#warnings

2017-06-01 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jun  1 14:08:34 2017
New Revision: 304456

URL: http://llvm.org/viewvc/llvm-project?rev=304456=rev
Log:
Add compatibility alias for -Wno-#warnings

GCC uses -Wno-cpp for this, so seems reasonable to add an alias to
match.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/test/Misc/diag-mapping2.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=304456=304455=304456=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Jun  1 14:08:34 2017
@@ -733,6 +733,7 @@ def Pedantic : DiagGroup<"pedantic">;
 // Aliases.
 def : DiagGroup<"", [Extra]>;   // -W = -Wextra
 def : DiagGroup<"endif-labels", [ExtraTokens]>; // 
-Wendif-labels=-Wextra-tokens
+def : DiagGroup<"cpp", [PoundWarning]>; // -Wcpp = -W#warnings
 def : DiagGroup<"comments", [Comment]>; // -Wcomments = -Wcomment
 def : DiagGroup<"conversion-null",
 [NullConversion]>; // -Wconversion-null = -Wnull-conversion

Modified: cfe/trunk/test/Misc/diag-mapping2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-mapping2.c?rev=304456=304455=304456=diff
==
--- cfe/trunk/test/Misc/diag-mapping2.c (original)
+++ cfe/trunk/test/Misc/diag-mapping2.c Thu Jun  1 14:08:34 2017
@@ -4,6 +4,7 @@
 // This should not emit anything.
 // RUN: %clang_cc1 %s -w 2>&1 | not grep diagnostic
 // RUN: %clang_cc1 %s -Wno-#warnings 2>&1 | not grep diagnostic
+// RUN: %clang_cc1 %s -Wno-cpp 2>&1 | not grep diagnostic
 
 // -Werror can map all warnings to error.
 // RUN: not %clang_cc1 %s -Werror 2>&1 | grep "error: foo"


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


r304455 - Fixed broken test (strict-vtable-pointers)

2017-06-01 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Thu Jun  1 14:08:05 2017
New Revision: 304455

URL: http://llvm.org/viewvc/llvm-project?rev=304455=rev
Log:
Fixed broken test (strict-vtable-pointers)

Modified:
cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp

Modified: cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp?rev=304455=304454=304455=diff
==
--- cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp Thu Jun  1 14:08:05 
2017
@@ -209,7 +209,7 @@ void UnionsBarriers(U *u) {
   // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
   // CHECK-NEW: call void @_Z2g2P1A(%struct.A*
   g2(>b);
-  // CHECK-NEW: call void @_Z9changeToAP1U(%union.U* %6)
+  // CHECK-NEW: call void @_Z9changeToAP1U(%union.U* 
   changeToA(u);
   // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
   // call void @_Z2g2P1A(%struct.A* %a)


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


[PATCH] D33706: CodeGen: Cast temporary variable to proper address space

2017-06-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 101070.
yaxunl marked 2 inline comments as done.
yaxunl retitled this revision from "[AMDGPU] Fix address space for global and 
temporary variables in C++" to "CodeGen: Cast temporary variable to proper 
address space".
yaxunl edited the summary of this revision.
yaxunl added a comment.

Keep changes for temporary variables only.


https://reviews.llvm.org/D33706

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/address-space.c
  test/CodeGen/default-address-space.c
  test/CodeGenCXX/amdgcn-automatic-variable.cpp

Index: test/CodeGenCXX/amdgcn-automatic-variable.cpp
===
--- test/CodeGenCXX/amdgcn-automatic-variable.cpp
+++ test/CodeGenCXX/amdgcn-automatic-variable.cpp
@@ -3,9 +3,10 @@
 // CHECK-LABEL: define void @_Z5func1Pi(i32* %x)
 void func1(int *x) {
   // CHECK: %[[x_addr:.*]] = alloca i32*{{.*}}addrspace(5)
-  // CHECK: store i32* %x, i32* addrspace(5)* %[[x_addr]]
-  // CHECK: %[[r0:.*]] = load i32*, i32* addrspace(5)* %[[x_addr]]
-  // CHECK: store i32 1, i32* %[[r0]]
+  // CHECK: %[[r0:.*]] = addrspacecast i32* addrspace(5)* %[[x_addr]] to i32**
+  // CHECK: store i32* %x, i32** %[[r0]]
+  // CHECK: %[[r1:.*]] = load i32*, i32** %[[r0]]
+  // CHECK: store i32 1, i32* %[[r1]]
   *x = 1;
 }
 
@@ -70,3 +71,12 @@
   // CHECK: call void @_ZN1AD1Ev(%class.A* %[[r0]])
   A a;
 }
+
+// CHECK-LABEL: define void @_Z5func4i
+void func4(int x) {
+  // CHECK: %[[x_addr:.*]] = alloca i32, align 4, addrspace(5)
+  // CHECK: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %[[x_addr]] to i32*
+  // CHECK: store i32 %x, i32* %[[r0]], align 4
+  // CHECK: call void @_Z5func1Pi(i32* %[[r0]])
+  func1();
+}
Index: test/CodeGen/default-address-space.c
===
--- test/CodeGen/default-address-space.c
+++ test/CodeGen/default-address-space.c
@@ -22,9 +22,10 @@
 int test1() { return foo; }
 
 // COM-LABEL: define i32 @test2(i32 %i)
-// PIZ: load i32, i32 addrspace(4)*
+// COM: %[[addr:.*]] = getelementptr
+// PIZ: load i32, i32 addrspace(4)* %[[addr]]
 // PIZ-NEXT: ret i32
-// CHECK: load i32, i32*
+// CHECK: load i32, i32* %[[addr]]
 // CHECK-NEXT: ret i32
 int test2(int i) { return ban[i]; }
 
@@ -42,15 +43,17 @@
 }
 
 // PIZ-LABEL: define void @test4(i32 addrspace(4)* %a)
-// PIZ: %[[a_addr:.*]] = alloca i32 addrspace(4)*
-// PIZ: store i32 addrspace(4)* %a, i32 addrspace(4)** %[[a_addr]]
-// PIZ: %[[r0:.*]] = load i32 addrspace(4)*, i32 addrspace(4)** %[[a_addr]]
+// PIZ: %[[alloca:.*]] = alloca i32 addrspace(4)*
+// PIZ: %[[a_addr:.*]] = addrspacecast{{.*}} %[[alloca]] to i32 addrspace(4)* addrspace(4)*
+// PIZ: store i32 addrspace(4)* %a, i32 addrspace(4)* addrspace(4)* %[[a_addr]]
+// PIZ: %[[r0:.*]] = load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* %[[a_addr]]
 // PIZ: %[[arrayidx:.*]] = getelementptr inbounds i32, i32 addrspace(4)* %[[r0]]
 // PIZ: store i32 0, i32 addrspace(4)* %[[arrayidx]]
 // CHECK-LABEL: define void @test4(i32* %a)
-// CHECK: %[[a_addr:.*]] = alloca i32*, align 4, addrspace(5)
-// CHECK: store i32* %a, i32* addrspace(5)* %[[a_addr]]
-// CHECK: %[[r0:.*]] = load i32*, i32* addrspace(5)* %[[a_addr]]
+// CHECK: %[[alloca:.*]] = alloca i32*, align 4, addrspace(5)
+// CHECK: %[[a_addr:.*]] = addrspacecast{{.*}} %[[alloca]] to i32**
+// CHECK: store i32* %a, i32** %[[a_addr]]
+// CHECK: %[[r0:.*]] = load i32*, i32** %[[a_addr]]
 // CHECK: %[[arrayidx:.*]] = getelementptr inbounds i32, i32* %[[r0]]
 // CHECK: store i32 0, i32* %[[arrayidx]]
 void test4(int *a) {
Index: test/CodeGen/address-space.c
===
--- test/CodeGen/address-space.c
+++ test/CodeGen/address-space.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | FileCheck -check-prefixes=CHECK,GIZ %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | FileCheck -check-prefixes=CHECK,X86,GIZ %s
 // RUN: %clang_cc1 -triple amdgcn -emit-llvm < %s | FileCheck -check-prefixes=CHECK,PIZ %s
-// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck -check-prefixes=CHECK,GIZ %s
+// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck -check-prefixes=CHECK,AMDGIZ,GIZ %s
 
 // CHECK: @foo = common addrspace(1) global
 int foo __attribute__((address_space(1)));
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1915,13 +1915,32 @@
 LValueBaseInfo *BaseInfo = nullptr);
   LValue EmitLoadOfPointerLValue(Address Ptr, const PointerType *PtrTy);
 
-  /// CreateTempAlloca - This creates a alloca and inserts it into the entry
-  /// block. The caller is responsible for setting an appropriate alignment on
+  /// CreateTempAlloca - 

r304451 - [SemaCXX] Add diagnostics to require_constant_initialization

2017-06-01 Thread Keno Fischer via cfe-commits
Author: kfischer
Date: Thu Jun  1 13:54:16 2017
New Revision: 304451

URL: http://llvm.org/viewvc/llvm-project?rev=304451=rev
Log:
[SemaCXX] Add diagnostics to require_constant_initialization

Summary:
This hooks up the detailed diagnostics of why constant initialization was
not possible if require_constant_initialization reports an error.
I have updated the test to account for the new notes.

Reviewed By: EricWF
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D24371

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=304451=304450=304451=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jun  1 13:54:16 2017
@@ -6,6 +6,17 @@ void Sema::CheckCompleteVariableDeclarat
   << Init->getSourceRange();
 Diag(attr->getLocation(), 
diag::note_declared_required_constant_init_here)
   << attr->getRange();
+if (getLangOpts().CPlusPlus11) {
+  APValue Value;
+  SmallVector Notes;
+  Init->EvaluateAsInitializer(Value, getASTContext(), var, Notes);
+  for (auto  : Notes)
+Diag(it.first, it.second);
+} else {
+  Diag(CacheCulprit->getExprLoc(),
+   diag::note_invalid_subexpr_in_const_expr)
+  << CacheCulprit->getSourceRange();
+}
   }
 }
 else if (!var->isConstexpr() && IsGlobal &&

Modified: cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp?rev=304451=304450=304451=diff
==
--- cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp Thu Jun  1 
13:54:16 2017
@@ -7,9 +7,9 @@
 
 #define ATTR __attribute__((require_constant_initialization)) // expected-note 
0+ {{expanded from macro}}
 
-int ReturnInt();
+int ReturnInt(); // expected-note 0+ {{declared here}}
 
-struct PODType {
+struct PODType { // expected-note 0+ {{declared here}}
   int value;
   int value2;
 };
@@ -20,20 +20,20 @@ struct PODType {
 struct LitType {
   constexpr LitType() : value(0) {}
   constexpr LitType(int x) : value(x) {}
-  LitType(void *) : value(-1) {}
+  LitType(void *) : value(-1) {} // expected-note 0+ {{declared here}}
   int value;
 };
 #endif
 
-struct NonLit {
+struct NonLit { // expected-note 0+ {{declared here}}
 #if __cplusplus >= 201402L
   constexpr NonLit() : value(0) {}
   constexpr NonLit(int x) : value(x) {}
 #else
-  NonLit() : value(0) {}
+  NonLit() : value(0) {} // expected-note 0+ {{declared here}}
   NonLit(int x) : value(x) {}
 #endif
-  NonLit(void *) : value(-1) {}
+  NonLit(void *) : value(-1) {} // expected-note 0+ {{declared here}}
   ~NonLit() {}
   int value;
 };
@@ -43,7 +43,7 @@ struct StoresNonLit {
   constexpr StoresNonLit() : obj() {}
   constexpr StoresNonLit(int x) : obj(x) {}
 #else
-  StoresNonLit() : obj() {}
+  StoresNonLit() : obj() {} // expected-note 0+ {{declared here}}
   StoresNonLit(int x) : obj(x) {}
 #endif
   StoresNonLit(void *p) : obj(p) {}
@@ -82,6 +82,12 @@ void test_basic_start_static_2_1() {
   const int non_global = 42;
   ATTR static const int _init = non_global; // expected-error {{variable 
does not have a constant initializer}}
   // expected-note@-1 {{required by 'require_constant_initialization' 
attribute here}}
+#if __cplusplus >= 201103L
+  // expected-note@-3 {{reference to 'non_global' is not a constant 
expression}}
+  // expected-note@-5 {{declared here}}
+#else
+  // expected-note@-6 {{subexpression not valid in a constant expression}}
+#endif
   ATTR static const int _init = glvalue_int;
   ATTR static const int _init = 42;
 }
@@ -89,8 +95,18 @@ void test_basic_start_static_2_1() {
 ATTR const int _ref = 42;
 ATTR const int _ref2 = ReturnInt(); // expected-error {{variable does not 
have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initialization' attribute 
here}}
+#if __cplusplus >= 201103L
+// expected-note@-3 {{non-constexpr function 'ReturnInt' cannot be used in a 
constant expression}}
+#else
+// expected-note@-5 {{subexpression not valid in a constant expression}}
+#endif
 ATTR const NonLit _temp_ref = 42; // expected-error {{variable does not 
have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initialization' attribute 
here}}
+#if __cplusplus >= 201103L
+// expected-note@-3 {{non-literal type 'const NonLit' cannot be used in a 
constant expression}}
+#else
+// expected-note@-5 {{subexpression not valid in a constant expression}}

[PATCH] D24371: Add diagnostics to require_constant_initialization

2017-06-01 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304451: [SemaCXX] Add diagnostics to 
require_constant_initialization (authored by kfischer).

Changed prior to commit:
  https://reviews.llvm.org/D24371?vs=100949=101066#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24371

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp

Index: cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp
===
--- cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp
+++ cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp
@@ -7,9 +7,9 @@
 
 #define ATTR __attribute__((require_constant_initialization)) // expected-note 0+ {{expanded from macro}}
 
-int ReturnInt();
+int ReturnInt(); // expected-note 0+ {{declared here}}
 
-struct PODType {
+struct PODType { // expected-note 0+ {{declared here}}
   int value;
   int value2;
 };
@@ -20,20 +20,20 @@
 struct LitType {
   constexpr LitType() : value(0) {}
   constexpr LitType(int x) : value(x) {}
-  LitType(void *) : value(-1) {}
+  LitType(void *) : value(-1) {} // expected-note 0+ {{declared here}}
   int value;
 };
 #endif
 
-struct NonLit {
+struct NonLit { // expected-note 0+ {{declared here}}
 #if __cplusplus >= 201402L
   constexpr NonLit() : value(0) {}
   constexpr NonLit(int x) : value(x) {}
 #else
-  NonLit() : value(0) {}
+  NonLit() : value(0) {} // expected-note 0+ {{declared here}}
   NonLit(int x) : value(x) {}
 #endif
-  NonLit(void *) : value(-1) {}
+  NonLit(void *) : value(-1) {} // expected-note 0+ {{declared here}}
   ~NonLit() {}
   int value;
 };
@@ -43,7 +43,7 @@
   constexpr StoresNonLit() : obj() {}
   constexpr StoresNonLit(int x) : obj(x) {}
 #else
-  StoresNonLit() : obj() {}
+  StoresNonLit() : obj() {} // expected-note 0+ {{declared here}}
   StoresNonLit(int x) : obj(x) {}
 #endif
   StoresNonLit(void *p) : obj(p) {}
@@ -82,23 +82,44 @@
   const int non_global = 42;
   ATTR static const int _init = non_global; // expected-error {{variable does not have a constant initializer}}
   // expected-note@-1 {{required by 'require_constant_initialization' attribute here}}
+#if __cplusplus >= 201103L
+  // expected-note@-3 {{reference to 'non_global' is not a constant expression}}
+  // expected-note@-5 {{declared here}}
+#else
+  // expected-note@-6 {{subexpression not valid in a constant expression}}
+#endif
   ATTR static const int _init = glvalue_int;
   ATTR static const int _init = 42;
 }
 
 ATTR const int _ref = 42;
 ATTR const int _ref2 = ReturnInt(); // expected-error {{variable does not have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initialization' attribute here}}
+#if __cplusplus >= 201103L
+// expected-note@-3 {{non-constexpr function 'ReturnInt' cannot be used in a constant expression}}
+#else
+// expected-note@-5 {{subexpression not valid in a constant expression}}
+#endif
 ATTR const NonLit _temp_ref = 42; // expected-error {{variable does not have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initialization' attribute here}}
+#if __cplusplus >= 201103L
+// expected-note@-3 {{non-literal type 'const NonLit' cannot be used in a constant expression}}
+#else
+// expected-note@-5 {{subexpression not valid in a constant expression}}
+#endif
 
 #if __cplusplus >= 201103L
 ATTR const LitType _temp_ref = 42;
 ATTR const int _ref = LitType{}.value;
 #endif
 
 ATTR const int _subobj_ref = NonLit().value; // expected-error {{variable does not have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initialization' attribute here}}
+#if __cplusplus >= 201103L
+// expected-note-re@-3 {{non-literal type '{{.*}}' cannot be used in a constant expression}}
+#else
+// expected-note@-5 {{subexpression not valid in a constant expression}}
+#endif
 
 struct TT1 {
   ATTR static const int _init;
@@ -116,6 +137,8 @@
 #if __cplusplus >= 201103L
 thread_local const int ::tl_glvalue_init = glvalue_int;
 thread_local const int ::tl_temp_init = 42; // expected-error {{variable does not have a constant initializer}}
+// expected-note@-1 {{reference to temporary is not a constant expression}}
+// expected-note@-2 {{temporary created here}}
 #endif
 
 // [basic.start.static]p2.2
@@ -129,17 +152,25 @@
 #else
   ATTR static PODType pod; // expected-error {{variable does not have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initialization' attribute here}}
+// expected-note@-2 {{non-constexpr constructor 'PODType' cannot be used in a constant expression}}
 #endif
   ATTR static PODType pot2 = {ReturnInt()}; // expected-error {{variable does not have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initialization' attribute here}}
+#if __cplusplus >= 201103L
+// expected-note@-3 

[libcxx] r304450 - Remove ubsan XFAILS in two tests

2017-06-01 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Jun  1 13:48:27 2017
New Revision: 304450

URL: http://llvm.org/viewvc/llvm-project?rev=304450=rev
Log:
Remove ubsan XFAILS in two tests

These two tests are ubsan-clean now:
http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/3553/

Modified:

libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp

libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp?rev=304450=304449=304450=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
 Thu Jun  1 13:48:27 2017
@@ -10,9 +10,6 @@
 
 // UNSUPPORTED: c++98, c++03, c++11
 
-// FIXME: When run under UBSAN this test hits an assertion inside Clang
-// XFAIL: ubsan
-
 #include 
 #include 
 

Modified: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp?rev=304450=304449=304450=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
 Thu Jun  1 13:48:27 2017
@@ -10,9 +10,6 @@
 
 // UNSUPPORTED: c++98, c++03, c++11
 
-// FIXME: When run under UBSAN this test hits an assertion inside Clang
-// XFAIL: ubsan
-
 #include 
 #include 
 #include 


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


[PATCH] D33698: [CodeGen][ObjC] Fix assertion failure in CodeGenFunction::EmitARCStoreStrongCall

2017-06-01 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304449: [CodeGen][ObjC] Fix assertion failure in 
EmitARCStoreStrongCall. (authored by ahatanak).

Changed prior to commit:
  https://reviews.llvm.org/D33698?vs=100787=101060#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33698

Files:
  cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
  cfe/trunk/test/CodeGenObjC/parameterized_classes.m


Index: cfe/trunk/test/CodeGenObjC/parameterized_classes.m
===
--- cfe/trunk/test/CodeGenObjC/parameterized_classes.m
+++ cfe/trunk/test/CodeGenObjC/parameterized_classes.m
@@ -68,3 +68,31 @@
   // CHECK: call i8* @objc_retainBlock
   // CHECK: ret void
 }
+
+// CHECK-LABEL: define internal void @"\01-[Derived setDest:]
+// CHECK: %[[SELFADDR:.*]] = alloca %[[SELFTY:.*]]*
+// CHECK: %[[AADDR:.*]] = alloca %[[IVARTY:.*]]*
+// CHECK: %[[V2:.*]] = load %[[IVARTY]]*, %[[IVARTY]]** %[[AADDR]]
+// CHECK: %[[V3:.*]] = load %[[SELFTY]]*, %[[SELFTY]]** %[[SELFADDR]]
+// CHECK: %[[IVAR:.*]] = load i64, i64* @"OBJC_IVAR_$_Base._destination"
+// CHECK: %[[V4:.*]] = bitcast %[[SELFTY]]* %[[V3]] to i8*
+// CHECK: %[[ADDPTR:.*]] = getelementptr inbounds i8, i8* %[[V4]], i64 
%[[IVAR]]
+// CHECK: %[[V5:.*]] = bitcast i8* %[[ADDPTR]] to %[[IVARTY]]**
+// CHECK: %[[V6:.*]] = bitcast %[[IVARTY]]** %[[V5]] to i8**
+// CHECK: %[[V7:.*]] = bitcast %[[IVARTY]]* %[[V2]] to i8*
+// CHECK: call void @objc_storeStrong(i8** %[[V6]], i8* %[[V7]])
+
+@interface Base : NSObject {
+  DestType _destination;
+}
+@end
+
+@interface Derived : Base
+- (void)setDest:(NSObject *)a;
+@end
+
+@implementation Derived
+- (void)setDest:(NSObject *)a {
+  _destination = a;
+}
+@end
Index: cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
@@ -90,7 +90,11 @@
unsigned CVRQualifiers,
llvm::Value *Offset) {
   // Compute (type*) ( (char *) BaseValue + Offset)
-  QualType IvarTy = Ivar->getType().withCVRQualifiers(CVRQualifiers);
+  QualType InterfaceTy{OID->getTypeForDecl(), 0};
+  QualType ObjectPtrTy =
+  CGF.CGM.getContext().getObjCObjectPointerType(InterfaceTy);
+  QualType IvarTy =
+  Ivar->getUsageType(ObjectPtrTy).withCVRQualifiers(CVRQualifiers);
   llvm::Type *LTy = CGF.CGM.getTypes().ConvertTypeForMem(IvarTy);
   llvm::Value *V = CGF.Builder.CreateBitCast(BaseValue, CGF.Int8PtrTy);
   V = CGF.Builder.CreateInBoundsGEP(V, Offset, "add.ptr");


Index: cfe/trunk/test/CodeGenObjC/parameterized_classes.m
===
--- cfe/trunk/test/CodeGenObjC/parameterized_classes.m
+++ cfe/trunk/test/CodeGenObjC/parameterized_classes.m
@@ -68,3 +68,31 @@
   // CHECK: call i8* @objc_retainBlock
   // CHECK: ret void
 }
+
+// CHECK-LABEL: define internal void @"\01-[Derived setDest:]
+// CHECK: %[[SELFADDR:.*]] = alloca %[[SELFTY:.*]]*
+// CHECK: %[[AADDR:.*]] = alloca %[[IVARTY:.*]]*
+// CHECK: %[[V2:.*]] = load %[[IVARTY]]*, %[[IVARTY]]** %[[AADDR]]
+// CHECK: %[[V3:.*]] = load %[[SELFTY]]*, %[[SELFTY]]** %[[SELFADDR]]
+// CHECK: %[[IVAR:.*]] = load i64, i64* @"OBJC_IVAR_$_Base._destination"
+// CHECK: %[[V4:.*]] = bitcast %[[SELFTY]]* %[[V3]] to i8*
+// CHECK: %[[ADDPTR:.*]] = getelementptr inbounds i8, i8* %[[V4]], i64 %[[IVAR]]
+// CHECK: %[[V5:.*]] = bitcast i8* %[[ADDPTR]] to %[[IVARTY]]**
+// CHECK: %[[V6:.*]] = bitcast %[[IVARTY]]** %[[V5]] to i8**
+// CHECK: %[[V7:.*]] = bitcast %[[IVARTY]]* %[[V2]] to i8*
+// CHECK: call void @objc_storeStrong(i8** %[[V6]], i8* %[[V7]])
+
+@interface Base : NSObject {
+  DestType _destination;
+}
+@end
+
+@interface Derived : Base
+- (void)setDest:(NSObject *)a;
+@end
+
+@implementation Derived
+- (void)setDest:(NSObject *)a {
+  _destination = a;
+}
+@end
Index: cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
@@ -90,7 +90,11 @@
unsigned CVRQualifiers,
llvm::Value *Offset) {
   // Compute (type*) ( (char *) BaseValue + Offset)
-  QualType IvarTy = Ivar->getType().withCVRQualifiers(CVRQualifiers);
+  QualType InterfaceTy{OID->getTypeForDecl(), 0};
+  QualType ObjectPtrTy =
+  CGF.CGM.getContext().getObjCObjectPointerType(InterfaceTy);
+  QualType IvarTy =
+  Ivar->getUsageType(ObjectPtrTy).withCVRQualifiers(CVRQualifiers);
   llvm::Type *LTy = CGF.CGM.getTypes().ConvertTypeForMem(IvarTy);
   llvm::Value *V = CGF.Builder.CreateBitCast(BaseValue, CGF.Int8PtrTy);
   V = CGF.Builder.CreateInBoundsGEP(V, Offset, "add.ptr");
___
cfe-commits mailing 

r304449 - [CodeGen][ObjC] Fix assertion failure in EmitARCStoreStrongCall.

2017-06-01 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Jun  1 13:41:25 2017
New Revision: 304449

URL: http://llvm.org/viewvc/llvm-project?rev=304449=rev
Log:
[CodeGen][ObjC] Fix assertion failure in EmitARCStoreStrongCall.

The assertion fails because EmitValueForIvarAtOffset doesn't get the
correct type of the ivar when the class the ivar belongs to is
parameterized. This commit fixes the function to compute the ivar's type
based on the type argument provided to the parameterized class.

rdar://problem/32461723

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

Modified:
cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
cfe/trunk/test/CodeGenObjC/parameterized_classes.m

Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp?rev=304449=304448=304449=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp Thu Jun  1 13:41:25 2017
@@ -90,7 +90,11 @@ LValue CGObjCRuntime::EmitValueForIvarAt
unsigned CVRQualifiers,
llvm::Value *Offset) {
   // Compute (type*) ( (char *) BaseValue + Offset)
-  QualType IvarTy = Ivar->getType().withCVRQualifiers(CVRQualifiers);
+  QualType InterfaceTy{OID->getTypeForDecl(), 0};
+  QualType ObjectPtrTy =
+  CGF.CGM.getContext().getObjCObjectPointerType(InterfaceTy);
+  QualType IvarTy =
+  Ivar->getUsageType(ObjectPtrTy).withCVRQualifiers(CVRQualifiers);
   llvm::Type *LTy = CGF.CGM.getTypes().ConvertTypeForMem(IvarTy);
   llvm::Value *V = CGF.Builder.CreateBitCast(BaseValue, CGF.Int8PtrTy);
   V = CGF.Builder.CreateInBoundsGEP(V, Offset, "add.ptr");

Modified: cfe/trunk/test/CodeGenObjC/parameterized_classes.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/parameterized_classes.m?rev=304449=304448=304449=diff
==
--- cfe/trunk/test/CodeGenObjC/parameterized_classes.m (original)
+++ cfe/trunk/test/CodeGenObjC/parameterized_classes.m Thu Jun  1 13:41:25 2017
@@ -68,3 +68,31 @@ void blockTest(NSMutableArray : NSObject {
+  DestType _destination;
+}
+@end
+
+@interface Derived : Base
+- (void)setDest:(NSObject *)a;
+@end
+
+@implementation Derived
+- (void)setDest:(NSObject *)a {
+  _destination = a;
+}
+@end


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


[PATCH] D31830: Emit invariant.group.barrier when using union field

2017-06-01 Thread Piotr Padlewski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304448: Emit invariant.group.barrier when using union field 
(authored by Prazek).

Changed prior to commit:
  https://reviews.llvm.org/D31830?vs=100977=101058#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31830

Files:
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp

Index: cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
===
--- cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
+++ cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fstrict-vtable-pointers -disable-llvm-passes -O2 -emit-llvm -o %t.ll
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fstrict-vtable-pointers -std=c++11 -disable-llvm-passes -O2 -emit-llvm -o %t.ll
 // RUN: FileCheck --check-prefix=CHECK-CTORS %s < %t.ll
 // RUN: FileCheck --check-prefix=CHECK-NEW %s < %t.ll
 // RUN: FileCheck --check-prefix=CHECK-DTORS %s < %t.ll
@@ -180,6 +180,119 @@
 // CHECK-CTORS-NOT: @llvm.invariant.group.barrier(
 // CHECK-CTORS-LABEL: {{^}}}
 
+struct A {
+  virtual void foo();
+};
+struct B : A {
+  virtual void foo();
+};
+
+union U {
+  A a;
+  B b;
+};
+
+void changeToB(U *u);
+void changeToA(U *u);
+
+void g2(A *a) {
+  a->foo();
+}
+// We have to guard access to union fields with invariant.group, because
+// it is very easy to skip the barrier with unions. In this example the inlined
+// g2 will produce loads with the same !invariant.group metadata, and
+// u->a and u->b would use the same pointer.
+// CHECK-NEW-LABEL: define void @_Z14UnionsBarriersP1U
+void UnionsBarriers(U *u) {
+  // CHECK-NEW: call void @_Z9changeToBP1U(
+  changeToB(u);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z2g2P1A(%struct.A*
+  g2(>b);
+  // CHECK-NEW: call void @_Z9changeToAP1U(%union.U* %6)
+  changeToA(u);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // call void @_Z2g2P1A(%struct.A* %a)
+  g2(>a);
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+}
+
+struct HoldingVirtuals {
+  A a;
+};
+
+struct Empty {};
+struct AnotherEmpty {
+  Empty e;
+};
+union NoVptrs {
+  int a;
+  AnotherEmpty empty;
+};
+void take(AnotherEmpty &);
+
+// CHECK-NEW-LABEL: noBarriers
+void noBarriers(NoVptrs ) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: 42
+  noVptrs.a += 42;
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR12AnotherEmpty(
+  take(noVptrs.empty);
+}
+
+union U2 {
+  HoldingVirtuals h;
+  int z;
+};
+void take(HoldingVirtuals &);
+
+// CHECK-NEW-LABEL: define void @_Z15UnionsBarriers2R2U2
+void UnionsBarriers2(U2 ) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: 42
+  u.z += 42;
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR15HoldingVirtuals(
+  take(u.h);
+}
+
+struct VirtualInBase : HoldingVirtuals, Empty {
+};
+
+struct VirtualInVBase : virtual Empty, virtual HoldingVirtuals {
+};
+
+// It has vtable by virtual inheritance.
+struct VirtualInheritance : virtual Empty {
+};
+
+union U3 {
+  VirtualInBase v1;
+  VirtualInBase v2;
+  VirtualInheritance v3;
+  int z;
+};
+
+void take(VirtualInBase &);
+void take(VirtualInVBase &);
+void take(VirtualInheritance &);
+
+void UnionsBarrier3(U3 ) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: 42
+  u.z += 42;
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR13VirtualInBase(
+  take(u.v1);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR13VirtualInBase(
+  take(u.v2);
+
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR18VirtualInheritance(
+  take(u.v3);
+}
 
 /** DTORS **/
 // CHECK-DTORS-LABEL: define linkonce_odr void @_ZN10StaticBaseD2Ev(
Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -3530,6 +3530,25 @@
   return CGF.Builder.CreateStructGEP(base, idx, offset, field->getName());
 }
 
+static bool hasAnyVptr(const QualType Type, const ASTContext ) {
+  const auto *RD = Type.getTypePtr()->getAsCXXRecordDecl();
+  if (!RD)
+return false;
+
+  if (RD->isDynamicClass())
+return true;
+
+  for (const auto  : RD->bases())
+if (hasAnyVptr(Base.getType(), Context))
+  return true;
+
+  for (const FieldDecl *Field : RD->fields())
+if (hasAnyVptr(Field->getType(), Context))
+  return true;
+
+  return false;
+}
+
 LValue CodeGenFunction::EmitLValueForField(LValue base,
const FieldDecl *field) {
   LValueBaseInfo 

r304448 - Emit invariant.group.barrier when using union field

2017-06-01 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Thu Jun  1 13:39:34 2017
New Revision: 304448

URL: http://llvm.org/viewvc/llvm-project?rev=304448=rev
Log:
Emit invariant.group.barrier when using union field

Summary:
We need to emit barrier if the union field
is CXXRecordDecl because it might have vptrs. The testcode
was wrongly devirtualized. It also proves that having different
groups for different dynamic types is not sufficient.

Reviewers: rjmccall, rsmith, mehdi_amini

Subscribers: amharc, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=304448=304447=304448=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Jun  1 13:39:34 2017
@@ -3530,6 +3530,25 @@ static Address emitAddrOfFieldStorage(Co
   return CGF.Builder.CreateStructGEP(base, idx, offset, field->getName());
 }
 
+static bool hasAnyVptr(const QualType Type, const ASTContext ) {
+  const auto *RD = Type.getTypePtr()->getAsCXXRecordDecl();
+  if (!RD)
+return false;
+
+  if (RD->isDynamicClass())
+return true;
+
+  for (const auto  : RD->bases())
+if (hasAnyVptr(Base.getType(), Context))
+  return true;
+
+  for (const FieldDecl *Field : RD->fields())
+if (hasAnyVptr(Field->getType(), Context))
+  return true;
+
+  return false;
+}
+
 LValue CodeGenFunction::EmitLValueForField(LValue base,
const FieldDecl *field) {
   LValueBaseInfo BaseInfo = base.getBaseInfo();
@@ -3572,6 +3591,14 @@ LValue CodeGenFunction::EmitLValueForFie
 assert(!type->isReferenceType() && "union has reference member");
 // TODO: handle path-aware TBAA for union.
 TBAAPath = false;
+
+const auto FieldType = field->getType();
+if (CGM.getCodeGenOpts().StrictVTablePointers &&
+hasAnyVptr(FieldType, getContext()))
+  // Because unions can easily skip invariant.barriers, we need to add
+  // a barrier every time CXXRecord field with vptr is referenced.
+  addr = Address(Builder.CreateInvariantGroupBarrier(addr.getPointer()),
+ addr.getAlignment());
   } else {
 // For structs, we GEP to the field that the record layout suggests.
 addr = emitAddrOfFieldStorage(*this, addr, field);

Modified: cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp?rev=304448=304447=304448=diff
==
--- cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp Thu Jun  1 13:39:34 
2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 
-fstrict-vtable-pointers -disable-llvm-passes -O2 -emit-llvm -o %t.ll
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 
-fstrict-vtable-pointers -std=c++11 -disable-llvm-passes -O2 -emit-llvm -o %t.ll
 // RUN: FileCheck --check-prefix=CHECK-CTORS %s < %t.ll
 // RUN: FileCheck --check-prefix=CHECK-NEW %s < %t.ll
 // RUN: FileCheck --check-prefix=CHECK-DTORS %s < %t.ll
@@ -180,6 +180,119 @@ struct DynamicFromStatic;
 // CHECK-CTORS-NOT: @llvm.invariant.group.barrier(
 // CHECK-CTORS-LABEL: {{^}}}
 
+struct A {
+  virtual void foo();
+};
+struct B : A {
+  virtual void foo();
+};
+
+union U {
+  A a;
+  B b;
+};
+
+void changeToB(U *u);
+void changeToA(U *u);
+
+void g2(A *a) {
+  a->foo();
+}
+// We have to guard access to union fields with invariant.group, because
+// it is very easy to skip the barrier with unions. In this example the inlined
+// g2 will produce loads with the same !invariant.group metadata, and
+// u->a and u->b would use the same pointer.
+// CHECK-NEW-LABEL: define void @_Z14UnionsBarriersP1U
+void UnionsBarriers(U *u) {
+  // CHECK-NEW: call void @_Z9changeToBP1U(
+  changeToB(u);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z2g2P1A(%struct.A*
+  g2(>b);
+  // CHECK-NEW: call void @_Z9changeToAP1U(%union.U* %6)
+  changeToA(u);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // call void @_Z2g2P1A(%struct.A* %a)
+  g2(>a);
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+}
+
+struct HoldingVirtuals {
+  A a;
+};
+
+struct Empty {};
+struct AnotherEmpty {
+  Empty e;
+};
+union NoVptrs {
+  int a;
+  AnotherEmpty empty;
+};
+void take(AnotherEmpty &);
+
+// CHECK-NEW-LABEL: noBarriers
+void noBarriers(NoVptrs ) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: 42
+  noVptrs.a += 42;
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR12AnotherEmpty(
+  

[PATCH] D33726: [driver][netbsd] Build and pass `-L` arguments to the linker

2017-06-01 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

A small subset can be found by searching for LINKER_RPATH_FLAG in pkgsrc. A 
classic offender is Emacs. For more, I would have to systematically search.


Repository:
  rL LLVM

https://reviews.llvm.org/D33726



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


Re: r297702 - [CodeGen][ObjC] Fix a bug where the type of an ivar wasn't encoded

2017-06-01 Thread Joerg Sonnenberger via cfe-commits
On Tue, Mar 14, 2017 at 04:00:53AM -, Akira Hatanaka via cfe-commits wrote:
> Author: ahatanak
> Date: Mon Mar 13 23:00:52 2017
> New Revision: 297702
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=297702=rev
> Log:
> [CodeGen][ObjC] Fix a bug where the type of an ivar wasn't encoded
> correctly.

This results in asserts on the attached test case. Can you have a look,
please?

Joerg
typedef BOOL;
@interface FormatScanner {
  BOOL : 1;
}
@end
@implementation FormatScanner
@end
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r304445 - Strip trailing whitespace. NFCI.

2017-06-01 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Jun  1 13:17:18 2017
New Revision: 304445

URL: http://llvm.org/viewvc/llvm-project?rev=304445=rev
Log:
Strip trailing whitespace. NFCI.

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=304445=30=304445=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Jun  1 13:17:18 2017
@@ -49,12 +49,12 @@ static bool functionHasPassObjectSizePar
 static ExprResult
 CreateFunctionRefExpr(Sema , FunctionDecl *Fn, NamedDecl *FoundDecl,
   bool HadMultipleCandidates,
-  SourceLocation Loc = SourceLocation(), 
+  SourceLocation Loc = SourceLocation(),
   const DeclarationNameLoc  = 
DeclarationNameLoc()){
   if (S.DiagnoseUseOfDecl(FoundDecl, Loc))
-return ExprError(); 
+return ExprError();
   // If FoundDecl is different from Fn (such as if one is a template
-  // and the other a specialization), make sure DiagnoseUseOfDecl is 
+  // and the other a specialization), make sure DiagnoseUseOfDecl is
   // called on both.
   // FIXME: This would be more comprehensively addressed by modifying
   // DiagnoseUseOfDecl to accept both the FoundDecl and the decl
@@ -79,7 +79,7 @@ static bool IsStandardConversion(Sema 
  bool CStyle,
  bool AllowObjCWritebackConversion);
 
-static bool IsTransparentUnionStandardConversion(Sema , Expr* From, 
+static bool IsTransparentUnionStandardConversion(Sema , Expr* From,
  QualType ,
  bool InOverloadResolution,
  StandardConversionSequence 
,
@@ -852,7 +852,7 @@ namespace {
   Expr *Saved;
 };
 SmallVector Entries;
-
+
   public:
 void save(Sema , Expr *) {
   assert(E->hasPlaceholderType(BuiltinType::ARCUnbridgedCast));
@@ -863,7 +863,7 @@ namespace {
 
 void restore() {
   for (SmallVectorImpl::iterator
- i = Entries.begin(), e = Entries.end(); i != e; ++i) 
+ i = Entries.begin(), e = Entries.end(); i != e; ++i)
 *i->Addr = i->Saved;
 }
   };
@@ -1368,9 +1368,9 @@ Sema::TryImplicitConversion(Expr *From,
 bool InOverloadResolution,
 bool CStyle,
 bool AllowObjCWritebackConversion) {
-  return ::TryImplicitConversion(*this, From, ToType, 
+  return ::TryImplicitConversion(*this, From, ToType,
  SuppressUserConversions, AllowExplicit,
- InOverloadResolution, CStyle, 
+ InOverloadResolution, CStyle,
  AllowObjCWritebackConversion,
  /*AllowObjCConversionOnExplicit=*/false);
 }
@@ -1396,7 +1396,7 @@ Sema::PerformImplicitConversion(Expr *Fr
 
   // Objective-C ARC: Determine whether we will allow the writeback conversion.
   bool AllowObjCWritebackConversion
-= getLangOpts().ObjCAutoRefCount && 
+= getLangOpts().ObjCAutoRefCount &&
   (Action == AA_Passing || Action == AA_Sending);
   if (getLangOpts().ObjC1)
 CheckObjCBridgeRelatedConversions(From->getLocStart(),
@@ -1592,15 +1592,15 @@ static bool IsStandardConversion(Sema 
 // if the function type matches except for [[noreturn]], it's ok
 if (!S.IsFunctionConversion(FromType,
   S.ExtractUnqualifiedFunctionType(ToType), resultTy))
-  // otherwise, only a boolean conversion is standard   
-  if (!ToType->isBooleanType()) 
-return false; 
+  // otherwise, only a boolean conversion is standard
+  if (!ToType->isBooleanType())
+return false;
   }
 
   // Check if the "from" expression is taking the address of an overloaded
   // function and recompute the FromType accordingly. Take advantage of the
   // fact that non-static member functions *must* have such an address-of
-  // expression. 
+  // expression.
   CXXMethodDecl *Method = dyn_cast(Fn);
   if (Method && !Method->isStatic()) {
 assert(isa(From->IgnoreParens()) &&
@@ -1638,7 +1638,7 @@ static bool IsStandardConversion(Sema 
 SCS.First = ICK_Lvalue_To_Rvalue;
 
 // C11 6.3.2.1p2:
-//   ... if the lvalue has atomic type, the value has the non-atomic 
version 
+//   ... if the lvalue has atomic type, the value has the non-atomic 
version
 //   of the type of the lvalue ...
 if (const AtomicType *Atomic = FromType->getAs())
   FromType = Atomic->getValueType();
@@ -1890,12 +1890,12 @@ static bool IsStandardConversion(Sema 
 }
 
 static 

r304444 - Remove late nullptr pointer test (PR32447)

2017-06-01 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Jun  1 13:13:02 2017
New Revision: 30

URL: http://llvm.org/viewvc/llvm-project?rev=30=rev
Log:
Remove late nullptr pointer test (PR32447)

IgnoreNarrowingConversion should never return nullptr, but I've added an assert 
just in case.

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=30=304443=30=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Jun  1 13:13:02 2017
@@ -330,13 +330,13 @@ StandardConversionSequence::getNarrowing
 } else if (FromType->isIntegralType(Ctx) && ToType->isRealFloatingType()) {
   llvm::APSInt IntConstantValue;
   const Expr *Initializer = IgnoreNarrowingConversion(Converted);
+  assert(Initializer && "Unknown conversion expression");
 
   // If it's value-dependent, we can't tell whether it's narrowing.
   if (Initializer->isValueDependent())
 return NK_Dependent_Narrowing;
 
-  if (Initializer &&
-  Initializer->isIntegerConstantExpr(IntConstantValue, Ctx)) {
+  if (Initializer->isIntegerConstantExpr(IntConstantValue, Ctx)) {
 // Convert the integer to the floating type.
 llvm::APFloat Result(Ctx.getFloatTypeSemantics(ToType));
 Result.convertFromAPInt(IntConstantValue, IntConstantValue.isSigned(),


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


Re: r304346 - [modules] When compiling a preprocessed module map, look for headers relative

2017-06-01 Thread Galina Kistanova via cfe-commits
Hello Richard,

This commit broke tests on few of our builders:

Failing Tests (2):
Clang :: Modules/preprocess-module.cpp
Clang :: Modules/preprocess-nested.cpp

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/10199
and
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/2819

Please have a look at this?

Also I see that email notifications on these failures were sent.

Thanks

Galina


On Wed, May 31, 2017 at 1:56 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Wed May 31 15:56:55 2017
> New Revision: 304346
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304346=rev
> Log:
> [modules] When compiling a preprocessed module map, look for headers
> relative
> to the original module map.
>
> Also use the path and name of the original module map when emitting that
> information into the .pcm file. The upshot of this is that the produced
> .pcm
> file will track information for headers in their original locations (where
> the
> module was preprocessed), not relative to whatever directory the
> preprocessed
> module map was in when it was built.
>
> Modified:
> cfe/trunk/include/clang/Basic/Module.h
> cfe/trunk/include/clang/Lex/HeaderSearch.h
> cfe/trunk/lib/Frontend/FrontendAction.cpp
> cfe/trunk/lib/Lex/HeaderSearch.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/test/Modules/preprocess-module.cpp
> cfe/trunk/test/Modules/preprocess-nested.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Module.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/Module.h?rev=304346=304345=304346=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/Module.h (original)
> +++ cfe/trunk/include/clang/Basic/Module.h Wed May 31 15:56:55 2017
> @@ -83,6 +83,10 @@ public:
>/// are found.
>const DirectoryEntry *Directory;
>
> +  /// \brief The presumed file name for the module map defining this
> module.
> +  /// Only non-empty when building from preprocessed source.
> +  std::string PresumedModuleMapFile;
> +
>/// \brief The umbrella header or directory.
>llvm::PointerUnion Umbrella;
>
>
> Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Lex/HeaderSearch.h?rev=304346=304345=304346=diff
> 
> ==
> --- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
> +++ cfe/trunk/include/clang/Lex/HeaderSearch.h Wed May 31 15:56:55 2017
> @@ -543,10 +543,13 @@ public:
>/// \param Offset [inout] An offset within ID to start parsing. On exit,
>///filled by the end of the parsed contents (either EOF or the
>///location of an end-of-module-map pragma).
> -  ///
> +  /// \param OriginalModuleMapFile The original path to the module map
> file,
> +  ///used to resolve paths within the module (this is required
> when
> +  ///building the module from preprocessed source).
>/// \returns true if an error occurred, false otherwise.
>bool loadModuleMapFile(const FileEntry *File, bool IsSystem,
> - FileID ID = FileID(), unsigned *Offset =
> nullptr);
> + FileID ID = FileID(), unsigned *Offset = nullptr,
> + StringRef OriginalModuleMapFile = StringRef());
>
>/// \brief Collect the set of all known, top-level modules.
>///
>
> Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
> Frontend/FrontendAction.cpp?rev=304346=304345=304346=diff
> 
> ==
> --- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
> +++ cfe/trunk/lib/Frontend/FrontendAction.cpp Wed May 31 15:56:55 2017
> @@ -373,10 +373,11 @@ collectModuleHeaderIncludes(const LangOp
>return std::error_code();
>  }
>
> -static bool
> -loadModuleMapForModuleBuild(CompilerInstance , StringRef Filename,
> -bool IsSystem, bool IsPreprocessed,
> -unsigned ) {
> +static bool loadModuleMapForModuleBuild(CompilerInstance ,
> +StringRef Filename, bool IsSystem,
> +bool IsPreprocessed,
> +std::string
> ,
> +unsigned ) {
>auto  = CI.getSourceManager();
>HeaderSearch  = CI.getPreprocessor().getHeaderSearchInfo();
>
> @@ -388,16 +389,15 @@ loadModuleMapForModuleBuild(CompilerInst
>// line directives are not part of the module map syntax in general.
>Offset = 0;
>if (IsPreprocessed) {
> -std::string PresumedModuleMapFile;
>  SourceLocation EndOfLineMarker =
>  ReadOriginalFileName(CI, 

[PATCH] D33765: Show correct column nr. when multi-byte utf8 chars are used.

2017-06-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Correctly counting columns is a bit more complicated that that... for example, 
consider what happens if you replace `ideëen` with `idez̈en`.  See 
https://stackoverflow.com/questions/3634627/how-to-know-the-preferred-display-width-in-columns-of-unicode-characters
 .


https://reviews.llvm.org/D33765



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


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-01 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In https://reviews.llvm.org/D33735#770333, @rjmccall wrote:

> In https://reviews.llvm.org/D33735#770318, @aaron.ballman wrote:
>
> > In https://reviews.llvm.org/D33735#770296, @ABataev wrote:
> >
> > > In https://reviews.llvm.org/D33735#770288, @aaron.ballman wrote:
> > >
> > > > Can you help me to understand what problem is being solved with this 
> > > > new attribute? Under what circumstances would the first argument be an 
> > > > `ImplicitParamDecl` but not an implicit this or self?
> > >
> > >
> > > For captured regions an outlined function is created, where all 
> > > parameters are ImplicitParamDecls. And the very first parameter is 
> > > wrongly treated as 'this' argument of the member function.
> >
> >
> > Ah, thank you! That makes sense to me, but it begs the question: why an 
> > attribute rather than a bit on ImplicitParamDecl?
>
>
> I agree: it would make more sense for ImplicitParamDecl to store a Kind that 
> would always be provided at construction.


Ok, will add a field to ImplicitParamDecl, thanks


https://reviews.llvm.org/D33735



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


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D33735#770318, @aaron.ballman wrote:

> In https://reviews.llvm.org/D33735#770296, @ABataev wrote:
>
> > In https://reviews.llvm.org/D33735#770288, @aaron.ballman wrote:
> >
> > > Can you help me to understand what problem is being solved with this new 
> > > attribute? Under what circumstances would the first argument be an 
> > > `ImplicitParamDecl` but not an implicit this or self?
> >
> >
> > For captured regions an outlined function is created, where all parameters 
> > are ImplicitParamDecls. And the very first parameter is wrongly treated as 
> > 'this' argument of the member function.
>
>
> Ah, thank you! That makes sense to me, but it begs the question: why an 
> attribute rather than a bit on ImplicitParamDecl?


I agree: it would make more sense for ImplicitParamDecl to store a Kind that 
would always be provided at construction.


https://reviews.llvm.org/D33735



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


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D33735#770296, @ABataev wrote:

> In https://reviews.llvm.org/D33735#770288, @aaron.ballman wrote:
>
> > Can you help me to understand what problem is being solved with this new 
> > attribute? Under what circumstances would the first argument be an 
> > `ImplicitParamDecl` but not an implicit this or self?
>
>
> For captured regions an outlined function is created, where all parameters 
> are ImplicitParamDecls. And the very first parameter is wrongly treated as 
> 'this' argument of the member function.


Ah, thank you! That makes sense to me, but it begs the question: why an 
attribute rather than a bit on ImplicitParamDecl?


https://reviews.llvm.org/D33735



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


[PATCH] D33774: [CodeGen] Make __attribute__(const) calls speculatable

2017-06-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Consider something like this:

  define i32 @div(i32 %x, i32 %y) {
  entry:
%div = sdiv i32 %x, %y
ret i32 %div
  }

We can mark this function readnone, but not speculatable: it doesn't read or 
write memory, but could exhibit undefined behavior.

Consider another function:

  @x = common local_unnamed_addr global i32 0, align 4
  define i32 @get_x() {
  entry:
%0 = load i32, i32* @x, align 4, !tbaa !2
ret i32 %0
  }

We can mark this function speculatable, but not readnone: it doesn't exhibit 
undefined behavior or have side-effects, but it does read memory.

Given that, it seems a little dubious to translate `__attribute__((const))` 
into `speculatable`.


https://reviews.llvm.org/D33774



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


[PATCH] D33788: Return a canonical path from getClangResourcePath()

2017-06-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.

on POSIX systems, CIndexer::getClangResourcesPath() uses dladdr() to get the 
path of the shared object. It seems that on some systems (in our case, OS X 
10.6.8), dladdr() does not return a canonicalized path. We're getting a path 
like PATH/TO/CLANG/build/bin/../lib/clang/4.0.0. This resource directory path 
is then used to calculate a hash used by CompilerInvocation::getModuleHash(). 
This, in turn, is causing Index/pch-from-libclang.c to fail for us because the 
module cache paths have different names -- the first path is calculated with 
PATH/TO/CLANG/build/lib/clang/4.0.0 and the second path uses 
PATH/TO/CLANG/build/bin/../lib/clang/4.0.0.

Fix this bug by returning a canonicalized path.


https://reviews.llvm.org/D33788

Files:
  tools/libclang/CIndexer.cpp


Index: tools/libclang/CIndexer.cpp
===
--- tools/libclang/CIndexer.cpp
+++ tools/libclang/CIndexer.cpp
@@ -73,6 +73,11 @@
   llvm::sys::path::append(LibClangPath, "clang", CLANG_VERSION_STRING);
 
   // Cache our result.
-  ResourcesPath = LibClangPath.str();
+  SmallString<260> RealPath;
+  if (!llvm::sys::fs::real_path(LibClangPath, RealPath, 
/*expand_tilde=*/false))
+ResourcesPath = RealPath.str();
+  else
+ResourcesPath = LibClangPath.str();
+
   return ResourcesPath;
 }


Index: tools/libclang/CIndexer.cpp
===
--- tools/libclang/CIndexer.cpp
+++ tools/libclang/CIndexer.cpp
@@ -73,6 +73,11 @@
   llvm::sys::path::append(LibClangPath, "clang", CLANG_VERSION_STRING);
 
   // Cache our result.
-  ResourcesPath = LibClangPath.str();
+  SmallString<260> RealPath;
+  if (!llvm::sys::fs::real_path(LibClangPath, RealPath, /*expand_tilde=*/false))
+ResourcesPath = RealPath.str();
+  else
+ResourcesPath = LibClangPath.str();
+
   return ResourcesPath;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33588: Fix two sources of UB in __next_hash_pow2 (from __hash_table)

2017-06-01 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: include/__hash_table:139
 {
-return size_t(1) << (std::numeric_limits::digits - __clz(__n-1));
+return (__n > 1) ? (size_t(1) << (std::numeric_limits::digits - 
__clz(__n-1))) : __n;
 }

EricWF wrote:
> Shouldn't this return  `__n + 1` when `__n <= 1`, or even 2 in both cases?
I thought "next_hash_pow2(n)" meant "a hash based on n or the first 
power-of-two GTE n", but I suppose it's actually "first power-of-two GTE than 
n, for hash tables". In this case, returning `1` when `__n <= 1` makes the most 
sense to me, since it's the first power of two GTE 0 and 1. What do you think?


https://reviews.llvm.org/D33588



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


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-01 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In https://reviews.llvm.org/D33735#770288, @aaron.ballman wrote:

> Can you help me to understand what problem is being solved with this new 
> attribute? Under what circumstances would the first argument be an 
> `ImplicitParamDecl` but not an implicit this or self?


For captured regions an outlined function is created, where all parameters are 
ImplicitParamDecls. And the very first parameter is wrongly treated as 'this' 
argument of the member function.


https://reviews.llvm.org/D33735



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


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Can you help me to understand what problem is being solved with this new 
attribute? Under what circumstances would the first argument be an 
`ImplicitParamDecl` but not an implicit this or self?


https://reviews.llvm.org/D33735



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


[PATCH] D31830: Emit invariant.group.barrier when using union field

2017-06-01 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.

Thanks, LGTM.


https://reviews.llvm.org/D31830



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


[PATCH] D33537: [clang-tidy] Exception Escape Checker

2017-06-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D33537#765445, @baloghadamsoftware wrote:

> In https://reviews.llvm.org/D33537#764834, @Prazek wrote:
>
> > How is that compared to https://reviews.llvm.org/D19201 and the clang patch 
> > mentioned in this patch?
>
>
> Actually, this check does much more. It does not only check for noexcept (and 
> throw()) functions, but also for destructors, move constructors, move 
> assignments, the main() function, swap() functions and also functions given 
> as option. A more important difference is that we traverse the whole 
> call-chain and check all the throw statements and try-catch blocks so 
> indirectly throwing functions are also reported and no flase positives are 
> caused by throw and catch in the same try block.


I think we should try to get as much of this functionality in 
https://reviews.llvm.org/D3 as possible; there is a considerable amount of 
overlap between that functionality and this functionality. This check can then 
cover only the parts that are not reasonably handled by the frontend check 
instead of duplicating diagnostics the user already receives.


https://reviews.llvm.org/D33537



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


[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D3#768332, @jyu2 wrote:

> Okay this CFG version of this change.  In this change I am basic using same 
> algorithm with -Winfinite-recursion.
>
> In addition to my original implementation,  I add handler type checking which 
> basic using  https://reviews.llvm.org/D19201 method.


Thank you, I think this is a step in the right direction!

> There are couple things I am worry about this implementation:
>  1> compile time...

Do you have any timing data on whether this has a negative performance impact?

> 2> Correctness...

Your implementation looks reasonable to me, but with further review (and good 
tests), we should have a better grasp on correctness.

> 3> Stack overflow for large CFG...

I would be surprised if that were a problem, but is something we could address 
if it ever arises.




Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6341
+: Warning<"%0 has a non-throwing exception specification but can still "
+  "throw, may result in unexpected program termination.">, 
+  InGroup;

throw, may -> throw, which may

Also, remove the period at the end of the diagnostic.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6344
+def note_throw_in_dtor 
+: Note<"destructor or deallocator has a (possible implicit) non-throwing "
+  "excepton specification">;

possible -> possibly



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6347
+def note_throw_in_function 
+: Note<"nonthrowing function declare here">;
 def err_seh_try_outside_functions : Error<

nonthrowing -> non-throwing

(to be consistent with other diagnostics.)



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:290
+
+static bool mayThrowBeCaughted(const CXXThrowExpr *Throw,
+   const CXXCatchStmt *Catch) {

Caughted -> Caught



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:292
+   const CXXCatchStmt *Catch) {
+  bool MayCaught = false;
+  const auto *ThrowType = Throw->getSubExpr()->getType().getTypePtrOrNull();

MayCaught -> IsCaught ?



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:293-294
+  bool MayCaught = false;
+  const auto *ThrowType = Throw->getSubExpr()->getType().getTypePtrOrNull();
+  const auto *CaughtType = Catch->getCaughtType().getTypePtrOrNull();
+

Please don't use `auto` unless the type is explicitly spelled out in the 
initializer (here and elsewhere).



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:298
+return true;
+  if (CaughtType == ThrowType)
+return true;

You can combine this with the above check.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:304
+  if (CaughtAsRecordType && ThrowTypeAsRecordType) {
+if (CaughtAsRecordType == ThrowTypeAsRecordType)
+  MayCaught = true;

This does not seem quite correct. Consider:
```
struct S{};

void f() {
  try {
throw S{};
  } catch (const S *s) {
  }
}
```



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:311
+
+static bool mayThrowBeCaughtedByHandlers(const CXXThrowExpr *CE,
+ const CXXTryStmt *TryStmt) {

mayThrowBeCaughtedByHandlers -> isThrowCaughtByAHandler



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:314
+  bool Caught = false;
+  for (unsigned h = 0; h < TryStmt->getNumHandlers(); ++h) {
+const CXXCatchStmt *CS = TryStmt->getHandler(h);

h -> H (or Idx, or anything else that meets the coding standard).



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:317-318
+if (mayThrowBeCaughted(CE, CS)) {
+  Caught = true;
+  break;
+}

Just return true here instead of setting a local variable. Return false below.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:324
+
+static bool hasThrowOutNothrowingFuncInPath(CFGBlock ,
+SourceLocation *OpLoc) {

Perhaps it's more clear as: `doesThrowEscapePath()`?



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:330
+  continue;
+const CXXThrowExpr *CE =
+dyn_cast(B.getAs()->getStmt());

Can use `const auto *` here.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:334
+  continue;
+else
+  HasThrowOutFunc = true;

You can drop the `else` here and just set `HasThrowOutFunc` to true.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:337
+
+(*OpLoc) = CE->getThrowLoc();
+for (CFGBlock::const_succ_iterator I = Block.succ_begin(),

If OpLoc cannot be null, you should take it by reference. If it can be null, 
then you should guard against that 

[PATCH] D33739: [Sema] Improve -Wstrict-prototypes diagnostic message for blocks

2017-06-01 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D33739



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


[PATCH] D33108: Generate extra .ll files before/after optimization when using -save-temps.

2017-06-01 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Driver/Driver.cpp:2603-2614
+  // lipo-able.
+  if (!MultiArchUniversalBuild) {
+if (isSaveTempsEnabled() && Phase == phases::Compile) {
+  Actions.push_back(
+  C.MakeAction(Current, types::TY_LLVM_IR));
+}
+if (isSaveTempsEnabled() && Phase == phases::Backend) {

Can this be moved below addHostDependenceToDeviceActions() on line 2626?
See my comment in cuda-options.cu below for the reasons why it may be necessary.



Comment at: test/Driver/cuda-options.cu:197-202
-// Match host-side preprocessor job with -save-temps.
-// HOST-SAVE: "-cc1" "-triple" "x86_64--linux-gnu"
-// HOST-SAVE-SAME: "-aux-triple" "nvptx64-nvidia-cuda"
-// HOST-SAVE-NOT: "-fcuda-is-device"
-// HOST-SAVE-SAME: "-x" "cuda"
-

It appears that the new actions you've pushed trigger at least parts of 
host-side compilation to happen before device-side compilation is done. That, 
at the very least, will not work well for CUDA. Compilation will probably 
succeed, but it will be missing device-side code and will fail at runtime.

If it's only host-side preprocessor that happens ahead of device-side actions, 
then may be OK, but in general host actions must be done after device's. 


https://reviews.llvm.org/D33108



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


[libunwind] r304432 - Creating release candidate rc2 from release_401 branch

2017-06-01 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Jun  1 11:30:02 2017
New Revision: 304432

URL: http://llvm.org/viewvc/llvm-project?rev=304432=rev
Log:
Creating release candidate rc2 from release_401 branch

Added:
libunwind/tags/RELEASE_401/rc2/   (props changed)
  - copied from r304431, libunwind/branches/release_40/

Propchange: libunwind/tags/RELEASE_401/rc2/
--
svn:mergeinfo = /libunwind/trunk:292723,296358-296359


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


[libcxxabi] r304426 - Creating release candidate rc2 from release_401 branch

2017-06-01 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Jun  1 11:29:45 2017
New Revision: 304426

URL: http://llvm.org/viewvc/llvm-project?rev=304426=rev
Log:
Creating release candidate rc2 from release_401 branch

Added:
libcxxabi/tags/RELEASE_401/rc2/   (props changed)
  - copied from r304425, libcxxabi/branches/release_40/

Propchange: libcxxabi/tags/RELEASE_401/rc2/
--
svn:mergeinfo = /libcxxabi/trunk:292135,292418,292638


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


[libcxx] r304425 - Creating release candidate rc2 from release_401 branch

2017-06-01 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Jun  1 11:29:42 2017
New Revision: 304425

URL: http://llvm.org/viewvc/llvm-project?rev=304425=rev
Log:
Creating release candidate rc2 from release_401 branch

Added:
libcxx/tags/RELEASE_401/rc2/   (props changed)
  - copied from r304424, libcxx/branches/release_40/

Propchange: libcxx/tags/RELEASE_401/rc2/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Jun  1 11:29:42 2017
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:292013,292091,292607,292990,293154,293197,293581,294133,294142,294431


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


[PATCH] D33597: [OpenCL] Fix pipe size in TypeInfo.

2017-06-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D33597#770137, @Anastasia wrote:

> Use global AS pointer for pipe size.
>
> @Sam, I am moving you to the reviewer to finish this change. Do you think it 
> makes sense to add RUN line with some AMD GPU in triple to the test?


I would appreciate that if you can add one RUN line for triple 
amdgcn-amd-amdhsa-amdgizcl. Thanks.


https://reviews.llvm.org/D33597



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


[PATCH] D33597: [OpenCL] Fix pipe size in TypeInfo.

2017-06-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 101031.
Anastasia edited reviewers, added: yaxunl; removed: echuraev.
Anastasia removed a subscriber: yaxunl.
Anastasia added a comment.

Use global AS pointer for pipe size.

@Sam, I am moving you to the reviewer to finish this change. Do you think it 
makes sense to add RUN line with some AMD GPU in triple to the test?


https://reviews.llvm.org/D33597

Files:
  lib/AST/ASTContext.cpp
  test/Index/pipe-size.cl


Index: test/Index/pipe-size.cl
===
--- /dev/null
+++ test/Index/pipe-size.cl
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
x86_64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
spir-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
spir64-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR64
+__kernel void testPipe( pipe int test )
+{
+int s = sizeof(test);
+// X86: store %opencl.pipe_t* %test, %opencl.pipe_t** %test.addr, align 8
+// X86: store i32 8, i32* %s, align 4
+// SPIR: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t 
addrspace(1)** %test.addr, align 4
+// SPIR: store i32 4, i32* %s, align 4
+// SPIR64: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t 
addrspace(1)** %test.addr, align 8
+// SPIR64: store i32 8, i32* %s, align 4
+}
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1939,9 +1939,8 @@
   break;
 
   case Type::Pipe: {
-TypeInfo Info = getTypeInfo(cast(T)->getElementType());
-Width = Info.Width;
-Align = Info.Align;
+Width = 
Target->getPointerWidth(getTargetAddressSpace(LangAS::opencl_global));
+Align = 
Target->getPointerAlign(getTargetAddressSpace(LangAS::opencl_global));
   }
 
   }


Index: test/Index/pipe-size.cl
===
--- /dev/null
+++ test/Index/pipe-size.cl
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple x86_64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple spir-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple spir64-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR64
+__kernel void testPipe( pipe int test )
+{
+int s = sizeof(test);
+// X86: store %opencl.pipe_t* %test, %opencl.pipe_t** %test.addr, align 8
+// X86: store i32 8, i32* %s, align 4
+// SPIR: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 4
+// SPIR: store i32 4, i32* %s, align 4
+// SPIR64: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 8
+// SPIR64: store i32 8, i32* %s, align 4
+}
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1939,9 +1939,8 @@
   break;
 
   case Type::Pipe: {
-TypeInfo Info = getTypeInfo(cast(T)->getElementType());
-Width = Info.Width;
-Align = Info.Align;
+Width = Target->getPointerWidth(getTargetAddressSpace(LangAS::opencl_global));
+Align = Target->getPointerAlign(getTargetAddressSpace(LangAS::opencl_global));
   }
 
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >