Re: [PATCH] D16310: new clang-tidy checker misc-long-cast

2016-01-28 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki updated this revision to Diff 46235.
danielmarjamaki added a comment.

Refactoring the AST matching


http://reviews.llvm.org/D16310

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/MisplacedWideningCastCheck.cpp
  clang-tidy/misc/MisplacedWideningCastCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
  test/clang-tidy/misc-misplaced-widening-cast.cpp

Index: test/clang-tidy/misc-misplaced-widening-cast.cpp
===
--- test/clang-tidy/misc-misplaced-widening-cast.cpp
+++ test/clang-tidy/misc-misplaced-widening-cast.cpp
@@ -0,0 +1,64 @@
+// RUN: %check_clang_tidy %s misc-misplaced-widening-cast %t
+
+void assign(int a, int b) {
+  long l;
+
+  l = a * b;
+  l = (long)(a * b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion [misc-misplaced-widening-cast]
+  l = (long)a * b;
+
+  l = (long)(a << 8);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long'
+  l = (long)b << 8;
+
+  l = static_cast(a * b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion [misc-misplaced-widening-cast]
+}
+
+void init(unsigned int n) {
+  long l = (long)(n << 8);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: either cast from 'unsigned int'
+}
+
+long ret(int a) {
+  return (long)(a * 1000);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: either cast from 'int' to 'long'
+}
+
+void dontwarn1(unsigned char a, int i, unsigned char *p) {
+  long l;
+  // the result is a 9 bit value, there is no truncation in the implicit cast
+  l = (long)(a + 15);
+  // the result is a 12 bit value, there is no truncation in the implicit cast
+  l = (long)(a << 4);
+  // the result is a 3 bit value, there is no truncation in the implicit cast
+  l = (long)((i%5)+1);
+  // the result is a 16 bit value, there is no truncation in the implicit cast
+  l = (long)(((*p)<<8) + *(p+1));
+}
+
+template  struct DontWarn2 {
+  void assign(T a, T b) {
+long l;
+l = (long)(a * b);
+  }
+};
+DontWarn2 DW2;
+
+// Cast is not suspicious when casting macro
+#define A  (X<<2)
+long macro1(int X) {
+  return (long)A;
+}
+
+// Don't warn about cast in macro
+#define B(X,Y)   (long)(X*Y)
+long macro2(int x, int y) {
+  return B(x,y);
+}
+
+void floatingpoint(float a, float b) {
+  double d = (double)(a * b); // currently we don't warn for this
+}
+
Index: docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
===
--- docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
+++ docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
@@ -0,0 +1,39 @@
+.. title:: clang-tidy - misc-misplaced-widening-cast
+
+misc-misplaced-widening-cast
+==
+
+This check will warn when there is a explicit redundant cast of a calculation
+result to a bigger type. If the intention of the cast is to avoid loss of
+precision then the cast is misplaced, and there can be loss of precision.
+Otherwise the cast is ineffective.
+
+Example code::
+
+long f(int x) {
+return (long)(x*1000);
+}
+
+The result x*1000 is first calculated using int precision. If the result
+exceeds int precision there is loss of precision. Then the result is casted to
+long.
+
+If there is no loss of precision then the cast can be removed or you can
+explicitly cast to int instead.
+
+If you want to avoid loss of precision then put the cast in a proper location,
+for instance::
+
+long f(int x) {
+return (long)x * 1000;
+}
+
+Floating point
+--
+
+Currently warnings are only written for integer conversion. No warning is
+written for this code::
+
+double f(float x) {
+return (double)(x * 10.0f);
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -51,6 +51,7 @@
misc-inefficient-algorithm
misc-macro-parentheses
misc-macro-repeated-side-effects
+   misc-misplaced-widening-cast
misc-move-constructor-init
misc-new-delete-overloads
misc-noexcept-move-constructor
Index: clang-tidy/misc/MisplacedWideningCastCheck.h
===
--- clang-tidy/misc/MisplacedWideningCastCheck.h
+++ clang-tidy/misc/MisplacedWideningCastCheck.h
@@ -0,0 +1,33 @@
+//===--- MisplacedWideningCastCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===-

Re: [PATCH] D16310: new clang-tidy checker misc-long-cast

2016-01-28 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a comment.

In http://reviews.llvm.org/D16310#337563, @LegalizeAdulthood wrote:

> In http://reviews.llvm.org/D16310#335844, @danielmarjamaki wrote:
>
> > There were some new interesting warnings and imho they were TP.
>
>
> TP?


Sorry.. True Positive



Comment at: clang-tidy/misc/MisplacedWideningCastCheck.cpp:32
@@ +31,3 @@
+  auto CXXReinterpretCastB = 
cxxReinterpretCastExpr(has(BinaryOp)).bind("cast");
+  auto CXXReinterpretCastU = cxxReinterpretCastExpr(has(UnaryOp)).bind("cast");
+

I would like to use a anyOf(cStyleCastExpr(..), cxxStaticCastExpr(..), ..) ... 
would that be possible somehow?

I would also like to use anyOf(binaryOperator(..), unaryOperator(..)) is that 
possible?


http://reviews.llvm.org/D16310



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


Re: [PATCH] D16310: new clang-tidy checker misc-long-cast

2016-01-28 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki marked an inline comment as done.


Comment at: clang-tidy/misc/MisplacedWideningCastCheck.cpp:33
@@ +32,3 @@
+  Finder->addMatcher(varDecl(has(Cast)), this);
+  Finder->addMatcher(binaryOperator(hasOperatorName("="), hasRHS(Cast)), this);
+}

I have refactored these expressions in latest patch. I did not know I have to 
use stmt().


http://reviews.llvm.org/D16310



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


Re: [PATCH] D16607: Implementation of PS4 ABI, round 1

2016-01-28 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

LGTM


http://reviews.llvm.org/D16607



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


r259030 - Small refactor in isBeforeInTranslationUnit.

2016-01-28 Thread Yury Gribov via cfe-commits
Author: ygribov
Date: Thu Jan 28 03:27:46 2016
New Revision: 259030

URL: http://llvm.org/viewvc/llvm-project?rev=259030&view=rev
Log:
Small refactor in isBeforeInTranslationUnit.

Differential Revision: http://reviews.llvm.org/D15804

Modified:
cfe/trunk/lib/Basic/SourceManager.cpp

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=259030&r1=259029&r2=259030&view=diff
==
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Thu Jan 28 03:27:46 2016
@@ -2089,10 +2089,10 @@ bool SourceManager::isBeforeInTranslatio
 
   // Clear the lookup cache, it depends on a common location.
   IsBeforeInTUCache.clear();
-  llvm::MemoryBuffer *LBuf = getBuffer(LOffs.first);
-  llvm::MemoryBuffer *RBuf = getBuffer(ROffs.first);
-  bool LIsBuiltins = strcmp("", LBuf->getBufferIdentifier()) == 0;
-  bool RIsBuiltins = strcmp("", RBuf->getBufferIdentifier()) == 0;
+  const char *LB = getBuffer(LOffs.first)->getBufferIdentifier();
+  const char *RB = getBuffer(ROffs.first)->getBufferIdentifier();
+  bool LIsBuiltins = strcmp("", LB) == 0;
+  bool RIsBuiltins = strcmp("", RB) == 0;
   // Sort built-in before non-built-in.
   if (LIsBuiltins || RIsBuiltins) {
 if (LIsBuiltins != RIsBuiltins)
@@ -2101,8 +2101,8 @@ bool SourceManager::isBeforeInTranslatio
 // lower IDs come first.
 return LOffs.first < ROffs.first;
   }
-  bool LIsAsm = strcmp("", LBuf->getBufferIdentifier()) == 0;
-  bool RIsAsm = strcmp("", RBuf->getBufferIdentifier()) == 0;
+  bool LIsAsm = strcmp("", LB) == 0;
+  bool RIsAsm = strcmp("", RB) == 0;
   // Sort assembler after built-ins, but before the rest.
   if (LIsAsm || RIsAsm) {
 if (LIsAsm != RIsAsm)


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


r259031 - Fix isBeforeInTranslationUnit to not abort on macros defined in cmdline.

2016-01-28 Thread Yury Gribov via cfe-commits
Author: ygribov
Date: Thu Jan 28 03:28:18 2016
New Revision: 259031

URL: http://llvm.org/viewvc/llvm-project?rev=259031&view=rev
Log:
Fix isBeforeInTranslationUnit to not abort on macros defined in cmdline.

Differential Revision: http://reviews.llvm.org/D15804

Modified:
cfe/trunk/lib/Basic/SourceManager.cpp

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=259031&r1=259030&r2=259031&view=diff
==
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Thu Jan 28 03:28:18 2016
@@ -2110,6 +2110,14 @@ bool SourceManager::isBeforeInTranslatio
 assert(LOffs.first == ROffs.first);
 return false;
   }
+  bool LIsScratch = strcmp("", LB) == 0;
+  bool RIsScratch = strcmp("", RB) == 0;
+  // Sort scratch after inline asm, but before the rest.
+  if (LIsScratch || RIsScratch) {
+if (LIsScratch != RIsScratch)
+  return LIsScratch;
+return LOffs.second < ROffs.second;
+  }
   llvm_unreachable("Unsortable locations found");
 }
 


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


r259036 - Add backend dignostic printer for unsupported features

2016-01-28 Thread Oliver Stannard via cfe-commits
Author: olista01
Date: Thu Jan 28 04:07:34 2016
New Revision: 259036

URL: http://llvm.org/viewvc/llvm-project?rev=259036&view=rev
Log:
Add backend dignostic printer for unsupported features

Re-commit of r258950 after fixing layering violation.

Add backend dignostic printer for unsupported features

The related LLVM patch adds a backend diagnostic type for reporting
unsupported features, this adds a printer for them to clang.

In the case where debug location information is not available, I've
changed the printer to report the location as the first line of the
function, rather than the closing brace, as the latter does not give the
user any information. This also affects optimisation remarks.

Differential Revision: http://reviews.llvm.org/D16591


Added:
cfe/trunk/test/CodeGen/backend-unsupported-error.ll
Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/test/Frontend/optimization-remark-analysis.c
cfe/trunk/test/Misc/backend-optimization-failure-nodbg.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=259036&r1=259035&r2=259036&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Thu Jan 28 
04:07:34 2016
@@ -58,8 +58,10 @@ def remark_fe_backend_optimization_remar
 BackendInfo, InGroup;
 def warn_fe_backend_optimization_failure : Warning<"%0">, BackendInfo,
 InGroup, DefaultWarn;
-def note_fe_backend_optimization_remark_invalid_loc : Note<"could "
-  "not determine the original source location for %0:%1:%2">;
+def note_fe_backend_invalid_loc : Note<"could "
+  "not determine the original source location for %0:%1:%2">, BackendInfo;
+
+def err_fe_backend_unsupported : Error<"%0">, BackendInfo;
 
 def remark_sanitize_address_insert_extra_padding_accepted : Remark<
 "-fsanitize-address-field-padding applied to %0">, ShowInSystemHeader,

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=259036&r1=259035&r2=259036&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Thu Jan 28 04:07:34 2016
@@ -23,6 +23,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/CodeGen/DiagnosticInfoCodeGen.h"
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/DiagnosticPrinter.h"
@@ -242,6 +243,13 @@ namespace clang {
   ((BackendConsumer *)Context)->DiagnosticHandlerImpl(DI);
 }
 
+/// Get the best possible source location to represent a diagnostic that
+/// may have associated debug info.
+const FullSourceLoc
+getBestLocationFromDebugLoc(const llvm::DiagnosticInfoWithDebugLocBase &D,
+bool &BadDebugInfo, StringRef &Filename,
+unsigned &Line, unsigned &Column) const;
+
 void InlineAsmDiagHandler2(const llvm::SMDiagnostic &,
SourceLocation LocCookie);
 
@@ -254,6 +262,8 @@ namespace clang {
 /// \return True if the diagnostic has been successfully reported, false
 /// otherwise.
 bool StackSizeDiagHandler(const llvm::DiagnosticInfoStackSize &D);
+/// \brief Specialized handler for unsupported backend feature diagnostic.
+void UnsupportedDiagHandler(const llvm::DiagnosticInfoUnsupported &D);
 /// \brief Specialized handlers for optimization remarks.
 /// Note that these handlers only accept remarks and they always handle
 /// them.
@@ -439,16 +449,11 @@ BackendConsumer::StackSizeDiagHandler(co
   return false;
 }
 
-void BackendConsumer::EmitOptimizationMessage(
-const llvm::DiagnosticInfoOptimizationBase &D, unsigned DiagID) {
-  // We only support warnings and remarks.
-  assert(D.getSeverity() == llvm::DS_Remark ||
- D.getSeverity() == llvm::DS_Warning);
-
+const FullSourceLoc BackendConsumer::getBestLocationFromDebugLoc(
+const llvm::DiagnosticInfoWithDebugLocBase &D, bool &BadDebugInfo, 
StringRef &Filename,
+unsigned &Line, unsigned &Column) const {
   SourceManager &SourceMgr = Context->getSourceManager();
   FileManager &FileMgr = SourceMgr.getFileManager();
-  StringRef Filename;
-  unsigned Line, Column;
   SourceLocation DILoc;
 
   if (D.isLocationAvailable()) {
@@ -459,6 +464,7 @@ void BackendConsumer::EmitOptimizationMe
   // source manager, so pass 1 if Column is not set.
   DILoc = SourceMgr.translateFileLineCol(FE, Line, Column ? Column : 1);
 }
+BadDebugInfo = DILoc.isInvalid();
 

Re: [PATCH] D16591: Add backend dignostic printer for unsupported features

2016-01-28 Thread Oliver Stannard via cfe-commits
olista01 added a comment.

This was reverted last night, I've re-committed it as r259036 with the layering 
violation fixed.


Repository:
  rL LLVM

http://reviews.llvm.org/D16591



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


Re: [PATCH] D14653: [libcxx] Introduce the mechanism for fixing -fno-exceptions test failures.

2016-01-28 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: test/support/noexcept.h:23
@@ +22,3 @@
+// tests use multiple catch statements, in those cases we have to use the
+// _LIBCPP_NO_EXCEPTIONS macro and exclude the additional catch statements.
+#ifndef _LIBCPP_NO_EXCEPTIONS

mclow.lists wrote:
> I don't care for this; I think that "implementing a mechanism for throwing 
> exceptions in the test suite for when we've disabled exceptions" seems like 
> something that we'll have to revisit time and time again.
> 
> I wonder if it would be better to just split some tests into multiple tests 
> (some parts that test exception handling, some that don't), and then XFAIL: 
> no-exceptions the ones that test exception handling.
Not sure if I follow. This mechanism is not about throwing exceptions in the 
test suite; it is to check that the **library** calls 
__libcxx_noexceptions_abort() where it previously (with-exceptions) used to 
throw.

I don't see how splitting the tests would allow us to check that the library 
calls __libcxx_noexceptions_abort() as appropriate. We can XFAIL the tests that 
does exception handling, but then we won't be checking the library's behaviour 
in exceptional situations (i.e. how does it react to exceptional situations in 
the absence of exceptions?).

If we define that the no-exceptions library's behaviour in exceptional 
situations is *undefined*, then your suggestion makes sense, as then we don't 
have to worry about calling __libcxx_noexceptions_abort(). But this is not what 
we agreed upon in the dev list.

WDYT?


http://reviews.llvm.org/D14653



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


r259043 - Revert r259036, it introduces a cyclic library dependency

2016-01-28 Thread Oliver Stannard via cfe-commits
Author: olista01
Date: Thu Jan 28 07:09:49 2016
New Revision: 259043

URL: http://llvm.org/viewvc/llvm-project?rev=259043&view=rev
Log:
Revert r259036, it introduces a cyclic library dependency

Removed:
cfe/trunk/test/CodeGen/backend-unsupported-error.ll
Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/test/Frontend/optimization-remark-analysis.c
cfe/trunk/test/Misc/backend-optimization-failure-nodbg.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=259043&r1=259042&r2=259043&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Thu Jan 28 
07:09:49 2016
@@ -58,10 +58,8 @@ def remark_fe_backend_optimization_remar
 BackendInfo, InGroup;
 def warn_fe_backend_optimization_failure : Warning<"%0">, BackendInfo,
 InGroup, DefaultWarn;
-def note_fe_backend_invalid_loc : Note<"could "
-  "not determine the original source location for %0:%1:%2">, BackendInfo;
-
-def err_fe_backend_unsupported : Error<"%0">, BackendInfo;
+def note_fe_backend_optimization_remark_invalid_loc : Note<"could "
+  "not determine the original source location for %0:%1:%2">;
 
 def remark_sanitize_address_insert_extra_padding_accepted : Remark<
 "-fsanitize-address-field-padding applied to %0">, ShowInSystemHeader,

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=259043&r1=259042&r2=259043&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Thu Jan 28 07:09:49 2016
@@ -23,7 +23,6 @@
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Bitcode/ReaderWriter.h"
-#include "llvm/CodeGen/DiagnosticInfoCodeGen.h"
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/DiagnosticPrinter.h"
@@ -243,13 +242,6 @@ namespace clang {
   ((BackendConsumer *)Context)->DiagnosticHandlerImpl(DI);
 }
 
-/// Get the best possible source location to represent a diagnostic that
-/// may have associated debug info.
-const FullSourceLoc
-getBestLocationFromDebugLoc(const llvm::DiagnosticInfoWithDebugLocBase &D,
-bool &BadDebugInfo, StringRef &Filename,
-unsigned &Line, unsigned &Column) const;
-
 void InlineAsmDiagHandler2(const llvm::SMDiagnostic &,
SourceLocation LocCookie);
 
@@ -262,8 +254,6 @@ namespace clang {
 /// \return True if the diagnostic has been successfully reported, false
 /// otherwise.
 bool StackSizeDiagHandler(const llvm::DiagnosticInfoStackSize &D);
-/// \brief Specialized handler for unsupported backend feature diagnostic.
-void UnsupportedDiagHandler(const llvm::DiagnosticInfoUnsupported &D);
 /// \brief Specialized handlers for optimization remarks.
 /// Note that these handlers only accept remarks and they always handle
 /// them.
@@ -449,11 +439,16 @@ BackendConsumer::StackSizeDiagHandler(co
   return false;
 }
 
-const FullSourceLoc BackendConsumer::getBestLocationFromDebugLoc(
-const llvm::DiagnosticInfoWithDebugLocBase &D, bool &BadDebugInfo, 
StringRef &Filename,
-unsigned &Line, unsigned &Column) const {
+void BackendConsumer::EmitOptimizationMessage(
+const llvm::DiagnosticInfoOptimizationBase &D, unsigned DiagID) {
+  // We only support warnings and remarks.
+  assert(D.getSeverity() == llvm::DS_Remark ||
+ D.getSeverity() == llvm::DS_Warning);
+
   SourceManager &SourceMgr = Context->getSourceManager();
   FileManager &FileMgr = SourceMgr.getFileManager();
+  StringRef Filename;
+  unsigned Line, Column;
   SourceLocation DILoc;
 
   if (D.isLocationAvailable()) {
@@ -464,7 +459,6 @@ const FullSourceLoc BackendConsumer::get
   // source manager, so pass 1 if Column is not set.
   DILoc = SourceMgr.translateFileLineCol(FE, Line, Column ? Column : 1);
 }
-BadDebugInfo = DILoc.isInvalid();
   }
 
   // If a location isn't available, try to approximate it using the associated
@@ -473,63 +467,18 @@ const FullSourceLoc BackendConsumer::get
   FullSourceLoc Loc(DILoc, SourceMgr);
   if (Loc.isInvalid())
 if (const Decl *FD = Gen->GetDeclForMangledName(D.getFunction().getName()))
-  Loc = FD->getASTContext().getFullLoc(FD->getLocation());
-
-  if (DILoc.isInvalid() && D.isLocationAvailable())
-// If we were not able to translate the file:line:col information
-// back to a SourceLocation, at least emit a note stating that
-// we c

Re: [PATCH] D16351: [FIX] Bug 25404 - Crash on typedef in OpenCL 2.0

2016-01-28 Thread Igor Chesnokov via cfe-commits
ichesnokov updated this revision to Diff 46229.
ichesnokov marked 2 inline comments as done.

http://reviews.llvm.org/D16351

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaOpenCL/implicit-typedef.cl
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -314,14 +314,34 @@
   if (llvm::sys::Process::FixupStandardFileDescriptors())
 return 1;
 
-  SmallVector argv;
+  SmallVector _argv_;
   llvm::SpecificBumpPtrAllocator ArgAllocator;
   std::error_code EC = llvm::sys::Process::GetArgumentVector(
-  argv, llvm::makeArrayRef(argv_, argc_), ArgAllocator);
+_argv_, llvm::makeArrayRef(argv_, argc_), ArgAllocator);
   if (EC) {
 llvm::errs() << "error: couldn't get arguments: " << EC.message() << '\n';
 return 1;
   }
+
+#if defined(_WINDOWS) && defined(_DEBUG)
+  // Sometimes when debugging in MSVC2015 some parameter(s) may end with "\n".
+  // The code below code removes wrong symbol.
+  std::vector argvStorage;
+  SmallVector argv;
+  for (int I = 0, Count = _argv_.size(); I < Count; ++I) {
+  const char* P = _argv_[I];
+  size_t PLen = strlen(P);
+  if (PLen > 0 && P[PLen - 1] == '\n') {
+  std::string Reduced(P, 0, PLen - 1);
+  argvStorage.push_back(Reduced);
+  argv.push_back(argvStorage.back().c_str());
+  } else {
+  argv.push_back(P);
+  }
+  }
+#else
+  SmallVector& argv = _argv_;
+#endif
 
   llvm::InitializeAllTargets();
   std::string ProgName = argv[0];
Index: test/SemaOpenCL/implicit-typedef.cl
===
--- test/SemaOpenCL/implicit-typedef.cl
+++ test/SemaOpenCL/implicit-typedef.cl
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 "-cc1" "-emit-llvm" "-D" "cl_khr_fp64" "-D" 
"cl_khr_int64_base_atomics" "-fno-dwarf-directory-asm" "-fmessage-length" "205" 
"-fdiagnostics-show-option" "-cl-std=CL2.0" "-x" "cl" "%s" 
"-fcolor-diagnostics" -o -
+typedef atomic_int atomic_flag;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -2033,6 +2033,12 @@
   if (getLangOpts().Modules || getLangOpts().C11)
 return;
   
+  // Added isImplicit() check, because implicit TypeDecl::getLocation()
+  // returns 0. The're many implicit typedefs in OpenCL, e.g. atomic_flag.
+  if (Old->isImplicit() || New->isImplicit()) {
+return;
+  }
+
   // If we have a redefinition of a typedef in C, emit a warning.  This warning
   // is normally mapped to an error, but can be controlled with
   // -Wtypedef-redefinition.  If either the original or the redefinition is


Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -314,14 +314,34 @@
   if (llvm::sys::Process::FixupStandardFileDescriptors())
 return 1;
 
-  SmallVector argv;
+  SmallVector _argv_;
   llvm::SpecificBumpPtrAllocator ArgAllocator;
   std::error_code EC = llvm::sys::Process::GetArgumentVector(
-  argv, llvm::makeArrayRef(argv_, argc_), ArgAllocator);
+_argv_, llvm::makeArrayRef(argv_, argc_), ArgAllocator);
   if (EC) {
 llvm::errs() << "error: couldn't get arguments: " << EC.message() << '\n';
 return 1;
   }
+
+#if defined(_WINDOWS) && defined(_DEBUG)
+  // Sometimes when debugging in MSVC2015 some parameter(s) may end with "\n".
+  // The code below code removes wrong symbol.
+  std::vector argvStorage;
+  SmallVector argv;
+  for (int I = 0, Count = _argv_.size(); I < Count; ++I) {
+  const char* P = _argv_[I];
+  size_t PLen = strlen(P);
+  if (PLen > 0 && P[PLen - 1] == '\n') {
+  std::string Reduced(P, 0, PLen - 1);
+  argvStorage.push_back(Reduced);
+  argv.push_back(argvStorage.back().c_str());
+  } else {
+  argv.push_back(P);
+  }
+  }
+#else
+  SmallVector& argv = _argv_;
+#endif
 
   llvm::InitializeAllTargets();
   std::string ProgName = argv[0];
Index: test/SemaOpenCL/implicit-typedef.cl
===
--- test/SemaOpenCL/implicit-typedef.cl
+++ test/SemaOpenCL/implicit-typedef.cl
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 "-cc1" "-emit-llvm" "-D" "cl_khr_fp64" "-D" "cl_khr_int64_base_atomics" "-fno-dwarf-directory-asm" "-fmessage-length" "205" "-fdiagnostics-show-option" "-cl-std=CL2.0" "-x" "cl" "%s" "-fcolor-diagnostics" -o -
+typedef atomic_int atomic_flag;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -2033,6 +2033,12 @@
   if (getLangOpts().Modules || getLangOpts().C11)
 return;
   
+  // Added isImplicit() check, because implicit TypeDecl::getLocation()
+  // returns 0. The're many implicit typedefs in OpenCL, e.g. atomic_flag.
+  if (Old->isImplicit() || New->i

Re: [PATCH] D16538: [cc1as] Add MCTargetOptions argument to createAsmBackend

2016-01-28 Thread Joel Jones via cfe-commits
joelkevinjones added a comment.

Did you mean remove the duplication from addPassesToEmitFile mentioned in the 
FIXME or something else?


http://reviews.llvm.org/D16538



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


[libcxx] r259046 - [libcxx] Work around for clang calling GAS after having already failed.

2016-01-28 Thread Daniel Sanders via cfe-commits
Author: dsanders
Date: Thu Jan 28 07:49:33 2016
New Revision: 259046

URL: http://llvm.org/viewvc/llvm-project?rev=259046&view=rev
Log:
[libcxx] Work around for clang calling GAS after having already failed.

Summary:
This is a workaround to a clang bug which causes libcxx tests to fail in the 3.8
release. The clang bug is currently being investigated. It seems that clang
does not stop after frontend errors when using -verify and -fno-integrated-as
(or when this is the default). This patch adds -fsyntax-only to prevent GAS
from being called, fixing the libcxx failures.

PR26277

Patch by Eric Fiselier

Reviewers: mclow.lists, hans, EricWF

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D16584

Modified:
libcxx/trunk/test/libcxx/test/format.py

Modified: libcxx/trunk/test/libcxx/test/format.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/format.py?rev=259046&r1=259045&r2=259046&view=diff
==
--- libcxx/trunk/test/libcxx/test/format.py (original)
+++ libcxx/trunk/test/libcxx/test/format.py Thu Jan 28 07:49:33 2016
@@ -161,7 +161,7 @@ class LibcxxTestFormat(object):
'expected-error', 'expected-no-diagnostics']
 use_verify = self.use_verify_for_fail and \
  any([tag in contents for tag in verify_tags])
-extra_flags = []
+extra_flags = ['-fsyntax-only']
 if use_verify:
 extra_flags += ['-Xclang', '-verify',
 '-Xclang', '-verify-ignore-unexpected=note']


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


RE: [libcxx] r259046 - [libcxx] Work around for clang calling GAS after having already failed.

2016-01-28 Thread Daniel Sanders via cfe-commits
Hi Hans,

Is it ok to merge this into 3.8? Eric Fiselier has already approved on the 
review.

From: cfe-commits [cfe-commits-boun...@lists.llvm.org] on behalf of Daniel 
Sanders via cfe-commits [cfe-commits@lists.llvm.org]
Sent: 28 January 2016 13:49
To: cfe-commits@lists.llvm.org
Subject: [libcxx] r259046 - [libcxx] Work around for clang calling GAS after 
having already failed.

Author: dsanders
Date: Thu Jan 28 07:49:33 2016
New Revision: 259046

URL: http://llvm.org/viewvc/llvm-project?rev=259046&view=rev
Log:
[libcxx] Work around for clang calling GAS after having already failed.

Summary:
This is a workaround to a clang bug which causes libcxx tests to fail in the 3.8
release. The clang bug is currently being investigated. It seems that clang
does not stop after frontend errors when using -verify and -fno-integrated-as
(or when this is the default). This patch adds -fsyntax-only to prevent GAS
from being called, fixing the libcxx failures.

PR26277

Patch by Eric Fiselier

Reviewers: mclow.lists, hans, EricWF

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D16584

Modified:
libcxx/trunk/test/libcxx/test/format.py

Modified: libcxx/trunk/test/libcxx/test/format.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/format.py?rev=259046&r1=259045&r2=259046&view=diff
==
--- libcxx/trunk/test/libcxx/test/format.py (original)
+++ libcxx/trunk/test/libcxx/test/format.py Thu Jan 28 07:49:33 2016
@@ -161,7 +161,7 @@ class LibcxxTestFormat(object):
'expected-error', 'expected-no-diagnostics']
 use_verify = self.use_verify_for_fail and \
  any([tag in contents for tag in verify_tags])
-extra_flags = []
+extra_flags = ['-fsyntax-only']
 if use_verify:
 extra_flags += ['-Xclang', '-verify',
 '-Xclang', '-verify-ignore-unexpected=note']


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


Re: [PATCH] D15636: Reduce false positives in printf/scanf format checker

2016-01-28 Thread Andy Gibbs via cfe-commits
AndyG added a comment.

Yes, but only for the "data argument not used" warning.  All other warnings are 
unaffected by the change, for example:

  test.cpp:9:51: warning: format specifies type 'char *' but the argument has 
type 'int' [-Wformat]  
  printf(minimal ? "%s %s %i\n" : "%i %i %i\n", code, msg);
~~  ^~~~
%d
  test.cpp:9:30: warning: more '%' conversions than data arguments [-Wformat]
  printf(minimal ? "%s %s %i\n" : "%i %i %i\n", code, msg);
  ~^
  test.cpp:9:57: warning: format specifies type 'int' but the argument has type 
'const char *' [-Wformat]
  printf(minimal ? "%s %s %i\n" : "%i %i %i\n", code, msg);
  ~~  ^~~
  %s
  test.cpp:9:45: warning: more '%' conversions than data arguments [-Wformat]
  printf(minimal ? "%s %s %i\n" : "%i %i %i\n", code, msg);
 ~^
  4 warnings generated.

But, as you observed, for the unused argument it only warns for the first 
instance:

  test.cpp:9:53: warning: data argument not used by format string 
[-Wformat-extra-args]
  printf(minimal ? "%i\n" : "%i %s\n", code, msg, msg);
~ ^
  1 warning generated.

This is in comparison to the original diagnostic:

  test.cpp:9:48: warning: data argument not used by format string 
[-Wformat-extra-args]
  printf(minimal ? "%i\n" : "%i %s\n", code, msg, msg);
   ~~^
  test.cpp:9:53: warning: data argument not used by format string 
[-Wformat-extra-args]
  printf(minimal ? "%i\n" : "%i %s\n", code, msg, msg);
~ ^
  2 warnings generated.

However, may I ask what the specific concern is here?  If this diagnostic 
appears then the user knows that **all** the strings do not use this and any 
subsequent argument.  Effectively the original situation doesn't really tell 
the user anything more useful - it only duplicates the warning and actually, as 
can be seen above, it is potentially confusing since it suggests two positions 
for the unused argument(s).  Compare this with the new diagnostic which shows 
only one string, and this string is the first string which uses the most 
arguments, so it is very clear which arguments are not used.

What do you think?  Is this an adequate argument?


http://reviews.llvm.org/D15636



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


Re: [PATCH] D16586: Make clang AAPCS compliant w.r.t volatile bitfield accesses

2016-01-28 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 46264.
rmaprath added a comment.

Addressing review comments by @rjmccall:

Moved all the AAPCS specific tweaks to EmitLValueForField(), this simplified 
the patch a lot (now there is no mucking about a de-constructed GEP at 
load/store points). In order to do this, LValue definition had to be updated so 
that it gets initialized with is own copy of CGBitFieldInfo.

> A few high-level notes:

>  AAPCS requires the bit-field to be loaded on a store, even if the store 
> fills the entire container; that doesn't seem to be implemented in your patch.


Fixed.

> Especially because of #1, let's not do this unless the l-value is actually 
> volatile. The ABI rule here is arguably actively wrong for non-volatile 
> cases, e.g. struct { volatile char c; short s : 8; }.


The AAPCS also say (Section 7.1.7.5):

"If the container of a non-volatile bit-field overlaps a volatile bit-field 
then it is undefined whether access to the non volatile field will cause the 
volatile field to be accessed."

So it looks like doing this for normal fields is still within the bounds of 
AAPCS. In fact, armcc loads the volatile 'c' in your example when 's' is 
accessed. But I agree that limiting this to volatile cases is a good idea; we 
are still AAPCS compliant and there's less things to break.

> Instead of using string comparisons all over the place, please make this a 
> flag on the CG TargetInfo or something.


Factored this out into a small utility function.


http://reviews.llvm.org/D16586

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGValue.h
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/aapcs-bitfield.c

Index: test/CodeGen/aapcs-bitfield.c
===
--- /dev/null
+++ test/CodeGen/aapcs-bitfield.c
@@ -0,0 +1,353 @@
+// RUN: %clang_cc1 -triple armv8-none-linux-eabi %s -emit-llvm -o - -O3 \
+// RUN:   | FileCheck %s -check-prefix=LE -check-prefix=CHECK
+// RUN: %clang_cc1 -triple armebv8-none-linux-eabi %s -emit-llvm -o - -O3 \
+// RUN:   | FileCheck %s -check-prefix=BE -check-prefix=CHECK
+
+// CHECK: %struct.st1 = type { i8, i8 }
+// CHECK: %struct.st2 = type { i16, [2 x i8] }
+// CHECK: %struct.st3 = type { i16, i8 }
+// CHECK: %struct.st4 = type { i16, i8, i8 }
+// CHECK: %struct.st5b = type { i8, [3 x i8], %struct.st5a }
+// CHECK: %struct.st5a = type { i8, i8, [2 x i8] }
+// CHECK: %struct.st6 = type { i16, [2 x i8] }
+
+// A simple volatile bitfield, should be accessed through an i16*
+struct st1 {
+  // Expected masks (0s mark the bit-field):
+  // le: 0xff80 (-128)
+  // be: 0x01ff (511)
+  volatile short c : 7;
+};
+
+// CHECK-LABLE: st1_check_load
+int st1_check_load(struct st1 *m) {
+  // LE: %[[PTR1:.*]] = bitcast %struct.st1* %m to i16*
+  // LE-NEXT: %[[LD:.*]] = load volatile i16, i16* %[[PTR1]], align 2
+  // LE-NEXT: %[[CLR1:.*]] = shl i16 %[[LD]], 9
+  // LE-NEXT: %[[CLR2:.*]] = ashr exact i16 %[[CLR1]], 9
+  // LE-NEXT: %[[SEXT:.*]] = sext i16 %[[CLR2]] to i32
+  // LE-NEXT: ret i32 %[[SEXT]]
+
+  // BE: %[[PTR1:.*]] = bitcast %struct.st1* %m to i16*
+  // BE-NEXT: %[[LD:.*]] = load volatile i16, i16* %[[PTR1]], align 2
+  // BE-NEXT: %[[CLR:.*]] = ashr i16 %[[LD]], 9
+  // BE-NEXT: %[[SEXT:.*]] = sext i16 %[[CLR]] to i32
+  // BE-NEXT: ret i32 %[[SEXT]]
+  return m->c;
+}
+
+// CHECK-LABLE: st1_check_store
+void st1_check_store(struct st1 *m) {
+  // LE: %[[PTR1:.*]] = bitcast %struct.st1* %m to i16*
+  // LE-NEXT: %[[LD:.*]] = load volatile i16, i16* %[[PTR1]], align 2
+  // LE-NEXT: %[[CLR:.*]] = and i16 %[[LD]], -128
+  // LE-NEXT: %[[SET:.*]] = or i16 %[[CLR]], 1
+  // LE-NEXT: store volatile i16 %[[SET]], i16* %[[PTR1]], align 2
+
+  // BE: %[[PTR1:.*]] = bitcast %struct.st1* %m to i16*
+  // BE-NEXT: %[[LD:.*]] = load volatile i16, i16* %[[PTR1]], align 2
+  // BE-NEXT: %[[CLR:.*]] = and i16 %[[LD]], 511
+  // BE-NEXT: %[[SET:.*]] = or i16 %[[CLR]], 512
+  // BE-NEXT: store volatile i16 %[[SET]], i16* %[[PTR1]], align 2
+  m->c = 1;
+}
+
+// 'c' should land straight after 'b' and should be accessed through an i16*
+struct st2 {
+  int b : 10;
+  // Expected masks (0s mark the bit-field):
+  // le: 0x03ff (1023)
+  // be: 0xffc0 (-64)
+  volatile short c : 6;
+};
+
+// CHECK-LABLE: st2_check_load
+int st2_check_load(struct st2 *m) {
+  // LE: %[[PTR:.*]] = getelementptr inbounds %struct.st2, %struct.st2* %m, i32 0, i32 0
+  // LE-NEXT: %[[LD:.*]] = load volatile i16, i16* %[[PTR]], align 4
+  // LE-NEXT: %[[CLR:.*]] = ashr i16 %[[LD]], 10
+  // LE-NEXT: %[[SEXT:.*]] = sext i16 %[[CLR]] to i32
+  // LE-NEXT: ret i32 %[[SEXT]]
+
+  // BE: %[[PTR:.*]] = getelementptr inbounds %struct.st2, %struct.st2* %m, i32 0, i32 0
+  // BE-NEXT: %[[LD:.*]] = load volatile i16, i16* %[[PTR]], align 4
+  // BE-NEXT: %[[CLR1:.*]] = shl i16 %[[LD]], 10
+  // BE-NEXT: %[[CLR2:.*]] = ashr exact i16 %[[CLR1]], 10
+  // BE-NEXT: %[[SEXT:.*]] = sext i16 %[[CLR2]] to i32
+  // BE-NEXT: ret i32 %[[SEXT]]
+  return m->c;
+}
+
+/

Re: [PATCH] D16586: Make clang AAPCS compliant w.r.t volatile bitfield accesses

2016-01-28 Thread Asiri Rathnayake via cfe-commits
rmaprath marked 2 inline comments as done.
rmaprath added a comment.

http://reviews.llvm.org/D16586



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


Re: [PATCH] D16613: Use LLVM's CheckAtomic cmake module to figure out whether we need to link with libatomic.

2016-01-28 Thread Vasileios Kalintiris via cfe-commits
vkalintiris updated this revision to Diff 46272.
vkalintiris added a comment.

Don't use LLVM's CheckAtomic cmake module. Instead, use a libcxx-specific one
that allows checking for 64-bit atomics too.


http://reviews.llvm.org/D16613

Files:
  cmake/Modules/CheckLibcxxAtomic.cmake
  cmake/config-ix.cmake
  lib/CMakeLists.txt
  test/CMakeLists.txt
  test/libcxx/test/target_info.py
  test/lit.site.cfg.in

Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -20,6 +20,7 @@
 config.target_info  = "@LIBCXX_TARGET_INFO@"
 config.executor = "@LIBCXX_EXECUTOR@"
 config.llvm_unwinder= "@LIBCXXABI_USE_LLVM_UNWINDER@"
+config.use_libatomic= "@LIBCXX_HAS_ATOMIC_LIB@"
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")
Index: test/libcxx/test/target_info.py
===
--- test/libcxx/test/target_info.py
+++ test/libcxx/test/target_info.py
@@ -172,6 +172,9 @@
 flags += ['-lunwind', '-ldl']
 else:
 flags += ['-lgcc_s', '-lgcc']
+use_libatomic = self.full_config.get_lit_bool('use_libatomic', False)
+if use_libatomic:
+flags += ['-latomic']
 san = self.full_config.get_lit_conf('use_sanitizer', '').strip()
 if san:
 # The libraries and their order are taken from the
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -15,6 +15,7 @@
 pythonize_bool(LIBCXX_BUILD_32_BITS)
 pythonize_bool(LIBCXX_GENERATE_COVERAGE)
 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
+pythonize_bool(LIBCXX_HAS_ATOMIC_LIB)
 
 # The tests shouldn't link to any ABI library when it has been linked into
 # libc++ statically or via a linker script.
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -79,6 +79,7 @@
 add_library_flags_if(LIBCXX_HAS_M_LIB m)
 add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
 add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+add_library_flags_if(LIBCXX_HAS_ATOMIC_LIB atomic)
 
 # Setup flags.
 add_flags_if_supported(-fPIC)
Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -1,5 +1,6 @@
 include(CheckLibraryExists)
 include(CheckCXXCompilerFlag)
+include(CheckLibcxxAtomic)
 
 # Check compiler flags
 
@@ -17,3 +18,7 @@
 check_library_exists(m ccos "" LIBCXX_HAS_M_LIB)
 check_library_exists(rt clock_gettime "" LIBCXX_HAS_RT_LIB)
 check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)
+
+if (NOT HAVE_CXX_ATOMICS_WITHOUT_LIB)
+  set(LIBCXX_HAS_ATOMIC_LIB True)
+endif()
Index: cmake/Modules/CheckLibcxxAtomic.cmake
===
--- /dev/null
+++ cmake/Modules/CheckLibcxxAtomic.cmake
@@ -0,0 +1,36 @@
+INCLUDE(CheckCXXSourceCompiles)
+
+# Sometimes linking against libatomic is required for atomic ops, if
+# the platform doesn't support lock-free atomics.
+#
+# We could modify LLVM's CheckAtomic module and have it check for 64-bit
+# atomics instead. However, we would like to avoid careless uses of 64-bit
+# atomics inside LLVM over time on 32-bit platforms.
+
+function(check_cxx_atomics varname)
+  set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+  set(CMAKE_REQUIRED_FLAGS "-std=c++11")
+  check_cxx_source_compiles("
+#include 
+std::atomic x;
+int main() {
+  return x;
+}
+" ${varname})
+  set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
+endfunction(check_cxx_atomics)
+
+check_cxx_atomics(HAVE_CXX_ATOMICS_WITHOUT_LIB)
+# If not, check if the library exists, and atomics work with it.
+if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB)
+  check_library_exists(atomic __atomic_fetch_add_8 "" HAVE_LIBATOMIC)
+  if(HAVE_LIBATOMIC)
+list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
+check_cxx_atomics(HAVE_CXX_ATOMICS_WITH_LIB)
+if (NOT HAVE_CXX_ATOMICS_WITH_LIB)
+  message(FATAL_ERROR "Host compiler must support std::atomic!")
+endif()
+  else()
+message(FATAL_ERROR "Host compiler appears to require libatomic, but cannot find it.")
+  endif()
+endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r259031 - Fix isBeforeInTranslationUnit to not abort on macros defined in cmdline.

2016-01-28 Thread David Blaikie via cfe-commits
Test case?

On Thu, Jan 28, 2016 at 1:28 AM, Yury Gribov via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ygribov
> Date: Thu Jan 28 03:28:18 2016
> New Revision: 259031
>
> URL: http://llvm.org/viewvc/llvm-project?rev=259031&view=rev
> Log:
> Fix isBeforeInTranslationUnit to not abort on macros defined in cmdline.
>
> Differential Revision: http://reviews.llvm.org/D15804
>
> Modified:
> cfe/trunk/lib/Basic/SourceManager.cpp
>
> Modified: cfe/trunk/lib/Basic/SourceManager.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=259031&r1=259030&r2=259031&view=diff
>
> ==
> --- cfe/trunk/lib/Basic/SourceManager.cpp (original)
> +++ cfe/trunk/lib/Basic/SourceManager.cpp Thu Jan 28 03:28:18 2016
> @@ -2110,6 +2110,14 @@ bool SourceManager::isBeforeInTranslatio
>  assert(LOffs.first == ROffs.first);
>  return false;
>}
> +  bool LIsScratch = strcmp("", LB) == 0;
> +  bool RIsScratch = strcmp("", RB) == 0;
> +  // Sort scratch after inline asm, but before the rest.
> +  if (LIsScratch || RIsScratch) {
> +if (LIsScratch != RIsScratch)
> +  return LIsScratch;
> +return LOffs.second < ROffs.second;
> +  }
>llvm_unreachable("Unsortable locations found");
>  }
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15603: [OpenCL] Pipe type support

2016-01-28 Thread Ulrich Weigand via cfe-commits
uweigand added a subscriber: uweigand.
uweigand added a comment.

Now that our build bot is up and running again, I noticed that the newly added 
test pipe_types.cl fails on SystemZ:

  
/home3/uweigand/llvm/llvm-head/tools/clang/test/CodeGenOpenCL/pipe_types.cl:26:11:
 error: expected string not found in input
  // CHECK: define void @test5(%opencl.pipe_t* %p)  
  
^   
  
  :34:40: note: scanning from here   
  
  define void @test4(%opencl.pipe_t* %p) #0 {   
  
 ^  
  
  :42:1: note: possible intended match here  
  
  define void @test5(%opencl.pipe_t**) #0 { 
  
  ^ 
 

For some reason, test5 gets an extra indirection in the input argument:

  define void @test5(%opencl.pipe_t**) #0 {
  entry:
%p.addr = alloca %opencl.pipe_t*, align 16
%p = load %opencl.pipe_t*, %opencl.pipe_t** %0, align 16
store %opencl.pipe_t* %p, %opencl.pipe_t** %p.addr, align 16
ret void
  }

Are there supposed to be platform-specific differences in OpenCL types?


http://reviews.llvm.org/D15603



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


Re: [modules] PR24954

2016-01-28 Thread Vassil Vassilev via cfe-commits
Would this patch be more reasonable? It follows what 
RegisterTemplateSpecialization (introduced in r245779) does. AFAICT this 
adds an update record far less often.

--Vassil
On 12/12/15 16:13, Vassil Vassilev wrote:

I couldn't find GetDecl routine in the ASTWriter. Could you elaborate?

Assuming you meant ASTWriter::GetDeclRef(D): It seems that the 
conditions when calling GetDeclRef differ from the conditions of 
AddedCXXTemplateSpecialization. Eg:


ASTWriter::AddedCXXTemplateSpecialization {
  assert(!WritingAST && "Already writing the AST!");
  ...
}
ASTWriter::GetDeclRef {
  assert(WritingAST && "Cannot request a declaration ID before AST 
writing");

  ..
}

IIUC this particular instantiation happens *after* module B was built, 
thus it needs to be retrospectively added to the serialized namespace. 
It looks like even avoiding somehow the asserts of GetDeclRef it 
wouldn't help much.


Alternatively I could try to reduce the redundant update records by 
narrowing down to instantiations coming in the context of friends.


--Vassil

On 12/12/15 01:07, Richard Smith wrote:
Instead of adding an update record directly in this case (which will 
emit far more update records than necessary), how about just calling 
GetDecl(D) from AddedCXXTemplateSpecialization to ensure that it gets 
emitted?


On Fri, Dec 4, 2015 at 7:46 AM, Vassil Vassilev  wrote:

Hi,
  Could you review my fix please.
Many thanks,
Vassil

On 08/10/15 15:53, Vassil Vassilev wrote:

Hi Richard,
  I started working on
https://llvm.org/bugs/show_bug.cgi?id=24954

  IIUC r228485 introduces an abstraction to deal with
not-really-anonymous friend decls
(serialization::needsAnonymousDeclarationNumber in
ASTCommon.cpp).

  A comment explicitly says:
  "// This doesn't apply to friend tag decls; Sema makes
those available to name
   // lookup in the surrounding context."

  In the bug reproducer, the friend function (wrt __iom_t10)
is forward declared in the same namespace, where Sema makes
the friend available for a name lookup.

  It seems that the friend operator<< in __iom_t10 (sorry
about the names they come from libcxx) doesn't get registered
in the ASTWriter's DeclIDs but it gets registered in outer
namespace's lookup table. Thus, assert is triggered when
finalizing module A, since it rebuilds the lookups of the
updated contexts.

  The issue only appears when building module A
deserializes/uses module B.

  Currently I was assume that something wrong happens in
either needsAnonymousDeclarationNumber or I hit a predicted
issue ASTWriterDecl.cpp:1602
// FIXME: This is not correct; when we reach an imported
declaration we
// won't emit its previous declaration.
(void)Writer.GetDeclRef(D->getPreviousDecl());
(void)Writer.GetDeclRef(MostRecent);

  The issue seems a fairly complex one and I am a bit stuck.

  Any hints are very very welcome ;)
Many thanks,
Vassil









From 2c12f1539c36548f7558e67a91e702c9233c0007 Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Sun, 27 Sep 2015 21:12:39 +0200
Subject: [PATCH] Fix adding a templated friend functions to a namespace from
 another module.

This should be reproducible with chained PCHs too.

Fixes https://llvm.org/bugs/show_bug.cgi?id=24954
---
 include/clang/Serialization/ASTWriter.h  |  3 +++
 lib/Serialization/ASTWriter.cpp  | 20 +++
 test/Modules/Inputs/PR24954/A.h  | 10 ++
 test/Modules/Inputs/PR24954/B.h  | 30 
 test/Modules/Inputs/PR24954/module.modulemap |  9 +
 test/Modules/pr24954.cpp |  7 +++
 6 files changed, 79 insertions(+)
 create mode 100644 test/Modules/Inputs/PR24954/A.h
 create mode 100644 test/Modules/Inputs/PR24954/B.h
 create mode 100644 test/Modules/Inputs/PR24954/module.modulemap
 create mode 100644 test/Modules/pr24954.cpp

diff --git a/include/clang/Serialization/ASTWriter.h 
b/include/clang/Serialization/ASTWriter.h
index ed34547..0f2ce34 100644
--- a/include/clang/Serialization/ASTWriter.h
+++ b/include/clang/Serialization/ASTWriter.h
@@ -865,6 +865,9 @@ public:
   void CompletedTagDefinition(const TagDecl *D) override;
   void AddedVisibleDecl(const DeclContext *DC, const Decl *D) override;
   void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) override;
+  using ASTMutationListener::AddedCXXTemplateSpecialization;
+  void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD,
+  const FunctionDecl *D) override;
   void ResolvedExceptionSpec(const FunctionDecl *FD) override;
   void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType) override;
   void ResolvedOperatorDe

Re: [PATCH] D16613: Introduce a cmake module to figure out whether we need to link with libatomic.

2016-01-28 Thread Joerg Sonnenberger via cfe-commits
joerg added a comment.

Thanks for working on it. I think it might be slightly better to explicitly 
test uintmax_t and uintptr_t as well. They could be larger than long long int 
and there are tests depending on the existance.

Do we have any test cases for arbitrary sized trivally copyable structures? 
That might also be needed.


http://reviews.llvm.org/D16613



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


[libcxx] r259058 - Merging r258920:

2016-01-28 Thread Daniel Sanders via cfe-commits
Author: dsanders
Date: Thu Jan 28 10:51:36 2016
New Revision: 259058

URL: http://llvm.org/viewvc/llvm-project?rev=259058&view=rev
Log:
Merging r258920:

r258920 | dsanders | 2016-01-27 10:45:07 + (Wed, 27 Jan 2016) | 11 lines

[libcxx] Additional 'REQUIRE' directives for tests that require en_US.UTF-8.

Summary:
These are the tests that didn't fail in the release candidate because they were
covered by another 'REQUIRES' directive.

Reviewers: mclow.lists, hans, bcraig, EricWF

Subscribers: EricWF, dim, cfe-commits

Differential Revision: http://reviews.llvm.org/D16408


Modified:

libcxx/branches/release_38/test/std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp

libcxx/branches/release_38/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp

libcxx/branches/release_38/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp

libcxx/branches/release_38/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp

libcxx/branches/release_38/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp

libcxx/branches/release_38/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp

libcxx/branches/release_38/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp

Modified: 
libcxx/branches/release_38/test/std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_38/test/std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp?rev=259058&r1=259057&r2=259058&view=diff
==
--- 
libcxx/branches/release_38/test/std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp
 (original)
+++ 
libcxx/branches/release_38/test/std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp
 Thu Jan 28 10:51:36 2016
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// REQUIRES: locale.en_US.UTF-8
+
 // 
 
 // template  class collate_byname

Modified: 
libcxx/branches/release_38/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_38/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp?rev=259058&r1=259057&r2=259058&view=diff
==
--- 
libcxx/branches/release_38/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
 (original)
+++ 
libcxx/branches/release_38/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
 Thu Jan 28 10:51:36 2016
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// REQUIRES: locale.en_US.UTF-8
+
 // 
 
 // template  class ctype_byname;

Modified: 
libcxx/branches/release_38/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_38/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp?rev=259058&r1=259057&r2=259058&view=diff
==
--- 
libcxx/branches/release_38/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
 (original)
+++ 
libcxx/branches/release_38/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
 Thu Jan 28 10:51:36 2016
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// REQUIRES: locale.en_US.UTF-8
+
 // 
 
 // template  class ctype_byname;

Modified: 
libcxx/branches/release_38/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_38/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp?rev=259058&r1=259057&r2=259058&view=diff
==
--- 
libcxx/branches/release_38/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp
 (original)
+++ 
libcxx/branches/release_38/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp
 Thu Jan 28 

Re: [PATCH] D16613: Introduce a cmake module to figure out whether we need to link with libatomic.

2016-01-28 Thread Vasileios Kalintiris via cfe-commits
vkalintiris updated this revision to Diff 46286.
vkalintiris added a comment.

Check for atomcis on uintmax_t/uintptr_t instead of long long int.


http://reviews.llvm.org/D16613

Files:
  cmake/Modules/CheckLibcxxAtomic.cmake
  cmake/config-ix.cmake
  lib/CMakeLists.txt
  test/CMakeLists.txt
  test/libcxx/test/target_info.py
  test/lit.site.cfg.in

Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -20,6 +20,7 @@
 config.target_info  = "@LIBCXX_TARGET_INFO@"
 config.executor = "@LIBCXX_EXECUTOR@"
 config.llvm_unwinder= "@LIBCXXABI_USE_LLVM_UNWINDER@"
+config.use_libatomic= "@LIBCXX_HAS_ATOMIC_LIB@"
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")
Index: test/libcxx/test/target_info.py
===
--- test/libcxx/test/target_info.py
+++ test/libcxx/test/target_info.py
@@ -172,6 +172,9 @@
 flags += ['-lunwind', '-ldl']
 else:
 flags += ['-lgcc_s', '-lgcc']
+use_libatomic = self.full_config.get_lit_bool('use_libatomic', False)
+if use_libatomic:
+flags += ['-latomic']
 san = self.full_config.get_lit_conf('use_sanitizer', '').strip()
 if san:
 # The libraries and their order are taken from the
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -15,6 +15,7 @@
 pythonize_bool(LIBCXX_BUILD_32_BITS)
 pythonize_bool(LIBCXX_GENERATE_COVERAGE)
 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
+pythonize_bool(LIBCXX_HAS_ATOMIC_LIB)
 
 # The tests shouldn't link to any ABI library when it has been linked into
 # libc++ statically or via a linker script.
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -79,6 +79,7 @@
 add_library_flags_if(LIBCXX_HAS_M_LIB m)
 add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
 add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+add_library_flags_if(LIBCXX_HAS_ATOMIC_LIB atomic)
 
 # Setup flags.
 add_flags_if_supported(-fPIC)
Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -1,5 +1,6 @@
 include(CheckLibraryExists)
 include(CheckCXXCompilerFlag)
+include(CheckLibcxxAtomic)
 
 # Check compiler flags
 
@@ -17,3 +18,7 @@
 check_library_exists(m ccos "" LIBCXX_HAS_M_LIB)
 check_library_exists(rt clock_gettime "" LIBCXX_HAS_RT_LIB)
 check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)
+
+if (NOT HAVE_CXX_ATOMICS_WITHOUT_LIB)
+  set(LIBCXX_HAS_ATOMIC_LIB True)
+endif()
Index: cmake/Modules/CheckLibcxxAtomic.cmake
===
--- /dev/null
+++ cmake/Modules/CheckLibcxxAtomic.cmake
@@ -0,0 +1,38 @@
+INCLUDE(CheckCXXSourceCompiles)
+
+# Sometimes linking against libatomic is required for atomic ops, if
+# the platform doesn't support lock-free atomics.
+#
+# We could modify LLVM's CheckAtomic module and have it check for 64-bit
+# atomics instead. However, we would like to avoid careless uses of 64-bit
+# atomics inside LLVM over time on 32-bit platforms.
+
+function(check_cxx_atomics varname)
+  set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+  set(CMAKE_REQUIRED_FLAGS "-std=c++11")
+  check_cxx_source_compiles("
+#include 
+#include 
+std::atomic x;
+std::atomic y;
+int main() {
+  return x + y;
+}
+" ${varname})
+  set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
+endfunction(check_cxx_atomics)
+
+check_cxx_atomics(HAVE_CXX_ATOMICS_WITHOUT_LIB)
+# If not, check if the library exists, and atomics work with it.
+if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB)
+  check_library_exists(atomic __atomic_fetch_add_8 "" HAVE_LIBATOMIC)
+  if(HAVE_LIBATOMIC)
+list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
+check_cxx_atomics(HAVE_CXX_ATOMICS_WITH_LIB)
+if (NOT HAVE_CXX_ATOMICS_WITH_LIB)
+  message(FATAL_ERROR "Host compiler must support std::atomic!")
+endif()
+  else()
+message(FATAL_ERROR "Host compiler appears to require libatomic, but cannot find it.")
+  endif()
+endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16686: [OpenCL] Generate metadata for opencl_unroll_hint attribute

2016-01-28 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: Anastasia, pxli168, pekka.jaaskelainen.
yaxunl added subscribers: tstellarAMD, cfe-commits.

Add codegen and diagnostics for opencl_unroll_hint attribute.

The code is based on Khronos OpenCL compiler 
(https://github.com/KhronosGroup/SPIR/tree/spirv-1.0).

http://reviews.llvm.org/D16686

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  lib/CodeGen/CGLoopInfo.cpp
  lib/Parse/ParseStmt.cpp
  lib/Sema/SemaStmtAttr.cpp
  test/CodeGenOpenCL/unroll-hint.cl
  test/Parser/opencl-unroll-hint.cl

Index: test/Parser/opencl-unroll-hint.cl
===
--- /dev/null
+++ test/Parser/opencl-unroll-hint.cl
@@ -0,0 +1,31 @@
+//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s
+
+extern int counter();
+
+kernel void B (global int *x) {
+  __attribute__((opencl_unroll_hint(42)))
+  if (x[0]) // expected-error {{OpenCL only supports opencl_unroll_hint on for, while, and do statements}}
+x[0] = 15;
+}
+
+kernel void C (global int *x) {
+  int I = 3;
+  __attribute__((opencl_unroll_hint(I))) // expected-error {{opencl_unroll_hint attribute requires an integer constant}}
+  while (I--)
+x[I] = I;
+}
+
+kernel void D (global int *x) {
+  int i;
+
+  __attribute__((opencl_unroll_hint))
+  do {
+i = counter();
+x[i] = i;
+  } while(i);
+}
+
+kernel void E() {
+  __attribute__((opencl_unroll_hint(-2))) // expected-error {{opencl_unroll_hint requires a positive integral compile time constant expression}}
+  for(int i=0; i<100; i++);
+}
Index: test/CodeGenOpenCL/unroll-hint.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/unroll-hint.cl
@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL1.2 -o - %s | FileCheck %s
+
+/*** for ***/
+void for_count(int* sum)
+{
+// CHECK-LABEL: for_count
+__attribute__((opencl_unroll_hint(8)))
+for( int i = 0; i < 1000; ++i) {
+*sum += i;
+}
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_COUNT:.*]]
+}
+
+void for_disable(int* sum)
+{
+// CHECK-LABEL: for_disable
+__attribute__((opencl_unroll_hint(1)))
+for( int i = 0; i < 1000; ++i) {
+*sum += i;
+}
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_DISABLE:.*]]
+}
+
+void for_full(int* sum)
+{
+// CHECK-LABEL: for_full
+__attribute__((opencl_unroll_hint))
+for( int i = 0; i < 1000; ++i) {
+*sum += i;
+}
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_FULL:.*]]
+}
+
+/*** while ***/
+void while_count(int* sum)
+{
+// CHECK-LABEL: while_count
+int i = 1000;
+__attribute__((opencl_unroll_hint(8)))
+while(i-->0) {
+*sum += i;
+}
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_COUNT:.*]]
+}
+
+void while_disable(int* sum)
+{
+// CHECK-LABEL: while_disable
+int i = 1000;
+__attribute__((opencl_unroll_hint(1)))
+while(i-->0) {
+*sum += i;
+}
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_DISABLE:.*]]
+}
+
+void while_full(int* sum)
+{
+// CHECK-LABEL: while_full
+int i = 1000;
+__attribute__((opencl_unroll_hint))
+while(i-->0) {
+*sum += i;
+}
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_FULL:.*]]
+}
+
+/*** do ***/
+void do_count(int* sum)
+{
+// CHECK-LABEL: do_count
+int i = 1000;
+__attribute__((opencl_unroll_hint(8)))
+do {
+*sum += i;
+} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_COUNT:.*]]
+}
+
+void do_disable(int* sum)
+{
+// CHECK-LABEL: do_disable
+int i = 1000;
+__attribute__((opencl_unroll_hint(1)))
+do {
+*sum += i;
+} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_DISABLE:.*]]
+}
+
+void do_full(int* sum)
+{
+// CHECK-LABEL: do_full
+int i = 1000;
+__attribute__((opencl_unroll_hint))
+do {
+*sum += i;
+} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_FULL:.*]]
+}
+
+
+// CHECK: ![[FOR_COUNT]] =  distinct !{![[FOR_COUNT]],  ![[COUNT:.*]]}
+// CHECK: ![[COUNT]] =  !{!"llvm.loop.unroll.count", i32 8}
+// CHECK: ![[FOR_DISABLE]]   =  distinct !{![[FOR_DISABLE]],  ![[DISABLE:.*]]}
+// CHECK: ![[DISABLE]]   =  !{!"llvm.loop.unroll.disable"}
+// CHECK: ![[FOR_FULL]]  =  distinct !{![[FOR_FULL]],  ![[FULL:.*]]}
+// CHECK: ![[FULL]]  =  !{!"llvm.loop.unroll.full"}
+// CHECK: ![[WHILE_COUNT]]   =  distinct !{![[WHILE_COUNT]],![[COUNT]]}
+// CHECK: ![[WHILE_DISABLE]] =  distinct !{![[WHILE_DISABLE]],  ![[DISABLE]]}
+// CHECK: ![[WHILE_FULL]]=  distinct !{![[WHILE_FULL]], ![[FULL]]}
+// CHECK: ![[DO_COUNT]]  =  distinct !{![[DO_COUNT]],   ![[COUNT]]}
+// CHECK: ![[DO_DISABL

Re: [PATCH] D16564: Fix an issue where backend crashes after frontend emits an error message

2016-01-28 Thread Justin Bogner via cfe-commits
Manman Ren via cfe-commits  writes:
> manmanren created this revision.
> manmanren added reviewers: echristo, rafael, ahatanak.
> manmanren added a subscriber: cfe-commits.
>
> It can happen that frontend emits error message when releasing the
> builder. When that happens, we emit the error message and continue to
> invoke backend.
> Backend will then crash.
>
> The fix is quite simple, we check for errors after releasing the builder.
>
> http://reviews.llvm.org/D16564
>
> Files:
>   lib/CodeGen/ModuleBuilder.cpp
>   test/CodeGen/target-builtin-error-3.c
>
>
> Index: test/CodeGen/target-builtin-error-3.c
> ===
> --- test/CodeGen/target-builtin-error-3.c
> +++ test/CodeGen/target-builtin-error-3.c
> @@ -0,0 +1,28 @@
> +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -S -verify -o - 
> -target-feature +avx
> +
> +// RUN: not %clang_cc1 %s -triple=x86_64-apple-darwin -emit-obj 
> -target-feature +avx 2> %t.err
> +// RUN: FileCheck < %t.err %s
> +// CHECK: 1 error generated
> +
> +typedef unsigned short uint16_t;
> +typedef long long __m128i __attribute__((__vector_size__(16)));
> +typedef float __v8sf __attribute__ ((__vector_size__ (32)));
> +typedef float __m256 __attribute__ ((__vector_size__ (32)));
> +typedef uint16_t half;
> +typedef __attribute__ ((ext_vector_type( 8),__aligned__( 16))) half half8;
> +typedef __attribute__ ((ext_vector_type(16),__aligned__( 32))) half half16;
> +typedef __attribute__ ((ext_vector_type(16),__aligned__( 2))) half half16U;
> +typedef __attribute__ ((ext_vector_type( 8),__aligned__( 32))) float float8;
> +typedef __attribute__ ((ext_vector_type(16),__aligned__( 64))) float float16;
> +static inline half8 __attribute__((__overloadable__)) convert_half( float8 a 
> ) {
> +  return __extension__ ({ __m256 __a = (a); 
> (__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)__a, (0x00)); }); // 
> expected-error {{'__builtin_ia32_vcvtps2ph256' needs target feature f16c}}
> +}
> +static inline half16 __attribute__((__overloadable__)) convert_half( float16 
> a ) {
> +  half16 r; 
> +  r.lo = convert_half( a.lo); 
> +  return r;
> +}
> +void avx_test( uint16_t *destData, float16 argbF)
> +{
> +   ((half16U*)destData)[0] = convert_half(argbF);
> +}
> Index: lib/CodeGen/ModuleBuilder.cpp
> ===
> --- lib/CodeGen/ModuleBuilder.cpp
> +++ lib/CodeGen/ModuleBuilder.cpp
> @@ -208,6 +208,14 @@
>  
>if (Builder)
>  Builder->Release();
> +
> +  // Builder->Release can cause diagnostics to be generated.

This comment's a bit confusing. Isn't it more like "If errors occurred
while building the module, we need to stop here before invoking the
backend", or something like that?

> +  if (Diags.hasErrorOccurred()) {
> +if (Builder)
> +  Builder->clear();
> +M.reset();
> +return;
> +  }
>  }
>  
>  void CompleteTentativeDefinition(VarDecl *D) override {
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r259061 - [Coverage] Use a set to track visited FileIDs (NFC)

2016-01-28 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Jan 28 11:52:18 2016
New Revision: 259061

URL: http://llvm.org/viewvc/llvm-project?rev=259061&view=rev
Log:
[Coverage] Use a set to track visited FileIDs (NFC)

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

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=259061&r1=259060&r2=259061&view=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Thu Jan 28 11:52:18 2016
@@ -15,6 +15,7 @@
 #include "CodeGenFunction.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ProfileData/CoverageMapping.h"
@@ -153,14 +154,13 @@ public:
   void gatherFileIDs(SmallVectorImpl &Mapping) {
 FileIDMapping.clear();
 
-SmallVector Visited;
+llvm::SmallSet Visited;
 SmallVector, 8> FileLocs;
 for (const auto &Region : SourceRegions) {
   SourceLocation Loc = Region.getStartLoc();
   FileID File = SM.getFileID(Loc);
-  if (std::find(Visited.begin(), Visited.end(), File) != Visited.end())
+  if (!Visited.insert(File).second)
 continue;
-  Visited.push_back(File);
 
   unsigned Depth = 0;
   for (SourceLocation Parent = getIncludeOrExpansionLoc(Loc);


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


Re: [libcxx] r259046 - [libcxx] Work around for clang calling GAS after having already failed.

2016-01-28 Thread Hans Wennborg via cfe-commits
Yes, go ahead.

Thanks,
Hans

On Thu, Jan 28, 2016 at 5:57 AM, Daniel Sanders
 wrote:
> Hi Hans,
>
> Is it ok to merge this into 3.8? Eric Fiselier has already approved on the 
> review.
> 
> From: cfe-commits [cfe-commits-boun...@lists.llvm.org] on behalf of Daniel 
> Sanders via cfe-commits [cfe-commits@lists.llvm.org]
> Sent: 28 January 2016 13:49
> To: cfe-commits@lists.llvm.org
> Subject: [libcxx] r259046 - [libcxx] Work around for clang calling GAS after 
> having already failed.
>
> Author: dsanders
> Date: Thu Jan 28 07:49:33 2016
> New Revision: 259046
>
> URL: http://llvm.org/viewvc/llvm-project?rev=259046&view=rev
> Log:
> [libcxx] Work around for clang calling GAS after having already failed.
>
> Summary:
> This is a workaround to a clang bug which causes libcxx tests to fail in the 
> 3.8
> release. The clang bug is currently being investigated. It seems that clang
> does not stop after frontend errors when using -verify and -fno-integrated-as
> (or when this is the default). This patch adds -fsyntax-only to prevent GAS
> from being called, fixing the libcxx failures.
>
> PR26277
>
> Patch by Eric Fiselier
>
> Reviewers: mclow.lists, hans, EricWF
>
> Subscribers: cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D16584
>
> Modified:
> libcxx/trunk/test/libcxx/test/format.py
>
> Modified: libcxx/trunk/test/libcxx/test/format.py
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/format.py?rev=259046&r1=259045&r2=259046&view=diff
> ==
> --- libcxx/trunk/test/libcxx/test/format.py (original)
> +++ libcxx/trunk/test/libcxx/test/format.py Thu Jan 28 07:49:33 2016
> @@ -161,7 +161,7 @@ class LibcxxTestFormat(object):
> 'expected-error', 'expected-no-diagnostics']
>  use_verify = self.use_verify_for_fail and \
>   any([tag in contents for tag in verify_tags])
> -extra_flags = []
> +extra_flags = ['-fsyntax-only']
>  if use_verify:
>  extra_flags += ['-Xclang', '-verify',
>  '-Xclang', '-verify-ignore-unexpected=note']
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-28 Thread Rong Xu via cfe-commits
xur added a comment.

I'll send an updated patch shortly.



Comment at: include/clang/Frontend/CodeGenOptions.def:106
@@ -105,3 +105,3 @@
 
-CODEGENOPT(ProfileInstrGenerate , 1, 0) ///< Instrument code to generate
-///< execution counts to use with PGO.
+CODEGENOPT(ProfileClangInstr, 1, 0) ///< Clang Instrumentation to generate
+///< execution counts to use with PGO.

silvas wrote:
> davidxl wrote:
> > For the sake of being consistent with the new cc1 option, making this an 
> > enum option is better:
> > 
> > ENUM_CODEGENOPT(ProfileInstr,... ) which takes two legal values 
> > ProfInstrClang, ProfInstrLLVM
> > 
> > I'd like to hear Sean's opinion on this.
> SGTM. I was going to suggest something similar. This is more consistent with 
> e.g. OPT_debug_info_kind_EQ and the other multi-value options.
OK. I'll use ENUM as you two suggested.


Comment at: lib/CodeGen/CodeGenModule.cpp:150
@@ -149,3 +149,3 @@
 
-  if (!CodeGenOpts.InstrProfileInput.empty()) {
+  if (!CodeGenOpts.ProfileIRInstr && !CodeGenOpts.InstrProfileInput.empty()) {
 auto ReaderOrErr =

silvas wrote:
> This seems like a latent bug: `!CodeGenOpts.ProfileIRInstr` is true when we 
> are doing no instrumentation. Using an ENUM_CODEGENOPT will fix this and 
> related issues.
I don't think this is a bug. As I mentioned in the update comments. I still use 
this option (-fprofile-instrumentor=) in profile-use compilation. Once we have 
the llvm-profdata patch in, we can detect the profile kind and remove this.


Comment at: lib/Frontend/CompilerInvocation.cpp:495
@@ +494,3 @@
+}
+  } else {
+// Default PGO instrumentor is Clang instrumentation.

silvas wrote:
> The work being done in this `else` is redundant. 
> `-fprofile-instrumentor={clang,llvm,none}` (with "none" being the default if 
> the argument isn't passed) covers this case as 
> `-fprofile-instrumentor=clang`. The driver can be changed to translate 
> `-fprofile-instr-generate` into `-fprofile-instrumentor=clang`. (and 
> `-fprofile-instrument=` might be a better name)
Only if we changed the driver and pushed in -fprofile-instrumentor to the cc1 
argument list, the else part is indeed redundant.

But since I did not change the driver options handling, we still need this else 
branch -- we only set ProfileClangInstr when there is 
OPT_fprofile_instr_generate.

I'll change the -fprofile-instrumentor to -fprofile-instrument and change the 
driver to push in this argument. I will probably remove 
OPT_fprfoile_instr_generate as a CC1 option.




http://reviews.llvm.org/D15829



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


Re: [PATCH] D15603: [OpenCL] Pipe type support

2016-01-28 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

No, this shouldn't happen! There shouldn't be any difference in emitted IR 
depending on a platform. I also don't see any code in CodeGen that could 
specialize.

Is there a way to reproduce your compilation? Passing any triple?


http://reviews.llvm.org/D15603



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


r259063 - Fix strange indent.

2016-01-28 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Jan 28 12:06:31 2016
New Revision: 259063

URL: http://llvm.org/viewvc/llvm-project?rev=259063&view=rev
Log:
Fix strange indent.

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

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=259063&r1=259062&r2=259063&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Jan 28 12:06:31 2016
@@ -271,9 +271,9 @@ void CodeGenFunction::EmitStmt(const Stm
   case Stmt::OMPTaskLoopSimdDirectiveClass:
 EmitOMPTaskLoopSimdDirective(cast(*S));
 break;
-case Stmt::OMPDistributeDirectiveClass:
+  case Stmt::OMPDistributeDirectiveClass:
 EmitOMPDistributeDirective(cast(*S));
-   break;
+break;
   }
 }
 


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


Re: [PATCH] D16639: [libcxx] Limit catopen usage to unix-like OSes

2016-01-28 Thread Ben Craig via cfe-commits
bcraig updated this revision to Diff 46291.
bcraig added a comment.

CloudABI doesn't define __unix__, so stop blacklisting it explicitly and let 
the whitelist filter it out.


http://reviews.llvm.org/D16639

Files:
  include/__config
  include/locale

Index: include/locale
===
--- include/locale
+++ include/locale
@@ -199,6 +199,14 @@
 // has had a chance to bake for a bit
 #include 
 #endif
+
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+// Most unix variants have catopen.  These are the specific ones that don't.
+#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION)
+#define _LIBCPP_HAS_CATOPEN 1
+#endif
+#endif
+
 #ifdef _LIBCPP_HAS_CATOPEN
 #include 
 #endif
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -713,11 +713,6 @@
 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
 #endif
 
-#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION) && \
-!defined(__CloudABI__)
-#define _LIBCPP_HAS_CATOPEN 1
-#endif
-
 #ifdef __FreeBSD__
 #define _DECLARE_C99_LDBL_MATH 1
 #endif


Index: include/locale
===
--- include/locale
+++ include/locale
@@ -199,6 +199,14 @@
 // has had a chance to bake for a bit
 #include 
 #endif
+
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+// Most unix variants have catopen.  These are the specific ones that don't.
+#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION)
+#define _LIBCPP_HAS_CATOPEN 1
+#endif
+#endif
+
 #ifdef _LIBCPP_HAS_CATOPEN
 #include 
 #endif
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -713,11 +713,6 @@
 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
 #endif
 
-#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION) && \
-!defined(__CloudABI__)
-#define _LIBCPP_HAS_CATOPEN 1
-#endif
-
 #ifdef __FreeBSD__
 #define _DECLARE_C99_LDBL_MATH 1
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16634: [libcxx] Whitelist inclusion of sysctl.h instead of blacklisting

2016-01-28 Thread Ben Craig via cfe-commits
bcraig updated this revision to Diff 46292.
bcraig added a comment.

CloudABI doesn't define unix, so stop blacklisting it explicitly and let the 
whitelist filter it out.


http://reviews.llvm.org/D16634

Files:
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -16,10 +16,15 @@
 #include "future"
 #include "limits"
 #include 
-#if !defined(_WIN32)
-# if !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && 
!defined(__native_client__) && !defined(__CloudABI__)
+
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+# include 
+# if defined(BSD)
 #   include 
-# endif // !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && 
!defined(__native_client__) && !defined(__CloudABI__)
+# endif // defined(BSD)
+#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+
+#if !defined(_WIN32)
 # include 
 #endif // !_WIN32
 


Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -16,10 +16,15 @@
 #include "future"
 #include "limits"
 #include 
-#if !defined(_WIN32)
-# if !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__) && !defined(__CloudABI__)
+
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+# include 
+# if defined(BSD)
 #   include 
-# endif // !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__) && !defined(__CloudABI__)
+# endif // defined(BSD)
+#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+
+#if !defined(_WIN32)
 # include 
 #endif // !_WIN32
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16634: [libcxx] Whitelist inclusion of sysctl.h instead of blacklisting

2016-01-28 Thread Ben Craig via cfe-commits
bcraig added a comment.

I plan on submitting this tomorrow morning (my time) so that I have lots of 
time to monitor build failures.


http://reviews.llvm.org/D16634



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


Re: [PATCH] D16664: [CUDA] Generate CUDA's printf alloca in its function's entry block.

2016-01-28 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 46293.
jlebar added a comment.

Address echristo's review comments.


http://reviews.llvm.org/D16664

Files:
  lib/CodeGen/CGCUDABuiltin.cpp
  test/CodeGenCUDA/printf.cu

Index: test/CodeGenCUDA/printf.cu
===
--- test/CodeGenCUDA/printf.cu
+++ test/CodeGenCUDA/printf.cu
@@ -10,9 +10,9 @@
 
 // Check a simple call to printf end-to-end.
 __device__ int CheckSimple() {
+  // CHECK: [[BUF:%[a-zA-Z0-9_]+]] = alloca i8, i32 4, align 4
   // CHECK: [[FMT:%[0-9]+]] = load{{.*}}%fmt
   const char* fmt = "%d";
-  // CHECK: [[BUF:%[a-zA-Z0-9_]+]] = alloca i8, i32 4, align 4
   // CHECK: [[PTR:%[0-9]+]] = getelementptr i8, i8* [[BUF]], i32 0
   // CHECK: [[CAST:%[0-9]+]] = bitcast i8* [[PTR]] to i32*
   // CHECK: store i32 42, i32* [[CAST]], align 4
@@ -51,3 +51,14 @@
   // CHECK: call i32 @vprintf({{.*}}, i8* null){{$}}
   printf("hello, world!");
 }
+
+// Check that printf's alloca happens in the entry block, not inside the if
+// statement.
+__device__ bool foo();
+__device__ void CheckAllocaIsInEntryBlock() {
+  // CHECK: alloca i8, i32 4, align 4
+  // CHECK: call {{.*}} @_Z3foov()
+  if (foo()) {
+printf("%d", 42);
+  }
+}
Index: lib/CodeGen/CGCUDABuiltin.cpp
===
--- lib/CodeGen/CGCUDABuiltin.cpp
+++ lib/CodeGen/CGCUDABuiltin.cpp
@@ -102,9 +102,15 @@
 // If there are no args, pass a null pointer to vprintf.
 BufferPtr = llvm::ConstantPointerNull::get(llvm::Type::getInt8PtrTy(Ctx));
   } else {
-BufferPtr = Builder.Insert(new llvm::AllocaInst(
+// Insert our alloca not into the current BB, but into the function's entry
+// block.  This is important because nvvm doesn't support alloca -- if we
+// put the alloca anywhere else, llvm may eventually output
+// stacksave/stackrestore intrinsics, which cause our nvvm backend to 
choke.
+auto *Alloca = new llvm::AllocaInst(
 llvm::Type::getInt8Ty(Ctx), llvm::ConstantInt::get(Int32Ty, BufSize),
-BufAlign, "printf_arg_buf"));
+BufAlign, "printf_arg_buf");
+Alloca->insertAfter(AllocaInsertPt);
+BufferPtr = Alloca;
 
 unsigned Offset = 0;
 for (unsigned I = 1, NumArgs = Args.size(); I < NumArgs; ++I) {


Index: test/CodeGenCUDA/printf.cu
===
--- test/CodeGenCUDA/printf.cu
+++ test/CodeGenCUDA/printf.cu
@@ -10,9 +10,9 @@
 
 // Check a simple call to printf end-to-end.
 __device__ int CheckSimple() {
+  // CHECK: [[BUF:%[a-zA-Z0-9_]+]] = alloca i8, i32 4, align 4
   // CHECK: [[FMT:%[0-9]+]] = load{{.*}}%fmt
   const char* fmt = "%d";
-  // CHECK: [[BUF:%[a-zA-Z0-9_]+]] = alloca i8, i32 4, align 4
   // CHECK: [[PTR:%[0-9]+]] = getelementptr i8, i8* [[BUF]], i32 0
   // CHECK: [[CAST:%[0-9]+]] = bitcast i8* [[PTR]] to i32*
   // CHECK: store i32 42, i32* [[CAST]], align 4
@@ -51,3 +51,14 @@
   // CHECK: call i32 @vprintf({{.*}}, i8* null){{$}}
   printf("hello, world!");
 }
+
+// Check that printf's alloca happens in the entry block, not inside the if
+// statement.
+__device__ bool foo();
+__device__ void CheckAllocaIsInEntryBlock() {
+  // CHECK: alloca i8, i32 4, align 4
+  // CHECK: call {{.*}} @_Z3foov()
+  if (foo()) {
+printf("%d", 42);
+  }
+}
Index: lib/CodeGen/CGCUDABuiltin.cpp
===
--- lib/CodeGen/CGCUDABuiltin.cpp
+++ lib/CodeGen/CGCUDABuiltin.cpp
@@ -102,9 +102,15 @@
 // If there are no args, pass a null pointer to vprintf.
 BufferPtr = llvm::ConstantPointerNull::get(llvm::Type::getInt8PtrTy(Ctx));
   } else {
-BufferPtr = Builder.Insert(new llvm::AllocaInst(
+// Insert our alloca not into the current BB, but into the function's entry
+// block.  This is important because nvvm doesn't support alloca -- if we
+// put the alloca anywhere else, llvm may eventually output
+// stacksave/stackrestore intrinsics, which cause our nvvm backend to choke.
+auto *Alloca = new llvm::AllocaInst(
 llvm::Type::getInt8Ty(Ctx), llvm::ConstantInt::get(Int32Ty, BufSize),
-BufAlign, "printf_arg_buf"));
+BufAlign, "printf_arg_buf");
+Alloca->insertAfter(AllocaInsertPt);
+BufferPtr = Alloca;
 
 unsigned Offset = 0;
 for (unsigned I = 1, NumArgs = Args.size(); I < NumArgs; ++I) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16664: [CUDA] Generate CUDA's printf alloca in its function's entry block.

2016-01-28 Thread Justin Lebar via cfe-commits
jlebar marked an inline comment as done.


Comment at: lib/CodeGen/CGCUDABuiltin.cpp:109
@@ -106,1 +108,3 @@
+// stacksave/stackrestore intrinsics, which cause ptxas to choke.
+auto *Alloca = new llvm::AllocaInst(
 llvm::Type::getInt8Ty(Ctx), llvm::ConstantInt::get(Int32Ty, BufSize),

echristo wrote:
> Not quite, you'll want to use AllocaInsertPt for this or even 
> CreateTempAlloca.
> 
> 
Aha.  Used AllocaInsertPt because it doesn't seem that there's an overload of 
CreateTempAlloca that takes an explicit size.


http://reviews.llvm.org/D16664



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


Re: [PATCH] D16664: [CUDA] Generate CUDA's printf alloca in its function's entry block.

2016-01-28 Thread Justin Lebar via cfe-commits
jlebar marked an inline comment as done.
jlebar added a comment.

http://reviews.llvm.org/D16664



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


r259067 - [PGO] test case cleanups

2016-01-28 Thread Xinliang David Li via cfe-commits
Author: davidxl
Date: Thu Jan 28 12:25:53 2016
New Revision: 259067

URL: http://llvm.org/viewvc/llvm-project?rev=259067&view=rev
Log:
[PGO] test case cleanups

1. Make test case more focused and robust by focusing on what to be tested 
(linkage, icall) -- make it easier to validate
2. Testing linkages of data and counter variables instead of names. Counters 
and data are more relavant to be tested.


Modified:
cfe/trunk/test/Profile/c-indirect-call.c
cfe/trunk/test/Profile/c-linkage-available_externally.c
cfe/trunk/test/Profile/c-linkage.c
cfe/trunk/test/Profile/cxx-linkage.cpp

Modified: cfe/trunk/test/Profile/c-indirect-call.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-indirect-call.c?rev=259067&r1=259066&r2=259067&view=diff
==
--- cfe/trunk/test/Profile/c-indirect-call.c (original)
+++ cfe/trunk/test/Profile/c-indirect-call.c Thu Jan 28 12:25:53 2016
@@ -7,7 +7,7 @@ int main(void) {
 // CHECK:  [[REG1:%[0-9]+]] = load void ()*, void ()** @foo, align 8
 // CHECK-NEXT:  call void [[REG1]]()
 // CHECK-NEXT:  [[REG2:%[0-9]+]] = ptrtoint void ()* [[REG1]] to i64
-// CHECK-NEXT:  call void @__llvm_profile_instrument_target(i64 [[REG2]], i8* 
bitcast ({ i32, i32, i64, i8*, i64*, i8*, i8*, [1 x i16] }* @__profd_main to 
i8*), i32 0)
+// CHECK-NEXT:  call void @__llvm_profile_instrument_target(i64 [[REG2]], i8* 
bitcast ({{.*}}* @__profd_main to i8*), i32 0)
   foo();
   return 0;
 }

Modified: cfe/trunk/test/Profile/c-linkage-available_externally.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-linkage-available_externally.c?rev=259067&r1=259066&r2=259067&view=diff
==
--- cfe/trunk/test/Profile/c-linkage-available_externally.c (original)
+++ cfe/trunk/test/Profile/c-linkage-available_externally.c Thu Jan 28 12:25:53 
2016
@@ -1,11 +1,9 @@
-// Make sure instrementation data from available_externally functions doesn't
-// get thrown out.
+// Make sure instrumentation data from available_externally functions doesn't
+// get thrown out and are emitted with the expected linkage.
 // RUN: %clang_cc1 -O2 -triple x86_64-apple-macosx10.9 -main-file-name 
c-linkage-available_externally.c %s -o - -emit-llvm -fprofile-instr-generate | 
FileCheck %s
 
-// CHECK: @__profn_foo = linkonce_odr hidden constant [3 x i8] c"foo", section 
"__DATA,__llvm_prf_names", align 1
-
 // CHECK: @__profc_foo = linkonce_odr hidden global [1 x i64] zeroinitializer, 
section "__DATA,__llvm_prf_cnts", align 8
-// CHECK: @__profd_foo = linkonce_odr hidden global { i32, i32, i64, i8*, 
i64*, i8*, i8*, [1 x i16] } { i32 3, i32 1, i64 0, i8* getelementptr inbounds 
([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64* getelementptr inbounds 
([1 x i64], [1 x i64]* @__profc_foo, i32 0, i32 0), i8* null, i8* null, [1 x 
i16] zeroinitializer }, section "__DATA,__llvm_prf_data", align 8
+// CHECK: @__profd_foo = linkonce_odr hidden global {{.*}} i64* getelementptr 
inbounds ([1 x i64], [1 x i64]* @__profc_foo, i32 0, i32 0){{.*}}, section 
"__DATA,__llvm_prf_data", align 8
 inline int foo(void) { return 1; }
 
 int main(void) {

Modified: cfe/trunk/test/Profile/c-linkage.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-linkage.c?rev=259067&r1=259066&r2=259067&view=diff
==
--- cfe/trunk/test/Profile/c-linkage.c (original)
+++ cfe/trunk/test/Profile/c-linkage.c Thu Jan 28 12:25:53 2016
@@ -1,10 +1,14 @@
-// Check that the profiling names we create have the linkage we expect
+// Check that the profiling counters and data we create have the linkage we 
expect
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-linkage.c 
%s -o - -emit-llvm -fprofile-instr-generate | FileCheck %s
 
-// CHECK: @__profn_foo = private constant [3 x i8] c"foo"
-// CHECK: @__profn_foo_weak = weak hidden constant [8 x i8] c"foo_weak"
-// CHECK: @__profn_main = private constant [4 x i8] c"main"
-// CHECK: @__profn_c_linkage.c_foo_internal = private constant [24 x i8] 
c"c-linkage.c:foo_internal"
+// CHECK: @__profc_foo = private global
+// CHECK: @__profd_foo = private global
+// CHECK: @__profc_foo_weak = weak hidden global
+// CHECK: @__profd_foo_weak = weak hidden global
+// CHECK: @__profc_main = private global
+// CHECK: @__profd_main = private global
+// CHECK: @__profc_c_linkage.c_foo_internal = private global
+// CHECK: @__profd_c_linkage.c_foo_internal = private global
 
 void foo(void) { }
 

Modified: cfe/trunk/test/Profile/cxx-linkage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-linkage.cpp?rev=259067&r1=259066&r2=259067&view=diff
==
--- cfe/trunk/test/Profile/cxx-linkage.cpp (original)
+++ cfe/trunk/test/Profile/cxx-linkage.cpp Thu Jan 28 12:25:

Re: [PATCH] D15603: [OpenCL] Pipe type support

2016-01-28 Thread Ulrich Weigand via cfe-commits
uweigand added a comment.

In http://reviews.llvm.org/D15603#338488, @Anastasia wrote:

> No, this shouldn't happen! There shouldn't be any difference in emitted IR 
> depending on a platform. I also don't see any code in CodeGen that could 
> specialize.
>
> Is there a way to reproduce your compilation? Passing any triple?


I see the problem when using:

  clang --target=s390x-linux -S -O0 -emit-llvm -std=CL2.0 -o - pipe_types.cl

Using --target=i386-linux instead results in the expected output.


http://reviews.llvm.org/D15603



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


r259070 - Class Property: class property and instance property can have the same name.

2016-01-28 Thread Manman Ren via cfe-commits
Author: mren
Date: Thu Jan 28 12:49:28 2016
New Revision: 259070

URL: http://llvm.org/viewvc/llvm-project?rev=259070&view=rev
Log:
Class Property: class property and instance property can have the same name.

Add "enum ObjCPropertyQueryKind" to a few APIs that used to only take the name
of the property: ObjCPropertyDecl::findPropertyDecl,
ObjCContainerDecl::FindPropertyDeclaration,
ObjCInterfaceDecl::FindPropertyVisibleInPrimaryClass,
ObjCImplDecl::FindPropertyImplDecl, and Sema::ActOnPropertyImplDecl.

ObjCPropertyQueryKind currently has 3 values:
OBJC_PR_query_unknown, OBJC_PR_query_instance, OBJC_PR_query_class

This extra parameter specifies that we are looking for an instance property with
the given name, or a class property with the given name, or any property with
the given name (if both exist, the instance property will be returned).

rdar://23891898

Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/Analysis/BodyFarm.cpp
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/lib/Sema/SemaPseudoObject.cpp
cfe/trunk/test/SemaObjC/objc-class-property.m
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=259070&r1=259069&r2=259070&view=diff
==
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Thu Jan 28 12:49:28 2016
@@ -689,6 +689,12 @@ public:
   friend TrailingObjects;
 };
 
+enum class ObjCPropertyQueryKind : uint8_t {
+  OBJC_PR_query_unknown = 0x00,
+  OBJC_PR_query_instance,
+  OBJC_PR_query_class
+};
+
 /// \brief Represents one property declaration in an Objective-C interface.
 ///
 /// For example:
@@ -826,6 +832,14 @@ public:
 
   bool isInstanceProperty() const { return !isClassProperty(); }
   bool isClassProperty() const { return PropertyAttributes & OBJC_PR_class; }
+  ObjCPropertyQueryKind getQueryKind() const {
+return isClassProperty() ? ObjCPropertyQueryKind::OBJC_PR_query_class :
+   ObjCPropertyQueryKind::OBJC_PR_query_instance;
+  }
+  static ObjCPropertyQueryKind getQueryKind(bool isClassProperty) {
+return isClassProperty ? ObjCPropertyQueryKind::OBJC_PR_query_class :
+ ObjCPropertyQueryKind::OBJC_PR_query_instance;
+  }
 
   /// getSetterKind - Return the method used for doing assignment in
   /// the property setter. This is only valid if the property has been
@@ -878,7 +892,8 @@ public:
 
   /// Lookup a property by name in the specified DeclContext.
   static ObjCPropertyDecl *findPropertyDecl(const DeclContext *DC,
-const IdentifierInfo *propertyID);
+const IdentifierInfo *propertyID,
+ObjCPropertyQueryKind queryKind);
 
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K == ObjCProperty; }
@@ -1005,7 +1020,8 @@ public:
   ObjCIvarDecl *getIvarDecl(IdentifierInfo *Id) const;
 
   ObjCPropertyDecl *
-  FindPropertyDeclaration(const IdentifierInfo *PropertyId) const;
+  FindPropertyDeclaration(const IdentifierInfo *PropertyId,
+  ObjCPropertyQueryKind QueryKind) const;
 
   typedef llvm::DenseMap PropertyMap;
   
@@ -1688,7 +1704,8 @@ public:
   }
 
   ObjCPropertyDecl
-*FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId) const;
+*FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId,
+   ObjCPropertyQueryKind QueryKind) const;
 
   void collectPropertiesToImplement(PropertyMap &PM,
 PropertyDeclOrder &PO) const override;
@@ -2325,7 +2342,8 @@ public:
 
   void addPropertyImplementation(ObjCPropertyImplDecl *property);
 
-  ObjCPropertyImplDecl *FindPropertyImplDecl(IdentifierInfo *propertyId) const;
+  ObjCPropertyImplDecl *FindPropertyImplDecl(IdentifierInfo *propertyId,
+ObjCPropertyQueryKind queryKind) const;
   ObjCPropertyImplDecl *FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const;
 
   // Iterator access to properties.

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=259070&r1=259069&r2=259070&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h 

Re: [PATCH] D16514: Add -stop-on-failure driver option, and enable it by default for CUDA compiles.

2016-01-28 Thread Artem Belevich via cfe-commits
tra added inline comments.


Comment at: include/clang/Driver/Options.td:1807
@@ +1806,3 @@
+"CUDA compilation without --save-temps.">;
+def nostop_on_failure : Flag<["-"], "nostop-on-failure">, 
Flags<[DriverOption]>;
+

I'd use 'no-' prefix.


Comment at: lib/Driver/Driver.cpp:650
@@ -638,3 +649,3 @@
   SmallVector, 4> FailingCommands;
-  C.ExecuteJobs(C.getJobs(), FailingCommands);
+  C.ExecuteJobs(C.getJobs(), /* StopOnFailure = */ false, FailingCommands);
 

Why is StopOnFailure is false in this case? Shouldn't it obey command line 
options, too?


http://reviews.llvm.org/D16514



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


r259077 - Remove unused parameter.

2016-01-28 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Jan 28 13:12:32 2016
New Revision: 259077

URL: http://llvm.org/viewvc/llvm-project?rev=259077&view=rev
Log:
Remove unused parameter.

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

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=259077&r1=259076&r2=259077&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jan 28 13:12:32 2016
@@ -3997,12 +3997,10 @@ static bool CheckAnonMemberRedeclaration
 ///
 /// This routine is recursive, injecting the names of nested anonymous
 /// structs/unions into the owning context and scope as well.
-static bool InjectAnonymousStructOrUnionMembers(Sema &SemaRef, Scope *S,
- DeclContext *Owner,
- RecordDecl *AnonRecord,
- AccessSpecifier AS,
- SmallVectorImpl 
&Chaining,
- bool MSAnonStruct) {
+static bool
+InjectAnonymousStructOrUnionMembers(Sema &SemaRef, Scope *S, DeclContext 
*Owner,
+RecordDecl *AnonRecord, AccessSpecifier AS,
+SmallVectorImpl &Chaining) {
   bool Invalid = false;
 
   // Look every FieldDecl and IndirectFieldDecl with a name.
@@ -4345,8 +4343,7 @@ Decl *Sema::BuildAnonymousStructOrUnion(
   SmallVector Chain;
   Chain.push_back(Anon);
 
-  if (InjectAnonymousStructOrUnionMembers(*this, S, Owner, Record, AS,
-  Chain, false))
+  if (InjectAnonymousStructOrUnionMembers(*this, S, Owner, Record, AS, Chain))
 Invalid = true;
 
   if (VarDecl *NewVD = dyn_cast(Anon)) {
@@ -4418,7 +4415,7 @@ Decl *Sema::BuildMicrosoftCAnonymousStru
   if (RequireCompleteType(Anon->getLocation(), RecTy,
   diag::err_field_incomplete) ||
   InjectAnonymousStructOrUnionMembers(*this, S, CurContext, RecordDef,
-  AS_none, Chain, true)) {
+  AS_none, Chain)) {
 Anon->setInvalidDecl();
 ParentDecl->setInvalidDecl();
   }


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


Re: r258307 - [OPENMP 4.0] Fix for codegen of 'cancel' directive within 'sections' directive.

2016-01-28 Thread Hans Wennborg via cfe-commits
Alexey: you're the owner of openmp in Clang.

Can you comment on what should be merged here?

On Tue, Jan 26, 2016 at 3:43 PM, Jack Howarth
 wrote:
> Tested the attached patch which contains a back port of the net
> changes from both r258307 and
>
> Author: abataev
> Date: Fri Jan 22 02:56:50 2016
> New Revision: 258495
>
> URL: http://llvm.org/viewvc/llvm-project?rev=258495&view=rev
> Log:
> [OPENMP] Generalize codegen for 'sections'-based directive.
> If 'sections' directive has only one sub-section, the code for
> 'single'-based directive was emitted. Removed this codegen, because it
> causes crashes in different cases.
>
> Modified:
> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
> cfe/trunk/test/OpenMP/cancel_codegen.cpp
> cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
> cfe/trunk/test/OpenMP/parallel_sections_codegen.cpp
> cfe/trunk/test/OpenMP/sections_codegen.cpp
> cfe/trunk/test/OpenMP/sections_firstprivate_codegen.cpp
> cfe/trunk/test/OpenMP/sections_lastprivate_codegen.cpp
> cfe/trunk/test/OpenMP/sections_private_codegen.cpp
> cfe/trunk/test/OpenMP/sections_reduction_codegen.cpp
>
> on x86_64-apple-darwin15 without regressions in the cfe or libomp test suites.
>  Jack
> ps Also verified that no regressions occur in the OpenMP3.1_Validation
> test suite.
>
> On Tue, Jan 26, 2016 at 2:23 PM, Hans Wennborg  wrote:
>> Did that fix land, and should it be merged to 3.8?
>>
>> On Thu, Jan 21, 2016 at 7:03 PM, Alexey Bataev  wrote:
>>> Later today I will post another fix, that will fix all 'sections'
>>> related troubles, including this one. So I don't think it is necessary
>>> to merge it
>>>
>>> Best regards,
>>> Alexey Bataev
>>> =
>>> Software Engineer
>>> Intel Compiler Team
>>>
>>> 22.01.2016 0:10, Hans Wennborg пишет:
 Jack suggested (https://llvm.org/bugs/show_bug.cgi?id=26059#c7) that
 this should be merged to 3.8.

 Alexey, you're the code owner here. OK for merging? If yes, do you
 want to go ahead and merge with utils/release/merge.sh?

 On Wed, Jan 20, 2016 at 4:29 AM, Alexey Bataev via cfe-commits
  wrote:
> Author: abataev
> Date: Wed Jan 20 06:29:47 2016
> New Revision: 258307
>
> URL: http://llvm.org/viewvc/llvm-project?rev=258307&view=rev
> Log:
> [OPENMP 4.0] Fix for codegen of 'cancel' directive within 'sections' 
> directive.
> Allow to emit code for 'cancel' directive within 'sections' directive 
> with single sub-section.
>
> Modified:
>  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
>  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
>  cfe/trunk/test/OpenMP/cancel_codegen.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=258307&r1=258306&r2=258307&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Jan 20 06:29:47 2016
> @@ -3685,8 +3685,6 @@ void CGOpenMPRuntime::emitCancelCall(Cod
> // kmp_int32 cncl_kind);
> if (auto *OMPRegionInfo =
> dyn_cast_or_null(CGF.CapturedStmtInfo)) {
> -if (OMPRegionInfo->getDirectiveKind() == OMPD_single)
> -  return;
>   auto &&ThenGen = [this, Loc, CancelRegion,
> OMPRegionInfo](CodeGenFunction &CGF) {
> llvm::Value *Args[] = {
>
> Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=258307&r1=258306&r2=258307&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Wed Jan 20 06:29:47 2016
> @@ -1786,7 +1786,11 @@ CodeGenFunction::EmitSections(const OMPE
>   CGF.EmitOMPPrivateClause(S, SingleScope);
>   (void)SingleScope.Privatize();
>
> +auto Exit = CGF.getJumpDestInCurrentScope("omp.sections.exit");
> +CGF.BreakContinueStack.push_back(BreakContinue(Exit, Exit));
>   CGF.EmitStmt(Stmt);
> +CGF.EmitBlock(Exit.getBlock());
> +CGF.BreakContinueStack.pop_back();
> };
> CGM.getOpenMPRuntime().emitSingleRegion(*this, CodeGen, 
> S.getLocStart(),
> llvm::None, llvm::None, 
> llvm::None,
> @@ -2647,7 +2651,8 @@ CodeGenFunction::getOMPCancelDestination
> if (Kind == OMPD_parallel || Kind == OMPD_task)
>   return ReturnBlock;
> assert(Kind == OMPD_for || Kind == OMPD_section || Kind == 
> OMPD_sections ||
> - Kind == OMPD_parallel_sections || Kind == OMPD_parallel_for)

Re: r258782 - Recommit: R258773 [OpenCL] Pipe builtin functions

2016-01-28 Thread Hans Wennborg via cfe-commits
I don't think we have a specific code owner for OpenCL in Clang, which
means Richard is the owner.

Richard, what do you think?

On Wed, Jan 27, 2016 at 10:08 PM, xiuli pan  wrote:
> Hi hans,
>
> Request to merge it to release 38
>
> It adds Pipe BIFs to be used along with Pipe type committed earlier (in 
> r257254).
>
> Thanks
> Xiuli
>
> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
> Xiuli Pan via cfe-commits
> Sent: Tuesday, January 26, 2016 12:04 PM
> To: cfe-commits@lists.llvm.org
> Subject: r258782 - Recommit: R258773 [OpenCL] Pipe builtin functions
>
> Author: pxl
> Date: Mon Jan 25 22:03:48 2016
> New Revision: 258782
>
> URL: http://llvm.org/viewvc/llvm-project?rev=258782&view=rev
> Log:
> Recommit: R258773 [OpenCL] Pipe builtin functions
> Fix arc patch fuzz error.
> Summary:
> Support for the pipe built-in functions for OpenCL 2.0.
> The pipe builtin functions may have infinite kinds of element types, one 
> approach
> would be to just generate calls that would always use generic types such as 
> void*.
> This patch is based on bader's opencl support patch on SPIR-V branch.
>
> Reviewers: Anastasia, pekka.jaaskelainen
>
> Subscribers: keryell, bader, cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D15914
>
> Added:
> cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl
> cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
> Modified:
> cfe/trunk/include/clang/Basic/Builtins.def
> cfe/trunk/include/clang/Basic/Builtins.h
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Basic/Builtins.cpp
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Builtins.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=258782&r1=258781&r2=258782&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/Builtins.def (original)
> +++ cfe/trunk/include/clang/Basic/Builtins.def Mon Jan 25 22:03:48 2016
> @@ -1252,6 +1252,32 @@ BUILTIN(__builtin___get_unsafe_stack_ptr
>  BUILTIN(__builtin_nontemporal_store, "v.", "t")
>  BUILTIN(__builtin_nontemporal_load, "v.", "t")
>
> +// OpenCL v2.0 s6.13.16, s9.17.3.5 - Pipe functions.
> +// We need the generic prototype, since the packet type could be anything.
> +LANGBUILTIN(read_pipe, "i.", "tn", OCLC_LANG)
> +LANGBUILTIN(write_pipe, "i.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(reserve_read_pipe, "i.", "tn", OCLC_LANG)
> +LANGBUILTIN(reserve_write_pipe, "i.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(commit_write_pipe, "v.", "tn", OCLC_LANG)
> +LANGBUILTIN(commit_read_pipe, "v.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(sub_group_reserve_read_pipe, "i.", "tn", OCLC_LANG)
> +LANGBUILTIN(sub_group_reserve_write_pipe, "i.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(sub_group_commit_read_pipe, "v.", "tn", OCLC_LANG)
> +LANGBUILTIN(sub_group_commit_write_pipe, "v.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(work_group_reserve_read_pipe, "i.", "tn", OCLC_LANG)
> +LANGBUILTIN(work_group_reserve_write_pipe, "i.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(work_group_commit_read_pipe, "v.", "tn", OCLC_LANG)
> +LANGBUILTIN(work_group_commit_write_pipe, "v.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(get_pipe_num_packets, "Ui.", "tn", OCLC_LANG)
> +LANGBUILTIN(get_pipe_max_packets, "Ui.", "tn", OCLC_LANG)
> +
>  #undef BUILTIN
>  #undef LIBBUILTIN
>  #undef LANGBUILTIN
>
> Modified: cfe/trunk/include/clang/Basic/Builtins.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=258782&r1=258781&r2=258782&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/Builtins.h (original)
> +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Jan 25 22:03:48 2016
> @@ -36,6 +36,7 @@ enum LanguageID {
>CXX_LANG = 0x4,  // builtin for cplusplus only.
>OBJC_LANG = 0x8, // builtin for objective-c and objective-c++
>MS_LANG = 0x10,  // builtin requires MS mode.
> +  OCLC_LANG = 0x20,// builtin for OpenCL C only.
>ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all 
> languages.
>ALL_GNU_LANGUAGES = ALL_LANGUAGES | GNU_LANG,  // builtin requires GNU 
> mode.
>ALL_MS_LANGUAGES = ALL_LANGUAGES | MS_LANG // builtin requires MS mode.
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=258782&r1=258781&r2=258782&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jan 25 22:03:48 
> 2016
> @@ -7680,6 +7680,16 @@ def err_atomic_init_constant : Error<
>  def err_opencl_implicit_vector_conversion : Error<
>"implicit conve

Re: Merge OpenCL 2.0 Pipe builtins (r258782) in 3.8

2016-01-28 Thread Hans Wennborg via cfe-commits
Sorry for the slow reply.

I've replied on the r258782 thread.

On Tue, Jan 26, 2016 at 10:29 AM, Anastasia Stulova
 wrote:
> Could you please merge Clang commit r258782 into release 3.8.
>
>
>
> It adds Pipe BIFs to be used along with Pipe type committed earlier (in
> r257254).
>
>
>
> Thanks,
>
> Anastasia
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r259079 - Include RecordDecls from anonymous unions in the AST.

2016-01-28 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Jan 28 13:25:00 2016
New Revision: 259079

URL: http://llvm.org/viewvc/llvm-project?rev=259079&view=rev
Log:
Include RecordDecls from anonymous unions in the AST.

For

  void f() {
union { int i; };
  }

clang used to omit the RecordDecl from the anonymous union from the AST.
That's because the code creating it only called PushOnScopeChains(), which adds
it to the current DeclContext, which here is the function's DeclContext. But
RecursiveASTVisitor doesn't descent into all decls in a FunctionDecl.

Instead, for DeclContexts that contain statements, return the RecordDecl so
that it can be included in the DeclStmt containing the VarDecl for the union.

Interesting bits from the AST before this change:

|-FunctionDecl
| `-CompoundStmt
|   |-DeclStmt
|   | `-VarDecl 0x589cd60  col:3 implicit used 'union (anonymous at 
test.cc:3:3)' callinit

After this change:

-FunctionDecl
| `-CompoundStmt
|   |-DeclStmt
|   | |-CXXRecordDecl 0x4612e48  col:3 union definition
|   | | |-FieldDecl 0x4612f70  col:15 referenced i 'int'
|   | `-VarDecl 0x4613010  col:3 implicit used 'union (anonymous at 
test.cc:3:3)' callinit

This is now closer to how anonymous struct and unions are represented as
members of structs.  It also enabled deleting some one-off code in the
template instantiation code.

Finally, it fixes a crash with ASTMatchers, see the included test case
(this fixes http://crbug.com/580749).


Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=259079&r1=259078&r2=259079&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jan 28 13:25:00 2016
@@ -1861,12 +1861,12 @@ public:
   void ActOnPopScope(SourceLocation Loc, Scope *S);
   void ActOnTranslationUnitScope(Scope *S);
 
-  Decl *ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS,
-   DeclSpec &DS);
-  Decl *ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS,
-   DeclSpec &DS,
+  Decl *ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS,
+   RecordDecl *&AnonRecord);
+  Decl *ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS,
MultiTemplateParamsArg TemplateParams,
-   bool IsExplicitInstantiation = false);
+   bool IsExplicitInstantiation,
+   RecordDecl *&AnonRecord);
 
   Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
 AccessSpecifier AS,

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=259079&r1=259078&r2=259079&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Jan 28 13:25:00 2016
@@ -1530,9 +1530,14 @@ Parser::ParseSimpleDeclaration(unsigned
 ProhibitAttributes(Attrs);
 DeclEnd = Tok.getLocation();
 if (RequireSemi) ConsumeToken();
+RecordDecl *AnonRecord = nullptr;
 Decl *TheDecl = Actions.ParsedFreeStandingDeclSpec(getCurScope(), AS_none,
-   DS);
+   DS, AnonRecord);
 DS.complete(TheDecl);
+if (AnonRecord) {
+  Decl* decls[] = {AnonRecord, TheDecl};
+  return Actions.BuildDeclaratorGroup(decls, /*TypeMayContainAuto=*/false);
+}
 return Actions.ConvertDeclToDeclGroup(TheDecl);
   }
 
@@ -3520,8 +3525,10 @@ void Parser::ParseStructDeclaration(
   // If there are no declarators, this is a free-standing declaration
   // specifier. Let the actions module cope with it.
   if (Tok.is(tok::semi)) {
+RecordDecl *AnonRecord = nullptr;
 Decl *TheDecl = Actions.ParsedFreeStandingDeclSpec(getCurScope(), AS_none,
-   DS);
+   DS, AnonRecord);
+assert(!AnonRecord && "Did not expect anonymous struct or union here");
 DS.complete(TheDecl);
 return;
   }

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=259079&r1=259078&r2=259079&view=diff
==
--- cfe/trun

Re: [PATCH] D16514: Add -stop-on-failure driver option, and enable it by default for CUDA compiles.

2016-01-28 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 46300.
jlebar marked an inline comment as done.
jlebar added a comment.

Address tra's review comment (rename flag).


http://reviews.llvm.org/D16514

Files:
  include/clang/Driver/Compilation.h
  include/clang/Driver/Driver.h
  include/clang/Driver/Options.td
  lib/Driver/Compilation.cpp
  lib/Driver/Driver.cpp

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -58,7 +58,8 @@
   CCPrintHeadersFilename(nullptr), CCLogDiagnosticsFilename(nullptr),
   CCCPrintBindings(false), CCPrintHeaders(false), CCLogDiagnostics(false),
   CCGenDiagnostics(false), CCCGenericGCCName(""), CheckInputsExist(true),
-  CCCUsePCH(true), SuppressMissingInputWarning(false) {
+  CCCUsePCH(true), SuppressMissingInputWarning(false),
+  StopOnJobFailure(false) {
 
   // Provide a sane fallback if no VFS is specified.
   if (!this->VFS)
@@ -505,6 +506,16 @@
   InputList Inputs;
   BuildInputs(C->getDefaultToolChain(), *TranslatedArgs, Inputs);
 
+  // StopOnJobFailure defaults to false, except for CUDA compilations.
+  if (Arg *A = C->getArgs().getLastArg(options::OPT_stop_on_failure,
+   options::OPT_no_stop_on_failure))
+StopOnJobFailure = A->getOption().matches(options::OPT_stop_on_failure);
+  else
+StopOnJobFailure =
+llvm::any_of(Inputs, [](const std::pair &I) {
+  return I.first == types::TY_CUDA;
+});
+
   // Construct the list of abstract actions to perform for this compilation. On
   // MachO targets this uses the driver-driver and universal actions.
   if (TC.getTriple().isOSBinFormatMachO())
@@ -638,7 +649,7 @@
 
   // Generate preprocessed output.
   SmallVector, 4> FailingCommands;
-  C.ExecuteJobs(C.getJobs(), FailingCommands);
+  C.ExecuteJobs(C.getJobs(), /* StopOnFailure = */ false, FailingCommands);
 
   // If any of the preprocessing commands failed, clean up and exit.
   if (!FailingCommands.empty()) {
@@ -730,7 +741,7 @@
   for (auto &Job : C.getJobs())
 setUpResponseFiles(C, Job);
 
-  C.ExecuteJobs(C.getJobs(), FailingCommands);
+  C.ExecuteJobs(C.getJobs(), StopOnJobFailure, FailingCommands);
 
   // Remove temp files.
   C.CleanupFileList(C.getTempFiles());
Index: lib/Driver/Compilation.cpp
===
--- lib/Driver/Compilation.cpp
+++ lib/Driver/Compilation.cpp
@@ -188,14 +188,17 @@
   return !ActionFailed(&C.getSource(), FailingCommands);
 }
 
-void Compilation::ExecuteJobs(const JobList &Jobs,
+void Compilation::ExecuteJobs(const JobList &Jobs, bool StopOnFailure,
   FailingCommandList &FailingCommands) const {
   for (const auto &Job : Jobs) {
 if (!InputsOk(Job, FailingCommands))
   continue;
 const Command *FailingCommand = nullptr;
-if (int Res = ExecuteCommand(Job, FailingCommand))
+if (int Res = ExecuteCommand(Job, FailingCommand)) {
   FailingCommands.push_back(std::make_pair(Res, FailingCommand));
+  if (StopOnFailure)
+return;
+}
   }
 }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1801,6 +1801,11 @@
 def : Flag<["-"], "no-integrated-as">, Alias,
   Flags<[CC1Option, DriverOption]>;
 
+def stop_on_failure : Flag<["-"], "stop-on-failure">, Flags<[DriverOption]>,
+  HelpText<"Stop running jobs as soon as one fails.  This is the default during "
+"CUDA compilation without --save-temps.">;
+def no_stop_on_failure : Flag<["-"], "no-stop-on-failure">, Flags<[DriverOption]>;
+
 def working_directory : JoinedOrSeparate<["-"], "working-directory">, Flags<[CC1Option]>,
   HelpText<"Resolve file paths relative to the specified directory">;
 def working_directory_EQ : Joined<["-"], "working-directory=">, Flags<[CC1Option]>,
Index: include/clang/Driver/Driver.h
===
--- include/clang/Driver/Driver.h
+++ include/clang/Driver/Driver.h
@@ -192,6 +192,10 @@
   /// Certain options suppress the 'no input files' warning.
   bool SuppressMissingInputWarning : 1;
 
+  /// Should we stop running all jobs as soon as one fails?  If false, we run as
+  /// much as we can.
+  bool StopOnJobFailure : 1;
+
   std::list TempFiles;
   std::list ResultFiles;
 
Index: include/clang/Driver/Compilation.h
===
--- include/clang/Driver/Compilation.h
+++ include/clang/Driver/Compilation.h
@@ -193,12 +193,13 @@
   /// \return The result code of the subprocess.
   int ExecuteCommand(const Command &C, const Command *&FailingCommand) const;
 
-  /// ExecuteJob - Execute a single job.
+  /// ExecuteJobs - Execute a list of jobs.
   ///
-  /// \param FailingCommands - For non-zero results, this will be a vector of
-  //

Re: [PATCH] D16514: Add -stop-on-failure driver option, and enable it by default for CUDA compiles.

2016-01-28 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: lib/Driver/Driver.cpp:650
@@ -638,3 +649,3 @@
   SmallVector, 4> FailingCommands;
-  C.ExecuteJobs(C.getJobs(), FailingCommands);
+  C.ExecuteJobs(C.getJobs(), /* StopOnFailure = */ false, FailingCommands);
 

tra wrote:
> Why is StopOnFailure is false in this case? Shouldn't it obey command line 
> options, too?
This function is called when the compiler has an internal error or crashes.  
The jobs we're executing here are preprocessor jobs dumping debugging info.  I 
figured we should not stop on failure when outputting that info?


http://reviews.llvm.org/D16514



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


Re: [PATCH] D16564: Fix an issue where backend crashes after frontend emits an error message

2016-01-28 Thread Manman Ren via cfe-commits
manmanren updated this revision to Diff 46301.
manmanren added a comment.

Addressing comments from Akira and Justin.


http://reviews.llvm.org/D16564

Files:
  lib/CodeGen/ModuleBuilder.cpp
  test/CodeGen/target-builtin-error-3.c

Index: test/CodeGen/target-builtin-error-3.c
===
--- test/CodeGen/target-builtin-error-3.c
+++ test/CodeGen/target-builtin-error-3.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -S -verify -o - 
-target-feature +avx
+
+// RUN: not %clang_cc1 %s -triple=x86_64-apple-darwin -emit-obj 
-target-feature +avx 2> %t.err
+// RUN: FileCheck < %t.err %s
+// CHECK: 1 error generated
+
+typedef unsigned short uint16_t;
+typedef long long __m128i __attribute__((__vector_size__(16)));
+typedef float __v8sf __attribute__ ((__vector_size__ (32)));
+typedef float __m256 __attribute__ ((__vector_size__ (32)));
+typedef uint16_t half;
+typedef __attribute__ ((ext_vector_type( 8),__aligned__( 16))) half half8;
+typedef __attribute__ ((ext_vector_type(16),__aligned__( 32))) half half16;
+typedef __attribute__ ((ext_vector_type(16),__aligned__( 2))) half half16U;
+typedef __attribute__ ((ext_vector_type( 8),__aligned__( 32))) float float8;
+typedef __attribute__ ((ext_vector_type(16),__aligned__( 64))) float float16;
+static inline half8 __attribute__((__overloadable__)) convert_half( float8 a ) 
{
+  return __extension__ ({ __m256 __a = (a); 
(__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)__a, (0x00)); }); // 
expected-error {{'__builtin_ia32_vcvtps2ph256' needs target feature f16c}}
+}
+static inline half16 __attribute__((__overloadable__)) convert_half( float16 a 
) {
+  half16 r; 
+  r.lo = convert_half( a.lo); 
+  return r;
+}
+void avx_test( uint16_t *destData, float16 argbF)
+{
+   ((half16U*)destData)[0] = convert_half(argbF);
+}
Index: lib/CodeGen/ModuleBuilder.cpp
===
--- lib/CodeGen/ModuleBuilder.cpp
+++ lib/CodeGen/ModuleBuilder.cpp
@@ -199,15 +199,18 @@
 }
 
 void HandleTranslationUnit(ASTContext &Ctx) override {
+  // Release the Builder when there is no error.
+  if (!Diags.hasErrorOccurred() && Builder)
+Builder->Release();
+
+  // If there are errors before or when releasing the Builder, reset
+  // the module to stop here before invoking the backend.
   if (Diags.hasErrorOccurred()) {
 if (Builder)
   Builder->clear();
 M.reset();
 return;
   }
-
-  if (Builder)
-Builder->Release();
 }
 
 void CompleteTentativeDefinition(VarDecl *D) override {


Index: test/CodeGen/target-builtin-error-3.c
===
--- test/CodeGen/target-builtin-error-3.c
+++ test/CodeGen/target-builtin-error-3.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -S -verify -o - -target-feature +avx
+
+// RUN: not %clang_cc1 %s -triple=x86_64-apple-darwin -emit-obj -target-feature +avx 2> %t.err
+// RUN: FileCheck < %t.err %s
+// CHECK: 1 error generated
+
+typedef unsigned short uint16_t;
+typedef long long __m128i __attribute__((__vector_size__(16)));
+typedef float __v8sf __attribute__ ((__vector_size__ (32)));
+typedef float __m256 __attribute__ ((__vector_size__ (32)));
+typedef uint16_t half;
+typedef __attribute__ ((ext_vector_type( 8),__aligned__( 16))) half half8;
+typedef __attribute__ ((ext_vector_type(16),__aligned__( 32))) half half16;
+typedef __attribute__ ((ext_vector_type(16),__aligned__( 2))) half half16U;
+typedef __attribute__ ((ext_vector_type( 8),__aligned__( 32))) float float8;
+typedef __attribute__ ((ext_vector_type(16),__aligned__( 64))) float float16;
+static inline half8 __attribute__((__overloadable__)) convert_half( float8 a ) {
+  return __extension__ ({ __m256 __a = (a); (__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)__a, (0x00)); }); // expected-error {{'__builtin_ia32_vcvtps2ph256' needs target feature f16c}}
+}
+static inline half16 __attribute__((__overloadable__)) convert_half( float16 a ) {
+  half16 r; 
+  r.lo = convert_half( a.lo); 
+  return r;
+}
+void avx_test( uint16_t *destData, float16 argbF)
+{
+   ((half16U*)destData)[0] = convert_half(argbF);
+}
Index: lib/CodeGen/ModuleBuilder.cpp
===
--- lib/CodeGen/ModuleBuilder.cpp
+++ lib/CodeGen/ModuleBuilder.cpp
@@ -199,15 +199,18 @@
 }
 
 void HandleTranslationUnit(ASTContext &Ctx) override {
+  // Release the Builder when there is no error.
+  if (!Diags.hasErrorOccurred() && Builder)
+Builder->Release();
+
+  // If there are errors before or when releasing the Builder, reset
+  // the module to stop here before invoking the backend.
   if (Diags.hasErrorOccurred()) {
 if (Builder)
   Builder->clear();
 M.reset();
 return;
   }
-
-  if (Builder)
-Builder->Release();
   

Re: [PATCH] D16564: Fix an issue where backend crashes after frontend emits an error message

2016-01-28 Thread Eric Christopher via cfe-commits
I'm also just curious how we got all the way to here without having the
error emitted and compilation stopped?

-eric

On Thu, Jan 28, 2016 at 9:53 AM Justin Bogner  wrote:

> Manman Ren via cfe-commits  writes:
> > manmanren created this revision.
> > manmanren added reviewers: echristo, rafael, ahatanak.
> > manmanren added a subscriber: cfe-commits.
> >
> > It can happen that frontend emits error message when releasing the
> > builder. When that happens, we emit the error message and continue to
> > invoke backend.
> > Backend will then crash.
> >
> > The fix is quite simple, we check for errors after releasing the builder.
> >
> > http://reviews.llvm.org/D16564
> >
> > Files:
> >   lib/CodeGen/ModuleBuilder.cpp
> >   test/CodeGen/target-builtin-error-3.c
> >
> >
> > Index: test/CodeGen/target-builtin-error-3.c
> > ===
> > --- test/CodeGen/target-builtin-error-3.c
> > +++ test/CodeGen/target-builtin-error-3.c
> > @@ -0,0 +1,28 @@
> > +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -S -verify -o -
> -target-feature +avx
> > +
> > +// RUN: not %clang_cc1 %s -triple=x86_64-apple-darwin -emit-obj
> -target-feature +avx 2> %t.err
> > +// RUN: FileCheck < %t.err %s
> > +// CHECK: 1 error generated
> > +
> > +typedef unsigned short uint16_t;
> > +typedef long long __m128i __attribute__((__vector_size__(16)));
> > +typedef float __v8sf __attribute__ ((__vector_size__ (32)));
> > +typedef float __m256 __attribute__ ((__vector_size__ (32)));
> > +typedef uint16_t half;
> > +typedef __attribute__ ((ext_vector_type( 8),__aligned__( 16))) half
> half8;
> > +typedef __attribute__ ((ext_vector_type(16),__aligned__( 32))) half
> half16;
> > +typedef __attribute__ ((ext_vector_type(16),__aligned__( 2))) half
> half16U;
> > +typedef __attribute__ ((ext_vector_type( 8),__aligned__( 32))) float
> float8;
> > +typedef __attribute__ ((ext_vector_type(16),__aligned__( 64))) float
> float16;
> > +static inline half8 __attribute__((__overloadable__)) convert_half(
> float8 a ) {
> > +  return __extension__ ({ __m256 __a = (a);
> (__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)__a, (0x00)); }); //
> expected-error {{'__builtin_ia32_vcvtps2ph256' needs target feature f16c}}
> > +}
> > +static inline half16 __attribute__((__overloadable__)) convert_half(
> float16 a ) {
> > +  half16 r;
> > +  r.lo = convert_half( a.lo);
> > +  return r;
> > +}
> > +void avx_test( uint16_t *destData, float16 argbF)
> > +{
> > +   ((half16U*)destData)[0] = convert_half(argbF);
> > +}
> > Index: lib/CodeGen/ModuleBuilder.cpp
> > ===
> > --- lib/CodeGen/ModuleBuilder.cpp
> > +++ lib/CodeGen/ModuleBuilder.cpp
> > @@ -208,6 +208,14 @@
> >
> >if (Builder)
> >  Builder->Release();
> > +
> > +  // Builder->Release can cause diagnostics to be generated.
>
> This comment's a bit confusing. Isn't it more like "If errors occurred
> while building the module, we need to stop here before invoking the
> backend", or something like that?
>
> > +  if (Diags.hasErrorOccurred()) {
> > +if (Builder)
> > +  Builder->clear();
> > +M.reset();
> > +return;
> > +  }
> >  }
> >
> >  void CompleteTentativeDefinition(VarDecl *D) override {
> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15603: [OpenCL] Pipe type support

2016-01-28 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Yes, I see that it happens only for some vector types. The CodeGen follows 
quite different paths for both targets. And in the case of s390x-linux-gnu it 
ends up in ABIArgInfo::Indirect case of the second switch statement where an 
additional pointer will be added here:

  ArgTypes[FirstIRArg] = LTy->getPointerTo();

I don't have enough knowledge at the moment of this ABI to tell whether it's 
Ok, but the generated code appears to be completely wrong.

As a temporary workaround to fix your build bot, I suggest you to add '-triple 
x86_64-linux-gnu' into RUN line of the test:

  -// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
  +// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - -triple 
x86_64-linux-gnu %s | FileCheck %s

It has already been done before in OpenCL tests as we don't support most of 
targets anyways.

In the meantime, I will try to see if there could be a better fix for this.


http://reviews.llvm.org/D15603



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


LLVM buildmaster will go off-line today after 5 PM Pacific for short time

2016-01-28 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be taken off-line today after 5 PM Pacific for short
time for maintenance and also will be updated.
Thank you for understanding.

Thanks

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


Re: [PATCH] D16664: [CUDA] Generate CUDA's printf alloca in its function's entry block.

2016-01-28 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: lib/CodeGen/CGCUDABuiltin.cpp:105-108
@@ -104,2 +104,6 @@
   } else {
-BufferPtr = Builder.Insert(new llvm::AllocaInst(
+// Insert our alloca not into the current BB, but into the function's entry
+// block.  This is important because nvvm doesn't support alloca -- if we
+// put the alloca anywhere else, llvm may eventually output
+// stacksave/stackrestore intrinsics, which cause our nvvm backend to 
choke.
+auto *Alloca = new llvm::AllocaInst(

The fact that allocas for local variables should always go in the entry block 
is pretty widespread cultural knowledge in LLVM and clang. Most readers aren't 
going to need this comment, unless you expect that people working on CUDA won't 
have that background. Plus, if you use CreateTempAlloca, there won't be any 
question about which insert point should be used.


Comment at: lib/CodeGen/CGCUDABuiltin.cpp:109
@@ -106,1 +108,3 @@
+// stacksave/stackrestore intrinsics, which cause our nvvm backend to 
choke.
+auto *Alloca = new llvm::AllocaInst(
 llvm::Type::getInt8Ty(Ctx), llvm::ConstantInt::get(Int32Ty, BufSize),

You can still use CreateTempAlloca by making an `[i8 x N]` LLVM type. You'll 
have to use CreateStructGEP below for forming GEPs. Overall I think that'd be 
nicer, since you don't need to worry about insertion at all.


http://reviews.llvm.org/D16664



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


Re: [PATCH] D15603: [OpenCL] Pipe type support

2016-01-28 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Btw, just to be clear in my previous comment I was referring to the 2nd switch 
statement in CodeGenTypes::GetFunctionType that contains the line:

  ArgTypes[FirstIRArg] = LTy->getPointerTo();


http://reviews.llvm.org/D15603



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


Re: [PATCH] D16478: Always build a new TypeSourceInfo for function templates with parameters

2016-01-28 Thread Nico Weber via cfe-commits
thakis added a comment.

rnk, I added you because you hacked in this general area a while ago in 
r187528. Since Richard is out, do you think you can take a look?


http://reviews.llvm.org/D16478



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


Re: [PATCH] D16664: [CUDA] Generate CUDA's printf alloca in its function's entry block.

2016-01-28 Thread Eric Christopher via cfe-commits
echristo added inline comments.


Comment at: lib/CodeGen/CGCUDABuiltin.cpp:109
@@ -106,1 +108,3 @@
+// stacksave/stackrestore intrinsics, which cause our nvvm backend to 
choke.
+auto *Alloca = new llvm::AllocaInst(
 llvm::Type::getInt8Ty(Ctx), llvm::ConstantInt::get(Int32Ty, BufSize),

rnk wrote:
> You can still use CreateTempAlloca by making an `[i8 x N]` LLVM type. You'll 
> have to use CreateStructGEP below for forming GEPs. Overall I think that'd be 
> nicer, since you don't need to worry about insertion at all.
+1 :)


Comment at: lib/CodeGen/CGCUDABuiltin.cpp:112
@@ +111,3 @@
+BufAlign, "printf_arg_buf");
+Alloca->insertAfter(AllocaInsertPt);
+BufferPtr = Alloca;

Also you'd have wanted to insert it before anyhow. 


http://reviews.llvm.org/D16664



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


Re: [PATCH] D15999: Adding doxygen comments to the LLVM intrinsics (part 2, _wmmintrin_pclmul.h)

2016-01-28 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a reviewer: echristo.
echristo added a comment.
This revision is now accepted and ready to land.

Yep. As I said, I expect to be on the losing side of that argument - just too 
much prior art :)

-eric


http://reviews.llvm.org/D15999



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


Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-28 Thread Rong Xu via cfe-commits
xur updated this revision to Diff 46303.
xur added a comment.

Integrated most recently comments/suggestions from David and Sean.

Thanks,

-Rong


http://reviews.llvm.org/D15829

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenPGO.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/Inputs/pgotest.profraw
  test/CodeGen/pgo-instrumentation.c

Index: test/CodeGen/pgo-instrumentation.c
===
--- /dev/null
+++ test/CodeGen/pgo-instrumentation.c
@@ -0,0 +1,28 @@
+// Test if PGO instrumentation and use pass are invoked.
+//
+// Ensure Pass PGOInstrumentationGenPass is invoked.
+// RUN: %clang -O2 -c -Xclang -fprofile-instrument=LLVM -fprofile-instr-generate %s -mllvm -debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=CHECK-PGOGENPASS-INVOKED-INSTR-GEN
+// CHECK-PGOGENPASS-INVOKED-INSTR-GEN: PGOInstrumentationGenPass
+//
+// Ensure Pass PGOInstrumentationGenPass is invoked.
+// RUN: %clang -O2 -c -Xclang -fprofile-instrument=LLVM -fprofile-generate %s -mllvm -debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=CHECK-PGOGENPASS-INVOKED-GEN
+// CHECK-PGOGENPASS-INVOKED-GEN: PGOInstrumentationGenPass
+//
+// Ensure Pass PGOInstrumentationGenPass is not invoked.
+// RUN: %clang -O2 -c -Xclang -fprofile-instrument=Clang -fprofile-instr-generate %s -mllvm -debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=CHECK-PGOGENPASS-INVOKED-INSTR-GEN-CLANG
+// CHECK-PGOGENPASS-INVOKED-INSTR-GEN-CLANG-NOT: PGOInstrumentationGenPass
+//
+// Ensure Pass PGOInstrumentationUsePass is invoked.
+// RUN: llvm-profdata merge -o %t.profdata %S/Inputs/pgotest.profraw
+// RUN: %clang -O2 -c -Xclang -fprofile-instrument=LLVM -fprofile-instr-use=%t.profdata %s -mllvm -debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=CHECK-PGOUSEPASS-INVOKED-INSTR-USE
+// CHECK-PGOUSEPASS-INVOKED-INSTR-USE: PGOInstrumentationUsePass
+//
+// Ensure Pass PGOInstrumentationUsePass is invoked.
+// RUN: llvm-profdata merge -o %t.profdata %S/Inputs/pgotest.profraw
+// RUN: %clang -O2 -c -Xclang -fprofile-instrument=LLVM -fprofile-use=%t.profdata %s -mllvm -debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=CHECK-PGOUSEPASS-INVOKED-USE
+// CHECK-PGOUSEPASS-INVOKED-USE: PGOInstrumentationUsePass
+//
+// Ensure Pass PGOInstrumentationUsePass is not invoked.
+// RUN: llvm-profdata merge -o %t.profdata %S/Inputs/pgotest.profraw
+// RUN: %clang -O2 -c -Xclang -fprofile-instrument=Clang -fprofile-use=%t.profdata %s -mllvm -debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=CHECK-PGOUSEPASS-INVOKED-USE-CLANG
+// CHECK-PGOUSEPASS-INVOKED-USE-CLANG-NOT: PGOInstrumentationUsePass
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -477,8 +477,29 @@
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
   Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
   Opts.SampleProfileFile = Args.getLastArgValue(OPT_fprofile_sample_use_EQ);
-  Opts.ProfileInstrGenerate = Args.hasArg(OPT_fprofile_instr_generate) ||
-  Args.hasArg(OPT_fprofile_instr_generate_EQ);
+
+  enum PGOInstrumentor { Unknown, Clang, LLVM };
+  if (Arg *A = Args.getLastArg(OPT_fprofile_instrument_EQ)) {
+StringRef Value = A->getValue();
+PGOInstrumentor Method = llvm::StringSwitch(Value)
+ .Case("Clang", Clang)
+ .Case("LLVM", LLVM)
+ .Default(Unknown);
+switch (Method) {
+case LLVM:
+  Opts.setProfileInstr(CodeGenOptions::ProfileIRInstr);
+  break;
+case Clang:
+  Opts.setProfileInstr(CodeGenOptions::ProfileClangInstr);
+  break;
+case Unknown:
+default:
+  Diags.Report(diag::err_drv_invalid_pgo_instrumentor)
+  << A->getAsString(Args) << Value;
+  break;
+}
+  }
+
   Opts.InstrProfileOutput = Args.getLastArgValue(OPT_fprofile_instr_generate_EQ);
   Opts.InstrProfileInput = Args.getLastArgValue(OPT_fprofile_instr_use_EQ);
   Opts.CoverageMapping =
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3230,8 +3230,9 @@
   llvm::sys::path::append(Path, "default.profraw");
   CmdArgs.push_back(
   Args.MakeArgString(Twine("-fprofile-instr-generate=") + Path));
-} else
-  Args.AddAllArgs(CmdArgs, options::OPT_fprofile_instr_generate);
+}
+// The default is to use Clang Instrumentation.
+CmdArgs.push_back("-fprofile-instrument=Clang");

Re: [PATCH] D16564: Fix an issue where backend crashes after frontend emits an error message

2016-01-28 Thread Manman Ren via cfe-commits
FYI :)

Here is the back trace when emitting the error:

  * frame #0: 0x00010271ea30
clang`clang::CodeGen::CodeGenFunction::EmitBuiltinExpr(this=0x7fff5fbf8c58,
FD=0x00010f214260, BuiltinID=1483, E=0x00010f214500,
ReturnValue=ReturnValueSlot at 0x7fff5fbf5fe0) + 49360 at
CGBuiltin.cpp:2033
frame #1: 0x00010283f76f
clang`clang::CodeGen::CodeGenFunction::EmitCallExpr(this=0x7fff5fbf8c58,
E=0x00010f214500, ReturnValue=ReturnValueSlot at 0x7fff5fbf6990) +
447 at CGExpr.cpp:3506
frame #2: 0x00010288ae23 clang`(anonymous
namespace)::ScalarExprEmitter::VisitCallExpr(this=0x7fff5fbf7380,
E=0x00010f214500) + 163 at CGExprScalar.cpp:326
frame #3: 0x000102885d52
clang`clang::StmtVisitorBase::Visit(this=0x7fff5fbf7380, S=0x00010f214500) + 2866
at StmtNodes.inc:311
frame #4: 0x00010287f479 clang`(anonymous
namespace)::ScalarExprEmitter::Visit(this=0x7fff5fbf7380,
E=0x00010f214500) + 73 at CGExprScalar.cpp:205
frame #5: 0x000102892a4f clang`(anonymous
namespace)::ScalarExprEmitter::VisitCastExpr(this=0x7fff5fbf7380,
CE=0x00010f214548) + 655 at CGExprScalar.cpp:1391
frame #6: 0x0001028927ae clang`(anonymous
namespace)::ScalarExprEmitter::VisitExplicitCastExpr(this=0x7fff5fbf7380,
E=0x00010f214548) + 62 at CGExprScalar.cpp:318
frame #7: 0x00010288af48
clang`clang::StmtVisitorBase::VisitCStyleCastExpr(this=0x7fff5fbf7380,
S=0x00010f214548) + 40 at StmtNodes.inc:351
frame #8: 0x000102885dde
clang`clang::StmtVisitorBase::Visit(this=0x7fff5fbf7380, S=0x00010f214548) + 3006
at StmtNodes.inc:351
frame #9: 0x00010287f479 clang`(anonymous
namespace)::ScalarExprEmitter::Visit(this=0x7fff5fbf7380,
E=0x00010f214548) + 73 at CGExprScalar.cpp:205
frame #10: 0x00010287f3e0
clang`clang::CodeGen::CodeGenFunction::EmitScalarExpr(this=0x7fff5fbf8c58,
E=0x00010f214548, IgnoreResultAssign=false) + 192 at
CGExprScalar.cpp:3463
frame #11: 0x000102828146
clang`clang::CodeGen::CodeGenFunction::EmitAnyExprToMem(this=0x7fff5fbf8c58,
E=0x00010f214548, Location=Address at 0x7fff5fbf7630, Quals=(Mask =
0), IsInit=false) + 502 at CGExpr.cpp:188
frame #12: 0x000102969778
clang`clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(this=0x7fff5fbf8c58,
S=0x00010f214570, GetLast=true, AggSlot=AggValueSlot at
0x7fff5fbf7700) + 552 at CGStmt.cpp:327
frame #13: 0x0001029688e9
clang`clang::CodeGen::CodeGenFunction::EmitCompoundStmt(this=0x7fff5fbf8c58,
S=0x00010f214570, GetLast=true, AggSlot=AggValueSlot at
0x7fff5fbf77d0) + 297 at CGStmt.cpp:293
frame #14: 0x00010288e9e5 clang`(anonymous
namespace)::ScalarExprEmitter::VisitStmtExpr(this=0x7fff5fbf8410,
E=0x00010f214598) + 197 at CGExprScalar.cpp:1598
frame #15: 0x00010288646e
clang`clang::StmtVisitorBase::Visit(this=0x7fff5fbf8410, S=0x00010f214598) + 4686
at StmtNodes.inc:735
frame #16: 0x00010287f479 clang`(anonymous
namespace)::ScalarExprEmitter::Visit(this=0x7fff5fbf8410,
E=0x00010f214598) + 73 at CGExprScalar.cpp:205
frame #17: 0x000102889df0 clang`(anonymous
namespace)::ScalarExprEmitter::VisitUnaryExtension(this=0x7fff5fbf8410,
E=0x00010f2145b8) + 48 at CGExprScalar.cpp:382
frame #18: 0x0001028857bb
clang`clang::StmtVisitorBase::Visit(this=0x7fff5fbf8410, S=0x00010f2145b8) + 1435
at StmtVisitor.h:96
frame #19: 0x00010287f479 clang`(anonymous
namespace)::ScalarExprEmitter::Visit(this=0x7fff5fbf8410,
E=0x00010f2145b8) + 73 at CGExprScalar.cpp:205
frame #20: 0x000102892a4f clang`(anonymous
namespace)::ScalarExprEmitter::VisitCastExpr(this=0x7fff5fbf8410,
CE=0x00010f2145d8) + 655 at CGExprScalar.cpp:1391
frame #21: 0x00010288b098
clang`clang::StmtVisitorBase::VisitImplicitCastExpr(this=0x7fff5fbf8410,
S=0x00010f2145d8) + 40 at StmtNodes.inc:405
frame #22: 0x000102885ea2
clang`clang::StmtVisitorBase::Visit(this=0x7fff5fbf8410, S=0x00010f2145d8) + 3202
at StmtNodes.inc:405
frame #23: 0x00010287f479 clang`(anonymous
namespace)::ScalarExprEmitter::Visit(this=0x7fff5fbf8410,
E=0x00010f2145d8) + 73 at CGExprScalar.cpp:205
frame #24: 0x00010287f3e0
clang`clang::CodeGen::CodeGenFunction::EmitScalarExpr(this=0x7fff5fbf8c58,
E=0x00010f2145d8, IgnoreResultAssign=false) + 192 at
CGExprScalar.cpp:3463
frame #25: 0x00010295e9df
clang`clang::CodeGen::CodeGenFunction::EmitReturnStmt(this=0x7fff5fbf8c58,
S=0x00010f2145f0) + 927 at CGStmt.cpp:979
frame #26: 0x00010295c611
clang`clang::CodeGen::CodeGenFunction::EmitStmt(this=0x7fff5fbf8c58,
S=0x00010f2145f0) + 993 at CGStmt.cpp:139
frame #27: 0x0001029695d5
clang`clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(this=0x7fff5fbf8c58,
S=0x00010f214608, GetLast=false, AggSlot=AggValueSlot at
0x000

Re: [PATCH] D16514: Add -stop-on-failure driver option, and enable it by default for CUDA compiles.

2016-01-28 Thread Eric Christopher via cfe-commits
echristo added a comment.

In general it feels like keeping 2 errors might make the most sense:

(Using a multiarch build rather than a cuda command line, but it should still 
be the same behavior for consistency)

t.c:

#if _NOT_ARCH4_
#error "aiee!"
#endif

clang -arch arch1 -arch arch2 -arch arch3 -arch arch4 t.c

seems like it might be nice to get 3 errors here rather than a single one and 
fixing that single one, then getting another one, etc. or realizing what the 
error is here.

I don't feel strongly about this, but I'm still uncertain as to why we want to 
make things more complicated here :)

-eric


http://reviews.llvm.org/D16514



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


Re: [PATCH] D16514: Add -stop-on-failure driver option, and enable it by default for CUDA compiles.

2016-01-28 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM.



Comment at: lib/Driver/Driver.cpp:652
@@ -640,3 +651,3 @@
   SmallVector, 4> FailingCommands;
-  C.ExecuteJobs(C.getJobs(), FailingCommands);
+  C.ExecuteJobs(C.getJobs(), /* StopOnFailure = */ false, FailingCommands);
 

As far as I can tell, we don't do anything interesting if we've detected that 
*any* of the commands have failed. That suggests that doing anything beyond the 
first failing command does not do us any good. That would suggest that we may 
really want StopOnFailure=true here.

'false' would preserve current behavior, though.

In either case I'm OK with a constant here.


http://reviews.llvm.org/D16514



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


Re: [PATCH] D16478: Always build a new TypeSourceInfo for function templates with parameters

2016-01-28 Thread Reid Kleckner via cfe-commits
rnk added a comment.

The fact that an instantiated type might point to decls from the template 
pattern seems like expected behavior. The parts of the template that are the 
same are supposed to be shared.

Can we dig in to what is going wrong in parent map construction?


http://reviews.llvm.org/D16478



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


Re: [PATCH] D16478: Always build a new TypeSourceInfo for function templates with parameters

2016-01-28 Thread Nico Weber via cfe-commits
thakis added a comment.

In http://reviews.llvm.org/D16478#338653, @rnk wrote:

> The fact that an instantiated type might point to decls from the template 
> pattern seems like expected behavior. The parts of the template that are the 
> same are supposed to be shared.
>
> Can we dig in to what is going wrong in parent map construction?


"RecursiveASTVisitor::TraverseFunctionHelper() traverses a function's 
ParmVarDecls by going to the function's getTypeSourceInfo if it exists, and `
DEF_TRAVERSE_TYPELOC(FunctionProtoType` then goes to the function's 
ParmVarDecls." was my attempt to do that. I guess I can expand this a bit with 
code snippets.

The parent map uses a RecursiveASTVisitor to build parents: It keeps a stack of 
nodes it has seen so far, and when something gets visited, it marks 
parent[something] = seenstack.top(). RecursiveASTVisitor does this for 
functions:

  DEF_TRAVERSE_DECL(FunctionDecl, {
// We skip decls_begin/decls_end, which are already covered by
// TraverseFunctionHelper().
return TraverseFunctionHelper(D);
  })

TraverseFunctionHelper goes to the TypeSource if it exists to visit the 
parameter decls:

  bool RecursiveASTVisitor::TraverseFunctionHelper(FunctionDecl *D) {
// ...
if (TypeSourceInfo *TSI = D->getTypeSourceInfo()) {
  TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));

The TypeLoc then goes to the param's decl if available:

  DEF_TRAVERSE_TYPELOC(FunctionProtoType, {
TRY_TO(TraverseTypeLoc(TL.getReturnLoc()));
  
const FunctionProtoType *T = TL.getTypePtr();
  
for (unsigned I = 0, E = TL.getNumParams(); I != E; ++I) {
  if (TL.getParam(I)) {

So when the instantiated CXXMethodDecl for quantizedSize is visited, this goes 
and visits the ParmDecls from the template CXXMethodDecl, not from the 
instantiated one. Hence, the instantiated ParmDecl for count never gets a 
parent assigned (since it's never visited).

So at least RecursiveASTVisitor didn't expect the current behavior.


http://reviews.llvm.org/D16478



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


Re: [PATCH] D13420: Fix deduction of __atomic_load's parameter types.

2016-01-28 Thread David Majnemer via cfe-commits
majnemer accepted this revision.
majnemer added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D13420



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


[libcxx] r259091 - Remove autoconf support.

2016-01-28 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Thu Jan 28 15:00:21 2016
New Revision: 259091

URL: http://llvm.org/viewvc/llvm-project?rev=259091&view=rev
Log:
Remove autoconf support.

Differential revision: http://reviews.llvm.org/D16651

Removed:
libcxx/trunk/Makefile

Removed: libcxx/trunk/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/Makefile?rev=259090&view=auto
==
--- libcxx/trunk/Makefile (original)
+++ libcxx/trunk/Makefile (removed)
@@ -1,56 +0,0 @@
-##
-# libc++ Makefile
-##
-
-SRCDIRS = .
-DESTDIR = $(DSTROOT)
-
-OBJROOT=.
-SYMROOT=.
-export TRIPLE=-apple-
-
-ifeq (,$(RC_INDIGO))
-   INSTALL_PREFIX=""
-else
-   INSTALL_PREFIX="$(SDKROOT)"
-endif
-INSTALL_DIR=$(DSTROOT)/$(INSTALL_PREFIX)
-
-.PHONY: help installsrc clean installheaders install
-
-help::
-   @echo "Use make install DSTROOT="
-
-installsrc:: $(SRCROOT)
-
-   ditto $(SRCDIRS)/include $(SRCROOT)/include
-   ditto $(SRCDIRS)/lib $(SRCROOT)/lib
-   ditto $(SRCDIRS)/src $(SRCROOT)/src
-   ditto $(SRCDIRS)/Makefile $(SRCROOT)/Makefile
-
-clean::
-
-# The installheaders target is used by clang's runtime/libcxx makefile.
-installheaders::
-   mkdir -p $(HEADER_DIR)/c++/v1/ext
-   (cd $(SRCDIRS)/include && \
- tar cf - --exclude=".*" --exclude=support \
-  --exclude=CMakeLists.txt *) | \
- (cd $(HEADER_DIR)/c++/v1 && tar xf -)
-   chmod 755 $(HEADER_DIR)/c++/v1
-   chmod 644 $(HEADER_DIR)/c++/v1/*
-   chmod 755 $(HEADER_DIR)/c++/v1/ext
-   chmod 644 $(HEADER_DIR)/c++/v1/ext/*
-   chmod 755 $(HEADER_DIR)/c++/v1/experimental
-   chmod 644 $(HEADER_DIR)/c++/v1/experimental/*
-
-install::
-
-   cd lib && ./buildit
-   ditto lib/libc++.1.dylib $(SYMROOT)/usr/lib/libc++.1.dylib
-   cd lib && dsymutil -o $(SYMROOT)/libc++.1.dylib.dSYM \
- $(SYMROOT)/usr/lib/libc++.1.dylib
-   mkdir -p $(INSTALL_DIR)/usr/lib
-   strip -S -o $(INSTALL_DIR)/usr/lib/libc++.1.dylib \
- $(SYMROOT)/usr/lib/libc++.1.dylib
-   cd $(INSTALL_DIR)/usr/lib && ln -s libc++.1.dylib libc++.dylib


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


RE: [libcxx] r259046 - [libcxx] Work around for clang calling GAS after having already failed.

2016-01-28 Thread Daniel Sanders via cfe-commits
Thanks. Merged in r259092.

From: hwennb...@google.com [hwennb...@google.com] on behalf of Hans Wennborg 
[h...@chromium.org]
Sent: 28 January 2016 17:56
To: Daniel Sanders
Cc: cfe-commits@lists.llvm.org; e...@efcs.ca
Subject: Re: [libcxx] r259046 - [libcxx] Work around for clang calling GAS 
after having already failed.

Yes, go ahead.

Thanks,
Hans

On Thu, Jan 28, 2016 at 5:57 AM, Daniel Sanders
 wrote:
> Hi Hans,
>
> Is it ok to merge this into 3.8? Eric Fiselier has already approved on the 
> review.
> 
> From: cfe-commits [cfe-commits-boun...@lists.llvm.org] on behalf of Daniel 
> Sanders via cfe-commits [cfe-commits@lists.llvm.org]
> Sent: 28 January 2016 13:49
> To: cfe-commits@lists.llvm.org
> Subject: [libcxx] r259046 - [libcxx] Work around for clang calling GAS after 
> having already failed.
>
> Author: dsanders
> Date: Thu Jan 28 07:49:33 2016
> New Revision: 259046
>
> URL: http://llvm.org/viewvc/llvm-project?rev=259046&view=rev
> Log:
> [libcxx] Work around for clang calling GAS after having already failed.
>
> Summary:
> This is a workaround to a clang bug which causes libcxx tests to fail in the 
> 3.8
> release. The clang bug is currently being investigated. It seems that clang
> does not stop after frontend errors when using -verify and -fno-integrated-as
> (or when this is the default). This patch adds -fsyntax-only to prevent GAS
> from being called, fixing the libcxx failures.
>
> PR26277
>
> Patch by Eric Fiselier
>
> Reviewers: mclow.lists, hans, EricWF
>
> Subscribers: cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D16584
>
> Modified:
> libcxx/trunk/test/libcxx/test/format.py
>
> Modified: libcxx/trunk/test/libcxx/test/format.py
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/format.py?rev=259046&r1=259045&r2=259046&view=diff
> ==
> --- libcxx/trunk/test/libcxx/test/format.py (original)
> +++ libcxx/trunk/test/libcxx/test/format.py Thu Jan 28 07:49:33 2016
> @@ -161,7 +161,7 @@ class LibcxxTestFormat(object):
> 'expected-error', 'expected-no-diagnostics']
>  use_verify = self.use_verify_for_fail and \
>   any([tag in contents for tag in verify_tags])
> -extra_flags = []
> +extra_flags = ['-fsyntax-only']
>  if use_verify:
>  extra_flags += ['-Xclang', '-verify',
>  '-Xclang', '-verify-ignore-unexpected=note']
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r259092 - Merging r259046:

2016-01-28 Thread Daniel Sanders via cfe-commits
Author: dsanders
Date: Thu Jan 28 15:03:16 2016
New Revision: 259092

URL: http://llvm.org/viewvc/llvm-project?rev=259092&view=rev
Log:
Merging r259046:

r259046 | dsanders | 2016-01-28 13:49:33 + (Thu, 28 Jan 2016) | 18 lines

[libcxx] Work around for clang calling GAS after having already failed.

Summary:
This is a workaround to a clang bug which causes libcxx tests to fail in the 3.8
release. The clang bug is currently being investigated. It seems that clang
does not stop after frontend errors when using -verify and -fno-integrated-as
(or when this is the default). This patch adds -fsyntax-only to prevent GAS
from being called, fixing the libcxx failures.

PR26277

Patch by Eric Fiselier

Reviewers: mclow.lists, hans, EricWF

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D16584


Modified:
libcxx/branches/release_38/test/libcxx/test/format.py

Modified: libcxx/branches/release_38/test/libcxx/test/format.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_38/test/libcxx/test/format.py?rev=259092&r1=259091&r2=259092&view=diff
==
--- libcxx/branches/release_38/test/libcxx/test/format.py (original)
+++ libcxx/branches/release_38/test/libcxx/test/format.py Thu Jan 28 15:03:16 
2016
@@ -161,7 +161,7 @@ class LibcxxTestFormat(object):
'expected-error', 'expected-no-diagnostics']
 use_verify = self.use_verify_for_fail and \
  any([tag in contents for tag in verify_tags])
-extra_flags = []
+extra_flags = ['-fsyntax-only']
 if use_verify:
 extra_flags += ['-Xclang', '-verify',
 '-Xclang', '-verify-ignore-unexpected=note']


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


Re: [PATCH] D16514: Add -stop-on-failure driver option, and enable it by default for CUDA compiles.

2016-01-28 Thread Justin Lebar via cfe-commits
jlebar added a comment.

In http://reviews.llvm.org/D16514#338631, @echristo wrote:

> In general it feels like keeping 2 errors might make the most sense:
>
> #if _NOT_ARCH4_
>  #error "aiee!"
>  #endif
>
> clang -arch arch1 -arch arch2 -arch arch3 -arch arch4 t.c
>
> seems like it might be nice to get 3 errors here rather than a single one and 
> fixing that single one, then getting another one, etc. or realizing what the 
> error is here.


Yes, this patch makes that case worse.

But I suspect errors that apply to some but not all archs will be far less 
common than errors that apply to all arches -- regular C++ errors like missing 
a semicolon or whatever.  It feels pretty overwhelming to output N copies of 
every error in those cases, especially when you consider multipage template 
errors.

In addition, iirc there's no separation between errors outputted for different 
archs, so it really looks like we're just outputting multiple copies of the 
errors for fun.

> I don't feel strongly about this, but I'm still uncertain as to why we want 
> to make things more complicated here :)


The other reason, which is less important, is that when you have one arch and 
ptxas fails -- which, it shouldn't, but we're not good enough to catch 
everything yet, and likely won't be for some time -- the error you get is

  ptxas: foo is not defined
  *FATAL ERROR*: fatbinary failed, /tmp/bar.cubin does not exist.

I'd like not to display that second line, since it hides the actual problem.  
Once you get used to it, it's not a big deal, but it tripped me up for a few 
minutes, and I'm the one who added the call to ptxas.



Comment at: lib/Driver/Driver.cpp:652
@@ -640,3 +651,3 @@
   SmallVector, 4> FailingCommands;
-  C.ExecuteJobs(C.getJobs(), FailingCommands);
+  C.ExecuteJobs(C.getJobs(), /* StopOnFailure = */ false, FailingCommands);
 

tra wrote:
> As far as I can tell, we don't do anything interesting if we've detected that 
> *any* of the commands have failed. That suggests that doing anything beyond 
> the first failing command does not do us any good. That would suggest that we 
> may really want StopOnFailure=true here.
> 
> 'false' would preserve current behavior, though.
> 
> In either case I'm OK with a constant here.
Sorry, I think I'm misunderstanding something.  Would you mind rephrasing this?

> As far as I can tell, we don't do anything interesting if we've detected that 
> *any* of the commands have failed.  That suggests that doing anything beyond 
> the first failing command does not do us any good.

The scenario I thought this change applied to was:

External tool crashes during a call to ExecuteJobs() (not this one).  We now 
want to output preprocessed inputs, so we run this code, which again calls 
ExecuteJobs(), but these jobs only run the preprocessor on the inputs.

Now suppose one of those preprocessor jobs fails.  Maybe it has a bad 
preprocessor directive, or maybe #error would be enough.  It seems to me in 
this case that we should continue running the other preprocessor jobs, so we 
dump as much debug info as we can.

Note that if the StopOnFailure flag is false, afaict it's entirely possible for 
us to have two inputs, one of which has a pp error and the other of which 
causes a compiler crash -- if we stopped on failure here, we wouldn't output 
anything for the second input, which is the one we're interested in.

Sorry again, I'm sure I'm missing something.


http://reviews.llvm.org/D16514



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


r259095 - Implementation of PS4 ABI, Round 1

2016-01-28 Thread Sunil Srivastava via cfe-commits
Author: ssrivastava
Date: Thu Jan 28 15:36:31 2016
New Revision: 259095

URL: http://llvm.org/viewvc/llvm-project?rev=259095&view=rev
Log:
Implementation of PS4 ABI, Round 1
Added a test to safeguard linux ABI.

Differential Revision: http://reviews.llvm.org/D16607

Modified:
cfe/trunk/test/Sema/bitfield-layout.c

Modified: cfe/trunk/test/Sema/bitfield-layout.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/bitfield-layout.c?rev=259095&r1=259094&r2=259095&view=diff
==
--- cfe/trunk/test/Sema/bitfield-layout.c (original)
+++ cfe/trunk/test/Sema/bitfield-layout.c Thu Jan 28 15:36:31 2016
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=i686-apple-darwin9
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=arm-linux-gnueabihf
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=aarch64-linux-gnu
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=x86_64-pc-linux-gnu
 // expected-no-diagnostics
 #include 
 
@@ -190,7 +191,7 @@ struct g11 {
   __attribute__((aligned(1))) long long b : 62;
   char c;
 };
-#if defined(__arm__) || defined(__aarch64__)
+#if defined(__arm__) || defined(__aarch64__) || defined(__x86_64__)
 CHECK_SIZE(struct, g11, 24);
 CHECK_ALIGN(struct, g11, 8);
 CHECK_OFFSET(struct, g11, c, 16);
@@ -218,6 +219,10 @@ struct g13 {
 CHECK_SIZE(struct, g13, 16);
 CHECK_ALIGN(struct, g13, 8);
 CHECK_OFFSET(struct, g13, c, 8);
+#elif (__x86_64__)
+CHECK_SIZE(struct, g13, 9);
+CHECK_ALIGN(struct, g13, 1);
+CHECK_OFFSET(struct, g13, c, 8);
 #else
 CHECK_SIZE(struct, g13, 5);
 CHECK_ALIGN(struct, g13, 1);
@@ -233,6 +238,10 @@ struct __attribute__((packed)) g14 {
 CHECK_SIZE(struct, g14, 16);
 CHECK_ALIGN(struct, g14, 8);
 CHECK_OFFSET(struct, g14, c, 8);
+#elif (__x86_64__)
+CHECK_SIZE(struct, g14, 9);
+CHECK_ALIGN(struct, g14, 1);
+CHECK_OFFSET(struct, g14, c, 8);
 #else
 CHECK_SIZE(struct, g14, 5);
 CHECK_ALIGN(struct, g14, 1);


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


Re: [PATCH] D16607: Implementation of PS4 ABI, round 1

2016-01-28 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL259095: Implementation of PS4 ABI, Round 1 (authored by 
ssrivastava).

Changed prior to commit:
  http://reviews.llvm.org/D16607?vs=46060&id=46310#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16607

Files:
  cfe/trunk/test/Sema/bitfield-layout.c

Index: cfe/trunk/test/Sema/bitfield-layout.c
===
--- cfe/trunk/test/Sema/bitfield-layout.c
+++ cfe/trunk/test/Sema/bitfield-layout.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=i686-apple-darwin9
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=arm-linux-gnueabihf
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=aarch64-linux-gnu
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=x86_64-pc-linux-gnu
 // expected-no-diagnostics
 #include 
 
@@ -190,7 +191,7 @@
   __attribute__((aligned(1))) long long b : 62;
   char c;
 };
-#if defined(__arm__) || defined(__aarch64__)
+#if defined(__arm__) || defined(__aarch64__) || defined(__x86_64__)
 CHECK_SIZE(struct, g11, 24);
 CHECK_ALIGN(struct, g11, 8);
 CHECK_OFFSET(struct, g11, c, 16);
@@ -218,6 +219,10 @@
 CHECK_SIZE(struct, g13, 16);
 CHECK_ALIGN(struct, g13, 8);
 CHECK_OFFSET(struct, g13, c, 8);
+#elif (__x86_64__)
+CHECK_SIZE(struct, g13, 9);
+CHECK_ALIGN(struct, g13, 1);
+CHECK_OFFSET(struct, g13, c, 8);
 #else
 CHECK_SIZE(struct, g13, 5);
 CHECK_ALIGN(struct, g13, 1);
@@ -233,6 +238,10 @@
 CHECK_SIZE(struct, g14, 16);
 CHECK_ALIGN(struct, g14, 8);
 CHECK_OFFSET(struct, g14, c, 8);
+#elif (__x86_64__)
+CHECK_SIZE(struct, g14, 9);
+CHECK_ALIGN(struct, g14, 1);
+CHECK_OFFSET(struct, g14, c, 8);
 #else
 CHECK_SIZE(struct, g14, 5);
 CHECK_ALIGN(struct, g14, 1);


Index: cfe/trunk/test/Sema/bitfield-layout.c
===
--- cfe/trunk/test/Sema/bitfield-layout.c
+++ cfe/trunk/test/Sema/bitfield-layout.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=i686-apple-darwin9
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=arm-linux-gnueabihf
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=aarch64-linux-gnu
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=x86_64-pc-linux-gnu
 // expected-no-diagnostics
 #include 
 
@@ -190,7 +191,7 @@
   __attribute__((aligned(1))) long long b : 62;
   char c;
 };
-#if defined(__arm__) || defined(__aarch64__)
+#if defined(__arm__) || defined(__aarch64__) || defined(__x86_64__)
 CHECK_SIZE(struct, g11, 24);
 CHECK_ALIGN(struct, g11, 8);
 CHECK_OFFSET(struct, g11, c, 16);
@@ -218,6 +219,10 @@
 CHECK_SIZE(struct, g13, 16);
 CHECK_ALIGN(struct, g13, 8);
 CHECK_OFFSET(struct, g13, c, 8);
+#elif (__x86_64__)
+CHECK_SIZE(struct, g13, 9);
+CHECK_ALIGN(struct, g13, 1);
+CHECK_OFFSET(struct, g13, c, 8);
 #else
 CHECK_SIZE(struct, g13, 5);
 CHECK_ALIGN(struct, g13, 1);
@@ -233,6 +238,10 @@
 CHECK_SIZE(struct, g14, 16);
 CHECK_ALIGN(struct, g14, 8);
 CHECK_OFFSET(struct, g14, c, 8);
+#elif (__x86_64__)
+CHECK_SIZE(struct, g14, 9);
+CHECK_ALIGN(struct, g14, 1);
+CHECK_OFFSET(struct, g14, c, 8);
 #else
 CHECK_SIZE(struct, g14, 5);
 CHECK_ALIGN(struct, g14, 1);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16514: Add -stop-on-failure driver option, and enable it by default for CUDA compiles.

2016-01-28 Thread Artem Belevich via cfe-commits
tra added inline comments.


Comment at: lib/Driver/Driver.cpp:652
@@ -640,3 +651,3 @@
   SmallVector, 4> FailingCommands;
-  C.ExecuteJobs(C.getJobs(), FailingCommands);
+  C.ExecuteJobs(C.getJobs(), /* StopOnFailure = */ false, FailingCommands);
 

jlebar wrote:
> tra wrote:
> > As far as I can tell, we don't do anything interesting if we've detected 
> > that *any* of the commands have failed. That suggests that doing anything 
> > beyond the first failing command does not do us any good. That would 
> > suggest that we may really want StopOnFailure=true here.
> > 
> > 'false' would preserve current behavior, though.
> > 
> > In either case I'm OK with a constant here.
> Sorry, I think I'm misunderstanding something.  Would you mind rephrasing 
> this?
> 
> > As far as I can tell, we don't do anything interesting if we've detected 
> > that *any* of the commands have failed.  That suggests that doing anything 
> > beyond the first failing command does not do us any good.
> 
> The scenario I thought this change applied to was:
> 
> External tool crashes during a call to ExecuteJobs() (not this one).  We now 
> want to output preprocessed inputs, so we run this code, which again calls 
> ExecuteJobs(), but these jobs only run the preprocessor on the inputs.
> 
> Now suppose one of those preprocessor jobs fails.  Maybe it has a bad 
> preprocessor directive, or maybe #error would be enough.  It seems to me in 
> this case that we should continue running the other preprocessor jobs, so we 
> dump as much debug info as we can.
> 
> Note that if the StopOnFailure flag is false, afaict it's entirely possible 
> for us to have two inputs, one of which has a pp error and the other of which 
> causes a compiler crash -- if we stopped on failure here, we wouldn't output 
> anything for the second input, which is the one we're interested in.
> 
> Sorry again, I'm sure I'm missing something.
Look at the lines below. If there are any failing commands we just report an 
error and return.
Even if there are multiple preprocessor jobs and if some of them succeed, we 
would not get to use their output.



http://reviews.llvm.org/D16514



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


Re: [PATCH] D3976: -Wcomma, a new warning for questionable uses of the comma operator

2016-01-28 Thread Nico Weber via cfe-commits
thakis added a comment.

Did this ever land? Looks like it's lgtm'd and ready to go, and it looks like a 
useful warning.


http://reviews.llvm.org/D3976



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


Re: [PATCH] D16478: Always build a new TypeSourceInfo for function templates with parameters

2016-01-28 Thread Yaron Keren via cfe-commits
The instantiated does get a new collection of ParmVarDecls while getting
the pattern Type which points to the pattern ParmVarDecls. So the
ParmVarDecls pointed in the instantiated are not the same as those pointed
by its Type.

Traversing by Type or by the Decl finds a different set of ParmVarDecls
which seems an inconsistency or at least a surprise.

2016-01-28 22:39 GMT+02:00 Reid Kleckner :

> The fact that an instantiated type might point to decls from the template
> pattern seems like expected behavior. The parts of the template that are
> the same are supposed to be shared.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16478: Always build a new TypeSourceInfo for function templates with parameters

2016-01-28 Thread Nico Weber via cfe-commits
Exactly :-)

On Thu, Jan 28, 2016 at 5:07 PM, Yaron Keren  wrote:

> The instantiated does get a new collection of ParmVarDecls while getting
> the pattern Type which points to the pattern ParmVarDecls. So the
> ParmVarDecls pointed in the instantiated are not the same as those pointed
> by its Type.
>
> Traversing by Type or by the Decl finds a different set of ParmVarDecls
> which seems an inconsistency or at least a surprise.
>
> 2016-01-28 22:39 GMT+02:00 Reid Kleckner :
>
>> The fact that an instantiated type might point to decls from the template
>> pattern seems like expected behavior. The parts of the template that are
>> the same are supposed to be shared.
>>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16694: [llvmlab] Enable clang tests that output to the console when we are on the buildbots

2016-01-28 Thread Yunzhong Gao via cfe-commits
ygao created this revision.
ygao added subscribers: gkistanova, sqlbyme, cfe-commits, llvm-commits.

Hi,
So this patch tries to enable tests that will output to the console. These 
tests are otherwise not exercised.
Note that the outputs will stay on the console and will not be saved into the 
test log.
Could a buildbot expert take a look whether this is the right approach?
Thanks in advance,
- Gao

http://reviews.llvm.org/D16694

Files:
  zorg/buildbot/builders/ClangBuilder.py

Index: zorg/buildbot/builders/ClangBuilder.py
===
--- zorg/buildbot/builders/ClangBuilder.py
+++ zorg/buildbot/builders/ClangBuilder.py
@@ -1367,15 +1367,15 @@
 # Save artifacts of this build for use by other builders.
 f = artifacts.uploadArtifacts(f)
 # Run the LLVM and Clang regression tests.
-cmd_str = r"""make VERBOSE=1 LIT_ARGS="-v --param run_long_tests=true 
--filter='^(?!.*debuginfo-tests)'" check-all"""
+cmd_str = r"""make VERBOSE=1 LIT_ARGS="-v --param run_long_tests=true 
--param enable_console=1 --filter='^(?!.*debuginfo-tests)'" check-all"""
 f.addStep(lit_test_command.LitTestCommand(name='run.llvm.tests', 
haltOnFailure=True,
   command=cmd_str,
   description=['all', 'tests'],
   workdir=clang_build_dir))
 # Work around for lldb issue rdar://14929651
 # The crazy filter regex is to remove static-member[2].cpp, which requires 
xcode5 or later.
 # radar://16295455 tracks the removal of this regex.
-cmd_str = r"""make VERBOSE=1 LIT_ARGS="-j 1 -v --param run_long_tests=true 
 --filter='debuginfo-tests.(?!static-member)'" check-all"""
+cmd_str = r"""make VERBOSE=1 LIT_ARGS="-j 1 -v --param run_long_tests=true 
--param enable_console=1 --filter='debuginfo-tests.(?!static-member)'" 
check-all"""
 f.addStep(lit_test_command.LitTestCommand(name='run.llvm.debuginfo-tests', 
haltOnFailure=True,
   command=cmd_str,
   description=['all', 'tests'],


Index: zorg/buildbot/builders/ClangBuilder.py
===
--- zorg/buildbot/builders/ClangBuilder.py
+++ zorg/buildbot/builders/ClangBuilder.py
@@ -1367,15 +1367,15 @@
 # Save artifacts of this build for use by other builders.
 f = artifacts.uploadArtifacts(f)
 # Run the LLVM and Clang regression tests.
-cmd_str = r"""make VERBOSE=1 LIT_ARGS="-v --param run_long_tests=true --filter='^(?!.*debuginfo-tests)'" check-all"""
+cmd_str = r"""make VERBOSE=1 LIT_ARGS="-v --param run_long_tests=true --param enable_console=1 --filter='^(?!.*debuginfo-tests)'" check-all"""
 f.addStep(lit_test_command.LitTestCommand(name='run.llvm.tests', haltOnFailure=True,
   command=cmd_str,
   description=['all', 'tests'],
   workdir=clang_build_dir))
 # Work around for lldb issue rdar://14929651
 # The crazy filter regex is to remove static-member[2].cpp, which requires xcode5 or later.
 # radar://16295455 tracks the removal of this regex.
-cmd_str = r"""make VERBOSE=1 LIT_ARGS="-j 1 -v --param run_long_tests=true  --filter='debuginfo-tests.(?!static-member)'" check-all"""
+cmd_str = r"""make VERBOSE=1 LIT_ARGS="-j 1 -v --param run_long_tests=true --param enable_console=1 --filter='debuginfo-tests.(?!static-member)'" check-all"""
 f.addStep(lit_test_command.LitTestCommand(name='run.llvm.debuginfo-tests', haltOnFailure=True,
   command=cmd_str,
   description=['all', 'tests'],
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r259099 - [analyzer] Suppress nullability warnings in copy, mutableCopy, and init families.

2016-01-28 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Thu Jan 28 16:23:34 2016
New Revision: 259099

URL: http://llvm.org/viewvc/llvm-project?rev=259099&view=rev
Log:
[analyzer] Suppress nullability warnings in copy, mutableCopy, and init 
families.

There are multiple, common idioms of defensive nil-checks in copy,
mutableCopy, and init methods in ObjC. The analyzer doesn't currently have the
capability to distinguish these idioms from true positives, so suppress all
warnings about returns in those families. This is a pretty blunt suppression
that we should improve later.

rdar://problem/24395811

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
cfe/trunk/test/Analysis/nullability.mm

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp?rev=259099&r1=259098&r2=259099&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp Thu Jan 28 
16:23:34 2016
@@ -510,23 +510,22 @@ void NullabilityChecker::checkPreStmt(co
   if (!RetSVal)
 return;
 
-  bool IsReturnSelfInObjCInit = false;
+  bool InSuppressedMethodFamily = false;
 
   QualType RequiredRetType;
   AnalysisDeclContext *DeclCtxt =
   C.getLocationContext()->getAnalysisDeclContext();
   const Decl *D = DeclCtxt->getDecl();
   if (auto *MD = dyn_cast(D)) {
+// HACK: This is a big hammer to avoid warning when there are defensive
+// nil checks in -init and -copy methods. We should add more sophisticated
+// logic here to suppress on common defensive idioms but still
+// warn when there is a likely problem.
+ObjCMethodFamily Family = MD->getMethodFamily();
+if (OMF_init == Family || OMF_copy == Family || OMF_mutableCopy == Family)
+  InSuppressedMethodFamily = true;
+
 RequiredRetType = MD->getReturnType();
-// Suppress diagnostics for returns of nil that are syntactic returns of
-// self in ObjC initializers. This avoids warning under the common idiom of
-// a defensive check of the result of a call to super:
-//   if (self = [super init]) {
-// ...
-//   }
-//   return self; // no-warning
-IsReturnSelfInObjCInit = (MD->getMethodFamily() == OMF_init) &&
-  isReturnSelf(S, C);
   } else if (auto *FD = dyn_cast(D)) {
 RequiredRetType = FD->getReturnType();
   } else {
@@ -549,7 +548,7 @@ void NullabilityChecker::checkPreStmt(co
   Nullness == NullConstraint::IsNull &&
   RetExprTypeLevelNullability != Nullability::Nonnull &&
   RequiredNullability == Nullability::Nonnull &&
-  !IsReturnSelfInObjCInit) {
+  !InSuppressedMethodFamily) {
 static CheckerProgramPointTag Tag(this, "NullReturnedFromNonnull");
 ExplodedNode *N = C.generateErrorNode(State, &Tag);
 if (!N)

Modified: cfe/trunk/test/Analysis/nullability.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nullability.mm?rev=259099&r1=259098&r2=259099&view=diff
==
--- cfe/trunk/test/Analysis/nullability.mm (original)
+++ cfe/trunk/test/Analysis/nullability.mm Thu Jan 28 16:23:34 2016
@@ -4,14 +4,27 @@
 #define nil 0
 #define BOOL int
 
+#define NS_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
+#define NS_ASSUME_NONNULL_END   _Pragma("clang assume_nonnull end")
+
+typedef struct _NSZone NSZone;
+
 @protocol NSObject
 + (id)alloc;
 - (id)init;
 @end
 
+NS_ASSUME_NONNULL_BEGIN
 @protocol NSCopying
+- (id)copyWithZone:(nullable NSZone *)zone;
+
 @end
 
+@protocol NSMutableCopying
+- (id)mutableCopyWithZone:(nullable NSZone *)zone;
+@end
+NS_ASSUME_NONNULL_END
+
 __attribute__((objc_root_class))
 @interface
 NSObject
@@ -332,8 +345,9 @@ Dummy *_Nonnull testDefensiveInlineCheck
   // This leaks, but we're not checking for that here.
 
   ClassWithInitializers *other = nil;
-  // Still warn when when not returning via self.
-  return other; // expected-warning {{Null is returned from a function that is 
expected to return a non-null value}}
+  // False negative. Once we have more subtle suppression of defensive checks 
in
+  // initializers we should warn here.
+  return other;
 }
 @end
 
@@ -350,4 +364,40 @@ Dummy *_Nonnull testDefensiveInlineCheck
 
   return self; // no-warning
 }
+
+- (id _Nonnull)initWithNonnullReturnAndSelfCheckingIdiomV2; {
+  // Another common return-checking idiom
+  self = [super initWithNonnullReturnAndSelfCheckingIdiom];
+  if (!self) {
+return nil; // no-warning
+  }
+
+  return self;
+}
+@end
+
+@interface ClassWithCopyWithZone : NSObject {
+  id i;
+}
+
+@end
+
+@implementation ClassWithCopyWithZone
+-(id)copyWithZone:(NSZone *)zone {
+  ClassWithCopyWithZone *newInstance = [[ClassWithCopyWithZone alloc] init];
+  if (!newInstance)
+return ni

Re: [PATCH] D16664: [CUDA] Generate CUDA's printf alloca in its function's entry block.

2016-01-28 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 46314.
jlebar marked an inline comment as done.
jlebar added a comment.

Use a struct rather than an i8 buffer.


http://reviews.llvm.org/D16664

Files:
  lib/CodeGen/CGCUDABuiltin.cpp
  test/CodeGenCUDA/printf.cu

Index: test/CodeGenCUDA/printf.cu
===
--- test/CodeGenCUDA/printf.cu
+++ test/CodeGenCUDA/printf.cu
@@ -9,45 +9,35 @@
 extern "C" __device__ int vprintf(const char*, const char*);
 
 // Check a simple call to printf end-to-end.
+// CHECK: [[SIMPLE_PRINTF_TY:%[a-zA-Z0-9_]+]] = type { i32, i64, double }
 __device__ int CheckSimple() {
+  // CHECK: [[BUF:%[a-zA-Z0-9_]+]] = alloca [[SIMPLE_PRINTF_TY]]
   // CHECK: [[FMT:%[0-9]+]] = load{{.*}}%fmt
-  const char* fmt = "%d";
-  // CHECK: [[BUF:%[a-zA-Z0-9_]+]] = alloca i8, i32 4, align 4
-  // CHECK: [[PTR:%[0-9]+]] = getelementptr i8, i8* [[BUF]], i32 0
-  // CHECK: [[CAST:%[0-9]+]] = bitcast i8* [[PTR]] to i32*
-  // CHECK: store i32 42, i32* [[CAST]], align 4
-  // CHECK: [[RET:%[0-9]+]] = call i32 @vprintf(i8* [[FMT]], i8* [[BUF]])
+  const char* fmt = "%d %lld %f";
+  // CHECK: [[PTR0:%[0-9]+]] = getelementptr inbounds [[SIMPLE_PRINTF_TY]], [[SIMPLE_PRINTF_TY]]* [[BUF]], i32 0, i32 0
+  // CHECK: store i32 1, i32* [[PTR0]], align 4
+  // CHECK: [[PTR1:%[0-9]+]] = getelementptr inbounds [[SIMPLE_PRINTF_TY]], [[SIMPLE_PRINTF_TY]]* [[BUF]], i32 0, i32 1
+  // CHECK: store i64 2, i64* [[PTR1]], align 8
+  // CHECK: [[PTR2:%[0-9]+]] = getelementptr inbounds [[SIMPLE_PRINTF_TY]], [[SIMPLE_PRINTF_TY]]* [[BUF]], i32 0, i32 2
+  // CHECK: store double 3.0{{[^,]*}}, double* [[PTR2]], align 8
+  // CHECK: [[BUF_CAST:%[0-9]+]] = bitcast [[SIMPLE_PRINTF_TY]]* [[BUF]] to i8*
+  // CHECK: [[RET:%[0-9]+]] = call i32 @vprintf(i8* [[FMT]], i8* [[BUF_CAST]])
   // CHECK: ret i32 [[RET]]
-  return printf(fmt, 42);
-}
-
-// Check that the args' types are promoted correctly when we call printf.
-__device__ void CheckTypes() {
-  // CHECK: alloca {{.*}} align 8
-  // CHECK: getelementptr {{.*}} i32 0
-  // CHECK: bitcast {{.*}} to i32*
-  // CHECK: getelementptr {{.*}} i32 4
-  // CHECK: bitcast {{.*}} to i32*
-  // CHECK: getelementptr {{.*}} i32 8
-  // CHECK: bitcast {{.*}} to double*
-  // CHECK: getelementptr {{.*}} i32 16
-  // CHECK: bitcast {{.*}} to double*
-  printf("%d %d %f %f", (char)1, (short)2, 3.0f, 4.0);
-}
-
-// Check that the args are aligned properly in the buffer.
-__device__ void CheckAlign() {
-  // CHECK: alloca i8, i32 40, align 8
-  // CHECK: getelementptr {{.*}} i32 0
-  // CHECK: getelementptr {{.*}} i32 8
-  // CHECK: getelementptr {{.*}} i32 16
-  // CHECK: getelementptr {{.*}} i32 20
-  // CHECK: getelementptr {{.*}} i32 24
-  // CHECK: getelementptr {{.*}} i32 32
-  printf("%d %f %d %d %d %lld", 1, 2.0, 3, 4, 5, (long long)6);
+  return printf(fmt, 1, 2ll, 3.0);
 }
 
 __device__ void CheckNoArgs() {
   // CHECK: call i32 @vprintf({{.*}}, i8* null){{$}}
   printf("hello, world!");
 }
+
+// Check that printf's alloca happens in the entry block, not inside the if
+// statement.
+__device__ bool foo();
+__device__ void CheckAllocaIsInEntryBlock() {
+  // CHECK: alloca %printf_args
+  // CHECK: call {{.*}} @_Z3foov()
+  if (foo()) {
+printf("%d", 42);
+  }
+}
Index: lib/CodeGen/CGCUDABuiltin.cpp
===
--- lib/CodeGen/CGCUDABuiltin.cpp
+++ lib/CodeGen/CGCUDABuiltin.cpp
@@ -52,10 +52,13 @@
 //
 // is converted into something resembling
 //
-//   char* buf = alloca(...);
-//   *reinterpret_cast(buf) = arg1;
-//   *reinterpret_cast(buf + ...) = arg2;
-//   *reinterpret_cast(buf + ...) = arg3;
+//   struct Tmp {
+// Arg1 a1;
+// Arg2 a2;
+// Arg3 a3;
+//   };
+//   char* buf = alloca(sizeof(Tmp));
+//   *(Tmp*)buf = {a1, a2, a3};
 //   vprintf("format string", buf);
 //
 // buf is aligned to the max of {alignof(Arg1), ...}.  Furthermore, each of the
@@ -80,48 +83,24 @@
E->arguments(), E->getDirectCallee(),
/* ParamsToSkip = */ 0);
 
-  // Figure out how large of a buffer we need to hold our varargs and how
-  // aligned the buffer needs to be.  We start iterating at Arg[1], because
-  // that's our first vararg.
-  unsigned BufSize = 0;
-  unsigned BufAlign = 0;
-  for (unsigned I = 1, NumArgs = Args.size(); I < NumArgs; ++I) {
-const RValue& RV = Args[I].RV;
-llvm::Type* Ty = RV.getScalarVal()->getType();
-
-auto Align = DL.getPrefTypeAlignment(Ty);
-BufAlign = std::max(BufAlign, Align);
-// Add padding required to keep the current arg aligned.
-BufSize = llvm::alignTo(BufSize, Align);
-BufSize += DL.getTypeAllocSize(Ty);
-  }
-
-  // Construct and fill the buffer.
-  llvm::Value* BufferPtr = nullptr;
-  if (BufSize == 0) {
+  // Construct and fill the args buffer that we'll pass to vprintf.
+  llvm::Value* BufferPtr;
+  if (Args.size() <= 1) {
 // If there are no args, pass a null pointer to vprintf.
 B

Re: [PATCH] D16664: [CUDA] Generate CUDA's printf alloca in its function's entry block.

2016-01-28 Thread Justin Lebar via cfe-commits
jlebar marked 3 inline comments as done.
jlebar added a comment.

Thank you for the reviews.

Please have another look; I switched to using a struct proper.  It's a lot 
cleaner!  We're now assuming that the struct is aligned in the same way as 
vprintf wants, but if anything I expect this new code is more likely to match 
what it wants.



Comment at: lib/CodeGen/CGCUDABuiltin.cpp:105-108
@@ -104,2 +104,6 @@
   } else {
-BufferPtr = Builder.Insert(new llvm::AllocaInst(
+// Insert our alloca not into the current BB, but into the function's entry
+// block.  This is important because nvvm doesn't support alloca -- if we
+// put the alloca anywhere else, llvm may eventually output
+// stacksave/stackrestore intrinsics, which cause our nvvm backend to 
choke.
+auto *Alloca = new llvm::AllocaInst(

rnk wrote:
> The fact that allocas for local variables should always go in the entry block 
> is pretty widespread cultural knowledge in LLVM and clang. Most readers 
> aren't going to need this comment, unless you expect that people working on 
> CUDA won't have that background. Plus, if you use CreateTempAlloca, there 
> won't be any question about which insert point should be used.
OK, yeah, I also don't like comments that explain something that everyone other 
than the author knows.  Thanks.


http://reviews.llvm.org/D16664



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


Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-28 Thread Rong Xu via cfe-commits
The previous patch was not good as it failed 58 tests that use
-fprofile-instr-generate as a cc1 option.

I can see two methods to solve this:
(1) we change all the 58 tests to use -fprofile-instrument=Clang option.
(2) Fall back to my previous patch: keep -fprofile-instr-generate as
the CC1 options and check it in Frontend/CompilerInvocation.cpp. (i.e.
The redundant else branch Sean was referring to).  We have to do it
here because we cannot assume driver will append
-fprofile-instrument=Clang in the case the user uses
-fprofile-instr-generate as the cc1 option.



On Thu, Jan 28, 2016 at 12:04 PM, Rong Xu  wrote:
> xur updated this revision to Diff 46303.
> xur added a comment.
>
> Integrated most recently comments/suggestions from David and Sean.
>
> Thanks,
>
> -Rong
>
>
> http://reviews.llvm.org/D15829
>
> Files:
>   include/clang/Basic/DiagnosticDriverKinds.td
>   include/clang/Driver/CC1Options.td
>   include/clang/Driver/Options.td
>   include/clang/Frontend/CodeGenOptions.def
>   include/clang/Frontend/CodeGenOptions.h
>   lib/CodeGen/BackendUtil.cpp
>   lib/CodeGen/CGStmt.cpp
>   lib/CodeGen/CodeGenFunction.cpp
>   lib/CodeGen/CodeGenFunction.h
>   lib/CodeGen/CodeGenModule.cpp
>   lib/CodeGen/CodeGenPGO.cpp
>   lib/Driver/Tools.cpp
>   lib/Frontend/CompilerInvocation.cpp
>   test/CodeGen/Inputs/pgotest.profraw
>   test/CodeGen/pgo-instrumentation.c
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-28 Thread Rong Xu via cfe-commits
xur added a comment.

The previous patch was not good as it failed 58 tests that use
-fprofile-instr-generate as a cc1 option.

I can see two methods to solve this:
(1) we change all the 58 tests to use -fprofile-instrument=Clang option.
(2) Fall back to my previous patch: keep -fprofile-instr-generate as
the CC1 options and check it in Frontend/CompilerInvocation.cpp. (i.e.
The redundant else branch Sean was referring to).  We have to do it
here because we cannot assume driver will append
-fprofile-instrument=Clang in the case the user uses
-fprofile-instr-generate as the cc1 option.


http://reviews.llvm.org/D15829



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


Re: [PATCH] D16514: Add -stop-on-failure driver option, and enable it by default for CUDA compiles.

2016-01-28 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 46315.
jlebar marked 3 inline comments as done.
jlebar added a comment.

Pass StopOnFailure = true when running the preprocessor after an ICE.


http://reviews.llvm.org/D16514

Files:
  include/clang/Driver/Compilation.h
  include/clang/Driver/Driver.h
  include/clang/Driver/Options.td
  lib/Driver/Compilation.cpp
  lib/Driver/Driver.cpp

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -58,7 +58,8 @@
   CCPrintHeadersFilename(nullptr), CCLogDiagnosticsFilename(nullptr),
   CCCPrintBindings(false), CCPrintHeaders(false), CCLogDiagnostics(false),
   CCGenDiagnostics(false), CCCGenericGCCName(""), CheckInputsExist(true),
-  CCCUsePCH(true), SuppressMissingInputWarning(false) {
+  CCCUsePCH(true), SuppressMissingInputWarning(false),
+  StopOnJobFailure(false) {
 
   // Provide a sane fallback if no VFS is specified.
   if (!this->VFS)
@@ -505,6 +506,16 @@
   InputList Inputs;
   BuildInputs(C->getDefaultToolChain(), *TranslatedArgs, Inputs);
 
+  // StopOnJobFailure defaults to false, except for CUDA compilations.
+  if (Arg *A = C->getArgs().getLastArg(options::OPT_stop_on_failure,
+   options::OPT_no_stop_on_failure))
+StopOnJobFailure = A->getOption().matches(options::OPT_stop_on_failure);
+  else
+StopOnJobFailure =
+llvm::any_of(Inputs, [](const std::pair &I) {
+  return I.first == types::TY_CUDA;
+});
+
   // Construct the list of abstract actions to perform for this compilation. On
   // MachO targets this uses the driver-driver and universal actions.
   if (TC.getTriple().isOSBinFormatMachO())
@@ -638,7 +649,9 @@
 
   // Generate preprocessed output.
   SmallVector, 4> FailingCommands;
-  C.ExecuteJobs(C.getJobs(), FailingCommands);
+  // Might as well pass StopOnFailure = true; if any of the commands fails, we
+  // don't output anything at all.
+  C.ExecuteJobs(C.getJobs(), /* StopOnFailure = */ true, FailingCommands);
 
   // If any of the preprocessing commands failed, clean up and exit.
   if (!FailingCommands.empty()) {
@@ -730,7 +743,7 @@
   for (auto &Job : C.getJobs())
 setUpResponseFiles(C, Job);
 
-  C.ExecuteJobs(C.getJobs(), FailingCommands);
+  C.ExecuteJobs(C.getJobs(), StopOnJobFailure, FailingCommands);
 
   // Remove temp files.
   C.CleanupFileList(C.getTempFiles());
Index: lib/Driver/Compilation.cpp
===
--- lib/Driver/Compilation.cpp
+++ lib/Driver/Compilation.cpp
@@ -188,14 +188,17 @@
   return !ActionFailed(&C.getSource(), FailingCommands);
 }
 
-void Compilation::ExecuteJobs(const JobList &Jobs,
+void Compilation::ExecuteJobs(const JobList &Jobs, bool StopOnFailure,
   FailingCommandList &FailingCommands) const {
   for (const auto &Job : Jobs) {
 if (!InputsOk(Job, FailingCommands))
   continue;
 const Command *FailingCommand = nullptr;
-if (int Res = ExecuteCommand(Job, FailingCommand))
+if (int Res = ExecuteCommand(Job, FailingCommand)) {
   FailingCommands.push_back(std::make_pair(Res, FailingCommand));
+  if (StopOnFailure)
+return;
+}
   }
 }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1801,6 +1801,11 @@
 def : Flag<["-"], "no-integrated-as">, Alias,
   Flags<[CC1Option, DriverOption]>;
 
+def stop_on_failure : Flag<["-"], "stop-on-failure">, Flags<[DriverOption]>,
+  HelpText<"Stop running jobs as soon as one fails.  This is the default during "
+"CUDA compilation without --save-temps.">;
+def no_stop_on_failure : Flag<["-"], "no-stop-on-failure">, Flags<[DriverOption]>;
+
 def working_directory : JoinedOrSeparate<["-"], "working-directory">, Flags<[CC1Option]>,
   HelpText<"Resolve file paths relative to the specified directory">;
 def working_directory_EQ : Joined<["-"], "working-directory=">, Flags<[CC1Option]>,
Index: include/clang/Driver/Driver.h
===
--- include/clang/Driver/Driver.h
+++ include/clang/Driver/Driver.h
@@ -192,6 +192,10 @@
   /// Certain options suppress the 'no input files' warning.
   bool SuppressMissingInputWarning : 1;
 
+  /// Should we stop running all jobs as soon as one fails?  If false, we run as
+  /// much as we can.
+  bool StopOnJobFailure : 1;
+
   std::list TempFiles;
   std::list ResultFiles;
 
Index: include/clang/Driver/Compilation.h
===
--- include/clang/Driver/Compilation.h
+++ include/clang/Driver/Compilation.h
@@ -193,12 +193,13 @@
   /// \return The result code of the subprocess.
   int ExecuteCommand(const Command &C, const Command *&FailingCommand) const;
 
-  /// ExecuteJob - Execute a single 

Re: [PATCH] D16514: Add -stop-on-failure driver option, and enable it by default for CUDA compiles.

2016-01-28 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: lib/Driver/Driver.cpp:652
@@ -640,3 +651,3 @@
   SmallVector, 4> FailingCommands;
-  C.ExecuteJobs(C.getJobs(), FailingCommands);
+  C.ExecuteJobs(C.getJobs(), /* StopOnFailure = */ false, FailingCommands);
 

tra wrote:
> jlebar wrote:
> > tra wrote:
> > > As far as I can tell, we don't do anything interesting if we've detected 
> > > that *any* of the commands have failed. That suggests that doing anything 
> > > beyond the first failing command does not do us any good. That would 
> > > suggest that we may really want StopOnFailure=true here.
> > > 
> > > 'false' would preserve current behavior, though.
> > > 
> > > In either case I'm OK with a constant here.
> > Sorry, I think I'm misunderstanding something.  Would you mind rephrasing 
> > this?
> > 
> > > As far as I can tell, we don't do anything interesting if we've detected 
> > > that *any* of the commands have failed.  That suggests that doing 
> > > anything beyond the first failing command does not do us any good.
> > 
> > The scenario I thought this change applied to was:
> > 
> > External tool crashes during a call to ExecuteJobs() (not this one).  We 
> > now want to output preprocessed inputs, so we run this code, which again 
> > calls ExecuteJobs(), but these jobs only run the preprocessor on the inputs.
> > 
> > Now suppose one of those preprocessor jobs fails.  Maybe it has a bad 
> > preprocessor directive, or maybe #error would be enough.  It seems to me in 
> > this case that we should continue running the other preprocessor jobs, so 
> > we dump as much debug info as we can.
> > 
> > Note that if the StopOnFailure flag is false, afaict it's entirely possible 
> > for us to have two inputs, one of which has a pp error and the other of 
> > which causes a compiler crash -- if we stopped on failure here, we wouldn't 
> > output anything for the second input, which is the one we're interested in.
> > 
> > Sorry again, I'm sure I'm missing something.
> Look at the lines below. If there are any failing commands we just report an 
> error and return.
> Even if there are multiple preprocessor jobs and if some of them succeed, we 
> would not get to use their output.
> 
Oh.

Thanks.  :)


http://reviews.llvm.org/D16514



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


Re: [PATCH] D16564: Fix an issue where backend crashes after frontend emits an error message

2016-01-28 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Seems like a weird place to handle this, but it's been there for a long time. 
That said, I see how we can get there now, thanks!

-eric


http://reviews.llvm.org/D16564



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


Re: [PATCH] D16514: Add -stop-on-failure driver option, and enable it by default for CUDA compiles.

2016-01-28 Thread Eric Christopher via cfe-commits
echristo added a comment.



> The other reason, which is less important, is that when you have one arch and 
> ptxas fails -- which, it shouldn't, but we're not good enough to catch 
> everything yet, and likely won't be for some time -- the error you get is

> 

>   ptxas: foo is not defined

>   *FATAL ERROR*: fatbinary failed, /tmp/bar.cubin does not exist.

>

> 

> I'd like not to display that second line, since it hides the actual problem.  
> Once you get used to it, it's not a big deal, but it tripped me up for a few 
> minutes, and I'm the one who added the call to ptxas.


This seems like more of a problem - we don't have this with the existing 
BindArchAction set of things, we stop before trying to call lipo on darwin. Hrm.

-eric


http://reviews.llvm.org/D16514



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


Re: [PATCH] D16664: [CUDA] Generate CUDA's printf alloca in its function's entry block.

2016-01-28 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a reviewer: echristo.
echristo added a comment.
This revision is now accepted and ready to land.

One inline nit then LGTM.

-eric



Comment at: lib/CodeGen/CGCUDABuiltin.cpp:87
@@ +86,3 @@
+  // Construct and fill the args buffer that we'll pass to vprintf.
+  llvm::Value* BufferPtr;
+  if (Args.size() <= 1) {

* on the wrong side ;)


http://reviews.llvm.org/D16664



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


r259108 - Update for llvm change.

2016-01-28 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Thu Jan 28 16:56:41 2016
New Revision: 259108

URL: http://llvm.org/viewvc/llvm-project?rev=259108&view=rev
Log:
Update for llvm change.

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

Modified: cfe/trunk/test/CodeGen/pr18235.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pr18235.c?rev=259108&r1=259107&r2=259108&view=diff
==
--- cfe/trunk/test/CodeGen/pr18235.c (original)
+++ cfe/trunk/test/CodeGen/pr18235.c Thu Jan 28 16:56:41 2016
@@ -1,3 +1,3 @@
 // RUN: not %clang_cc1 -triple le32-unknown-nacl %s -S -o - 2>&1 | FileCheck %s
 
-// CHECK: error: unable to create target: 'No available targets are compatible 
with this triple, see -version for the available targets.'
+// CHECK: error: unable to create target: 'No available targets are compatible 
with this triple.


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


Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-28 Thread Xinliang David Li via cfe-commits
On Thu, Jan 28, 2016 at 2:34 PM, Rong Xu  wrote:
> The previous patch was not good as it failed 58 tests that use
> -fprofile-instr-generate as a cc1 option.
>
> I can see two methods to solve this:
> (1) we change all the 58 tests to use -fprofile-instrument=Clang option.

My vote is on (1) -- get rid of -fprofile-instr-generate as cc1 option
as it is now a subset of what -fprofile-instrument=<...> does.

Changing test cases are mechanical.

David

> (2) Fall back to my previous patch: keep -fprofile-instr-generate as
> the CC1 options and check it in Frontend/CompilerInvocation.cpp. (i.e.
> The redundant else branch Sean was referring to).  We have to do it
> here because we cannot assume driver will append
> -fprofile-instrument=Clang in the case the user uses
> -fprofile-instr-generate as the cc1 option.


>
>
>
> On Thu, Jan 28, 2016 at 12:04 PM, Rong Xu  wrote:
>> xur updated this revision to Diff 46303.
>> xur added a comment.
>>
>> Integrated most recently comments/suggestions from David and Sean.
>>
>> Thanks,
>>
>> -Rong
>>
>>
>> http://reviews.llvm.org/D15829
>>
>> Files:
>>   include/clang/Basic/DiagnosticDriverKinds.td
>>   include/clang/Driver/CC1Options.td
>>   include/clang/Driver/Options.td
>>   include/clang/Frontend/CodeGenOptions.def
>>   include/clang/Frontend/CodeGenOptions.h
>>   lib/CodeGen/BackendUtil.cpp
>>   lib/CodeGen/CGStmt.cpp
>>   lib/CodeGen/CodeGenFunction.cpp
>>   lib/CodeGen/CodeGenFunction.h
>>   lib/CodeGen/CodeGenModule.cpp
>>   lib/CodeGen/CodeGenPGO.cpp
>>   lib/Driver/Tools.cpp
>>   lib/Frontend/CompilerInvocation.cpp
>>   test/CodeGen/Inputs/pgotest.profraw
>>   test/CodeGen/pgo-instrumentation.c
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-28 Thread David Li via cfe-commits
davidxl added inline comments.


Comment at: lib/Driver/Tools.cpp:3232
@@ -3231,2 +3231,3 @@
   CmdArgs.push_back(
   Args.MakeArgString(Twine("-fprofile-instr-generate=") + Path));
+}

I also suggest changing CC1 option -fprofile-instr-generate= to be a different 
name (from the  driver option): -fprofile-instrument-path=... or something.


http://reviews.llvm.org/D15829



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


r259116 - Check for frontend errors after releasing the Builder.

2016-01-28 Thread Manman Ren via cfe-commits
Author: mren
Date: Thu Jan 28 17:29:02 2016
New Revision: 259116

URL: http://llvm.org/viewvc/llvm-project?rev=259116&view=rev
Log:
Check for frontend errors after releasing the Builder.

Frontend can emit errors when releaseing the Builder. If there are errors before
or when releasing the Builder, we reset the module to stop here before invoking
the backend.

Before this commit, clang will continue to invoke the backend and backend can
crash.

Differential Revision: http://reviews.llvm.org/D16564

Added:
cfe/trunk/test/CodeGen/target-builtin-error-3.c
Modified:
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp

Modified: cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ModuleBuilder.cpp?rev=259116&r1=259115&r2=259116&view=diff
==
--- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/ModuleBuilder.cpp Thu Jan 28 17:29:02 2016
@@ -199,15 +199,18 @@ namespace {
 }
 
 void HandleTranslationUnit(ASTContext &Ctx) override {
+  // Release the Builder when there is no error.
+  if (!Diags.hasErrorOccurred() && Builder)
+Builder->Release();
+
+  // If there are errors before or when releasing the Builder, reset
+  // the module to stop here before invoking the backend.
   if (Diags.hasErrorOccurred()) {
 if (Builder)
   Builder->clear();
 M.reset();
 return;
   }
-
-  if (Builder)
-Builder->Release();
 }
 
 void AssignInheritanceModel(CXXRecordDecl *RD) override {

Added: cfe/trunk/test/CodeGen/target-builtin-error-3.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-builtin-error-3.c?rev=259116&view=auto
==
--- cfe/trunk/test/CodeGen/target-builtin-error-3.c (added)
+++ cfe/trunk/test/CodeGen/target-builtin-error-3.c Thu Jan 28 17:29:02 2016
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -S -verify -o - 
-target-feature +avx
+
+// RUN: not %clang_cc1 %s -triple=x86_64-apple-darwin -emit-obj 
-target-feature +avx 2> %t.err
+// RUN: FileCheck < %t.err %s
+// CHECK: 1 error generated
+
+typedef unsigned short uint16_t;
+typedef long long __m128i __attribute__((__vector_size__(16)));
+typedef float __v8sf __attribute__ ((__vector_size__ (32)));
+typedef float __m256 __attribute__ ((__vector_size__ (32)));
+typedef uint16_t half;
+typedef __attribute__ ((ext_vector_type( 8),__aligned__( 16))) half half8;
+typedef __attribute__ ((ext_vector_type(16),__aligned__( 32))) half half16;
+typedef __attribute__ ((ext_vector_type(16),__aligned__( 2))) half half16U;
+typedef __attribute__ ((ext_vector_type( 8),__aligned__( 32))) float float8;
+typedef __attribute__ ((ext_vector_type(16),__aligned__( 64))) float float16;
+static inline half8 __attribute__((__overloadable__)) convert_half( float8 a ) 
{
+  return __extension__ ({ __m256 __a = (a); 
(__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)__a, (0x00)); }); // 
expected-error {{'__builtin_ia32_vcvtps2ph256' needs target feature f16c}}
+}
+static inline half16 __attribute__((__overloadable__)) convert_half( float16 a 
) {
+  half16 r; 
+  r.lo = convert_half( a.lo); 
+  return r;
+}
+void avx_test( uint16_t *destData, float16 argbF)
+{
+   ((half16U*)destData)[0] = convert_half(argbF);
+}


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


Re: [PATCH] D16564: Fix an issue where backend crashes after frontend emits an error message

2016-01-28 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL259116: Check for frontend errors after releasing the 
Builder. (authored by mren).

Changed prior to commit:
  http://reviews.llvm.org/D16564?vs=46301&id=46320#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16564

Files:
  cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
  cfe/trunk/test/CodeGen/target-builtin-error-3.c

Index: cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
===
--- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
+++ cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
@@ -199,15 +199,18 @@
 }
 
 void HandleTranslationUnit(ASTContext &Ctx) override {
+  // Release the Builder when there is no error.
+  if (!Diags.hasErrorOccurred() && Builder)
+Builder->Release();
+
+  // If there are errors before or when releasing the Builder, reset
+  // the module to stop here before invoking the backend.
   if (Diags.hasErrorOccurred()) {
 if (Builder)
   Builder->clear();
 M.reset();
 return;
   }
-
-  if (Builder)
-Builder->Release();
 }
 
 void AssignInheritanceModel(CXXRecordDecl *RD) override {
Index: cfe/trunk/test/CodeGen/target-builtin-error-3.c
===
--- cfe/trunk/test/CodeGen/target-builtin-error-3.c
+++ cfe/trunk/test/CodeGen/target-builtin-error-3.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -S -verify -o - 
-target-feature +avx
+
+// RUN: not %clang_cc1 %s -triple=x86_64-apple-darwin -emit-obj 
-target-feature +avx 2> %t.err
+// RUN: FileCheck < %t.err %s
+// CHECK: 1 error generated
+
+typedef unsigned short uint16_t;
+typedef long long __m128i __attribute__((__vector_size__(16)));
+typedef float __v8sf __attribute__ ((__vector_size__ (32)));
+typedef float __m256 __attribute__ ((__vector_size__ (32)));
+typedef uint16_t half;
+typedef __attribute__ ((ext_vector_type( 8),__aligned__( 16))) half half8;
+typedef __attribute__ ((ext_vector_type(16),__aligned__( 32))) half half16;
+typedef __attribute__ ((ext_vector_type(16),__aligned__( 2))) half half16U;
+typedef __attribute__ ((ext_vector_type( 8),__aligned__( 32))) float float8;
+typedef __attribute__ ((ext_vector_type(16),__aligned__( 64))) float float16;
+static inline half8 __attribute__((__overloadable__)) convert_half( float8 a ) 
{
+  return __extension__ ({ __m256 __a = (a); 
(__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)__a, (0x00)); }); // 
expected-error {{'__builtin_ia32_vcvtps2ph256' needs target feature f16c}}
+}
+static inline half16 __attribute__((__overloadable__)) convert_half( float16 a 
) {
+  half16 r; 
+  r.lo = convert_half( a.lo); 
+  return r;
+}
+void avx_test( uint16_t *destData, float16 argbF)
+{
+   ((half16U*)destData)[0] = convert_half(argbF);
+}


Index: cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
===
--- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
+++ cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
@@ -199,15 +199,18 @@
 }
 
 void HandleTranslationUnit(ASTContext &Ctx) override {
+  // Release the Builder when there is no error.
+  if (!Diags.hasErrorOccurred() && Builder)
+Builder->Release();
+
+  // If there are errors before or when releasing the Builder, reset
+  // the module to stop here before invoking the backend.
   if (Diags.hasErrorOccurred()) {
 if (Builder)
   Builder->clear();
 M.reset();
 return;
   }
-
-  if (Builder)
-Builder->Release();
 }
 
 void AssignInheritanceModel(CXXRecordDecl *RD) override {
Index: cfe/trunk/test/CodeGen/target-builtin-error-3.c
===
--- cfe/trunk/test/CodeGen/target-builtin-error-3.c
+++ cfe/trunk/test/CodeGen/target-builtin-error-3.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -S -verify -o - -target-feature +avx
+
+// RUN: not %clang_cc1 %s -triple=x86_64-apple-darwin -emit-obj -target-feature +avx 2> %t.err
+// RUN: FileCheck < %t.err %s
+// CHECK: 1 error generated
+
+typedef unsigned short uint16_t;
+typedef long long __m128i __attribute__((__vector_size__(16)));
+typedef float __v8sf __attribute__ ((__vector_size__ (32)));
+typedef float __m256 __attribute__ ((__vector_size__ (32)));
+typedef uint16_t half;
+typedef __attribute__ ((ext_vector_type( 8),__aligned__( 16))) half half8;
+typedef __attribute__ ((ext_vector_type(16),__aligned__( 32))) half half16;
+typedef __attribute__ ((ext_vector_type(16),__aligned__( 2))) half half16U;
+typedef __attribute__ ((ext_vector_type( 8),__aligned__( 32))) float float8;
+typedef __attribute__ ((ext_vector_type(16),__aligned__( 64))) float float16;
+static inline half8 __attribute__((__overloadable__)) convert_half( float8 a ) {
+  return __extension__ ({ __m256 __a = (a); (__m128i)__builtin_ia32_v

r259118 - [analyzer] NullabilityChecker: Remove unused isReturnSelf() function.

2016-01-28 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Thu Jan 28 17:34:13 2016
New Revision: 259118

URL: http://llvm.org/viewvc/llvm-project?rev=259118&view=rev
Log:
[analyzer] NullabilityChecker: Remove unused isReturnSelf() function.

Remove the now-unused isReturnSelf() function so we don't get a compiler
warning. Apologies for not doing this in r259099.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp?rev=259118&r1=259117&r2=259118&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp Thu Jan 28 
17:34:13 2016
@@ -470,22 +470,6 @@ static const Expr *lookThroughImplicitCa
   return E;
 }
 
-/// Returns true when the return statement is a syntactic 'return self' in
-/// Objective-C.
-static bool isReturnSelf(const ReturnStmt *RS, CheckerContext &C) {
-  const ImplicitParamDecl *SelfDecl =
-C.getCurrentAnalysisDeclContext()->getSelfDecl();
-  if (!SelfDecl)
-return false;
-
-  const Expr *ReturnExpr = lookThroughImplicitCasts(RS->getRetValue());
-  auto *RefExpr = dyn_cast(ReturnExpr);
-  if (!RefExpr)
-return false;
-
-  return RefExpr->getDecl() == SelfDecl;
-}
-
 /// This method check when nullable pointer or null value is returned from a
 /// function that has nonnull return type.
 ///


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


r259119 - Class Property: change PropertyMap to include isClassProperty.

2016-01-28 Thread Manman Ren via cfe-commits
Author: mren
Date: Thu Jan 28 17:36:05 2016
New Revision: 259119

URL: http://llvm.org/viewvc/llvm-project?rev=259119&view=rev
Log:
Class Property: change PropertyMap to include isClassProperty.

PropertyMap used to map IdentifierInfo (name of the property) to
ObjcPropertyDecl *. Now that a class property can have the same name as
an instance property, we change PropertyMap to map a pair  to ObjcPropertyDecl *.

Also update a few places from iterating over instance_properties to
iterating over all properties.

rdar://23891898

Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=259119&r1=259118&r2=259119&view=diff
==
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Thu Jan 28 17:36:05 2016
@@ -1023,7 +1023,9 @@ public:
   FindPropertyDeclaration(const IdentifierInfo *PropertyId,
   ObjCPropertyQueryKind QueryKind) const;
 
-  typedef llvm::DenseMap PropertyMap;
+  typedef llvm::DenseMap,
+ ObjCPropertyDecl*> PropertyMap;
   
   typedef llvm::DenseMap
 ProtocolPropertyMap;

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=259119&r1=259118&r2=259119&view=diff
==
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Thu Jan 28 17:36:05 2016
@@ -369,14 +369,14 @@ ObjCInterfaceDecl::FindPropertyVisibleIn
 
 void ObjCInterfaceDecl::collectPropertiesToImplement(PropertyMap &PM,
  PropertyDeclOrder &PO) 
const {
-  for (auto *Prop : instance_properties()) {
-PM[Prop->getIdentifier()] = Prop;
+  for (auto *Prop : properties()) {
+PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
 PO.push_back(Prop);
   }
   for (const auto *Ext : known_extensions()) {
 const ObjCCategoryDecl *ClassExt = Ext;
-for (auto *Prop : ClassExt->instance_properties()) {
-  PM[Prop->getIdentifier()] = Prop;
+for (auto *Prop : ClassExt->properties()) {
+  PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = 
Prop;
   PO.push_back(Prop);
 }
   }
@@ -1848,9 +1848,11 @@ void ObjCProtocolDecl::collectProperties
 PropertyDeclOrder &PO) 
const {
   
   if (const ObjCProtocolDecl *PDecl = getDefinition()) {
-for (auto *Prop : PDecl->instance_properties()) {
+for (auto *Prop : PDecl->properties()) {
   // Insert into PM if not there already.
-  PM.insert(std::make_pair(Prop->getIdentifier(), Prop));
+  PM.insert(std::make_pair(
+  std::make_pair(Prop->getIdentifier(), Prop->isClassProperty()),
+  Prop));
   PO.push_back(Prop);
 }
 // Scan through protocol's protocols.

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=259119&r1=259118&r2=259119&view=diff
==
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Thu Jan 28 17:36:05 2016
@@ -1534,8 +1534,9 @@ static void CollectImmediateProperties(O
bool IncludeProtocols = true) {
 
   if (ObjCInterfaceDecl *IDecl = dyn_cast(CDecl)) {
-for (auto *Prop : IDecl->instance_properties())
-  PropMap[Prop->getIdentifier()] = Prop;
+for (auto *Prop : IDecl->properties())
+  PropMap[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] =
+  Prop;
 
 // Collect the properties from visible extensions.
 for (auto *Ext : IDecl->visible_extensions())
@@ -1548,8 +1549,9 @@ static void CollectImmediateProperties(O
 }
   }
   if (ObjCCategoryDecl *CATDecl = dyn_cast(CDecl)) {
-for (auto *Prop : CATDecl->instance_properties())
-  PropMap[Prop->getIdentifier()] = Prop;
+for (auto *Prop : CATDecl->properties())
+  PropMap[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] =
+  Prop;
 if (IncludeProtocols) {
   // Scan through class's protocols.
   for (auto *PI : CATDecl->protocols())
@@ -1557,13 +1559,17 @@ static void CollectImmediateProperties(O
 }
   }
   else if (ObjCProtocolDecl *PDecl = dyn_cast(CDecl)) {
-for (auto *Prop : PDecl->instance_properties()) {
-  ObjCPropertyDecl *PropertyFromSuper = 
SuperPropMap[Prop->getIdentifier()];
+for (auto *Prop : PDecl->properties()) {
+  ObjCPropertyDecl *PropertyF

Re: [PATCH] D16664: [CUDA] Generate CUDA's printf alloca in its function's entry block.

2016-01-28 Thread Justin Lebar via cfe-commits
jlebar marked an inline comment as done.


Comment at: lib/CodeGen/CGCUDABuiltin.cpp:87
@@ +86,3 @@
+  // Construct and fill the args buffer that we'll pass to vprintf.
+  llvm::Value* BufferPtr;
+  if (Args.size() <= 1) {

echristo wrote:
> * on the wrong side ;)
Argh, I really need to set up a linter.  I'm still doing readability reviews, 
and I cannot brain two styles.  Sorry to keep wasting your time with silly 
stuff like this.


http://reviews.llvm.org/D16664



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


Re: [PATCH] D16664: [CUDA] Generate CUDA's printf alloca in its function's entry block.

2016-01-28 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
jlebar marked an inline comment as done.
Closed by commit rL259122: [CUDA] Generate CUDA's printf alloca in its 
function's entry block. (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D16664?vs=46314&id=46323#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16664

Files:
  cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
  cfe/trunk/test/CodeGenCUDA/printf.cu

Index: cfe/trunk/test/CodeGenCUDA/printf.cu
===
--- cfe/trunk/test/CodeGenCUDA/printf.cu
+++ cfe/trunk/test/CodeGenCUDA/printf.cu
@@ -9,45 +9,35 @@
 extern "C" __device__ int vprintf(const char*, const char*);
 
 // Check a simple call to printf end-to-end.
+// CHECK: [[SIMPLE_PRINTF_TY:%[a-zA-Z0-9_]+]] = type { i32, i64, double }
 __device__ int CheckSimple() {
+  // CHECK: [[BUF:%[a-zA-Z0-9_]+]] = alloca [[SIMPLE_PRINTF_TY]]
   // CHECK: [[FMT:%[0-9]+]] = load{{.*}}%fmt
-  const char* fmt = "%d";
-  // CHECK: [[BUF:%[a-zA-Z0-9_]+]] = alloca i8, i32 4, align 4
-  // CHECK: [[PTR:%[0-9]+]] = getelementptr i8, i8* [[BUF]], i32 0
-  // CHECK: [[CAST:%[0-9]+]] = bitcast i8* [[PTR]] to i32*
-  // CHECK: store i32 42, i32* [[CAST]], align 4
-  // CHECK: [[RET:%[0-9]+]] = call i32 @vprintf(i8* [[FMT]], i8* [[BUF]])
+  const char* fmt = "%d %lld %f";
+  // CHECK: [[PTR0:%[0-9]+]] = getelementptr inbounds [[SIMPLE_PRINTF_TY]], [[SIMPLE_PRINTF_TY]]* [[BUF]], i32 0, i32 0
+  // CHECK: store i32 1, i32* [[PTR0]], align 4
+  // CHECK: [[PTR1:%[0-9]+]] = getelementptr inbounds [[SIMPLE_PRINTF_TY]], [[SIMPLE_PRINTF_TY]]* [[BUF]], i32 0, i32 1
+  // CHECK: store i64 2, i64* [[PTR1]], align 8
+  // CHECK: [[PTR2:%[0-9]+]] = getelementptr inbounds [[SIMPLE_PRINTF_TY]], [[SIMPLE_PRINTF_TY]]* [[BUF]], i32 0, i32 2
+  // CHECK: store double 3.0{{[^,]*}}, double* [[PTR2]], align 8
+  // CHECK: [[BUF_CAST:%[0-9]+]] = bitcast [[SIMPLE_PRINTF_TY]]* [[BUF]] to i8*
+  // CHECK: [[RET:%[0-9]+]] = call i32 @vprintf(i8* [[FMT]], i8* [[BUF_CAST]])
   // CHECK: ret i32 [[RET]]
-  return printf(fmt, 42);
-}
-
-// Check that the args' types are promoted correctly when we call printf.
-__device__ void CheckTypes() {
-  // CHECK: alloca {{.*}} align 8
-  // CHECK: getelementptr {{.*}} i32 0
-  // CHECK: bitcast {{.*}} to i32*
-  // CHECK: getelementptr {{.*}} i32 4
-  // CHECK: bitcast {{.*}} to i32*
-  // CHECK: getelementptr {{.*}} i32 8
-  // CHECK: bitcast {{.*}} to double*
-  // CHECK: getelementptr {{.*}} i32 16
-  // CHECK: bitcast {{.*}} to double*
-  printf("%d %d %f %f", (char)1, (short)2, 3.0f, 4.0);
-}
-
-// Check that the args are aligned properly in the buffer.
-__device__ void CheckAlign() {
-  // CHECK: alloca i8, i32 40, align 8
-  // CHECK: getelementptr {{.*}} i32 0
-  // CHECK: getelementptr {{.*}} i32 8
-  // CHECK: getelementptr {{.*}} i32 16
-  // CHECK: getelementptr {{.*}} i32 20
-  // CHECK: getelementptr {{.*}} i32 24
-  // CHECK: getelementptr {{.*}} i32 32
-  printf("%d %f %d %d %d %lld", 1, 2.0, 3, 4, 5, (long long)6);
+  return printf(fmt, 1, 2ll, 3.0);
 }
 
 __device__ void CheckNoArgs() {
   // CHECK: call i32 @vprintf({{.*}}, i8* null){{$}}
   printf("hello, world!");
 }
+
+// Check that printf's alloca happens in the entry block, not inside the if
+// statement.
+__device__ bool foo();
+__device__ void CheckAllocaIsInEntryBlock() {
+  // CHECK: alloca %printf_args
+  // CHECK: call {{.*}} @_Z3foov()
+  if (foo()) {
+printf("%d", 42);
+  }
+}
Index: cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
@@ -52,10 +52,13 @@
 //
 // is converted into something resembling
 //
-//   char* buf = alloca(...);
-//   *reinterpret_cast(buf) = arg1;
-//   *reinterpret_cast(buf + ...) = arg2;
-//   *reinterpret_cast(buf + ...) = arg3;
+//   struct Tmp {
+// Arg1 a1;
+// Arg2 a2;
+// Arg3 a3;
+//   };
+//   char* buf = alloca(sizeof(Tmp));
+//   *(Tmp*)buf = {a1, a2, a3};
 //   vprintf("format string", buf);
 //
 // buf is aligned to the max of {alignof(Arg1), ...}.  Furthermore, each of the
@@ -80,48 +83,24 @@
E->arguments(), E->getDirectCallee(),
/* ParamsToSkip = */ 0);
 
-  // Figure out how large of a buffer we need to hold our varargs and how
-  // aligned the buffer needs to be.  We start iterating at Arg[1], because
-  // that's our first vararg.
-  unsigned BufSize = 0;
-  unsigned BufAlign = 0;
-  for (unsigned I = 1, NumArgs = Args.size(); I < NumArgs; ++I) {
-const RValue& RV = Args[I].RV;
-llvm::Type* Ty = RV.getScalarVal()->getType();
-
-auto Align = DL.getPrefTypeAlignment(Ty);
-BufAlign = std::max(BufAlign, Align);
-// Add padding required to keep the current arg aligned.
-BufSize = llvm::alignTo(BufSize, Align);
-BufSize += DL.getTypeAllocSize(Ty);
-  }
-
-  // Construct and f

r259122 - [CUDA] Generate CUDA's printf alloca in its function's entry block.

2016-01-28 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan 28 17:58:28 2016
New Revision: 259122

URL: http://llvm.org/viewvc/llvm-project?rev=259122&view=rev
Log:
[CUDA] Generate CUDA's printf alloca in its function's entry block.

Summary:
This is necessary to prevent llvm from generating stacksave intrinsics
around this alloca.  NVVM doesn't have a stack, and we don't handle said
intrinsics.

Reviewers: rnk, echristo

Subscribers: cfe-commits, jhen, tra

Differential Revision: http://reviews.llvm.org/D16664

Modified:
cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
cfe/trunk/test/CodeGenCUDA/printf.cu

Modified: cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp?rev=259122&r1=259121&r2=259122&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp Thu Jan 28 17:58:28 2016
@@ -52,10 +52,13 @@ static llvm::Function *GetVprintfDeclara
 //
 // is converted into something resembling
 //
-//   char* buf = alloca(...);
-//   *reinterpret_cast(buf) = arg1;
-//   *reinterpret_cast(buf + ...) = arg2;
-//   *reinterpret_cast(buf + ...) = arg3;
+//   struct Tmp {
+// Arg1 a1;
+// Arg2 a2;
+// Arg3 a3;
+//   };
+//   char* buf = alloca(sizeof(Tmp));
+//   *(Tmp*)buf = {a1, a2, a3};
 //   vprintf("format string", buf);
 //
 // buf is aligned to the max of {alignof(Arg1), ...}.  Furthermore, each of the
@@ -80,48 +83,24 @@ CodeGenFunction::EmitCUDADevicePrintfCal
E->arguments(), E->getDirectCallee(),
/* ParamsToSkip = */ 0);
 
-  // Figure out how large of a buffer we need to hold our varargs and how
-  // aligned the buffer needs to be.  We start iterating at Arg[1], because
-  // that's our first vararg.
-  unsigned BufSize = 0;
-  unsigned BufAlign = 0;
-  for (unsigned I = 1, NumArgs = Args.size(); I < NumArgs; ++I) {
-const RValue& RV = Args[I].RV;
-llvm::Type* Ty = RV.getScalarVal()->getType();
-
-auto Align = DL.getPrefTypeAlignment(Ty);
-BufAlign = std::max(BufAlign, Align);
-// Add padding required to keep the current arg aligned.
-BufSize = llvm::alignTo(BufSize, Align);
-BufSize += DL.getTypeAllocSize(Ty);
-  }
-
-  // Construct and fill the buffer.
-  llvm::Value* BufferPtr = nullptr;
-  if (BufSize == 0) {
+  // Construct and fill the args buffer that we'll pass to vprintf.
+  llvm::Value *BufferPtr;
+  if (Args.size() <= 1) {
 // If there are no args, pass a null pointer to vprintf.
 BufferPtr = llvm::ConstantPointerNull::get(llvm::Type::getInt8PtrTy(Ctx));
   } else {
-BufferPtr = Builder.Insert(new llvm::AllocaInst(
-llvm::Type::getInt8Ty(Ctx), llvm::ConstantInt::get(Int32Ty, BufSize),
-BufAlign, "printf_arg_buf"));
+llvm::SmallVector ArgTypes;
+for (unsigned I = 1, NumArgs = Args.size(); I < NumArgs; ++I)
+  ArgTypes.push_back(Args[I].RV.getScalarVal()->getType());
+llvm::Type *AllocaTy = llvm::StructType::create(ArgTypes, "printf_args");
+llvm::Value *Alloca = CreateTempAlloca(AllocaTy);
 
-unsigned Offset = 0;
 for (unsigned I = 1, NumArgs = Args.size(); I < NumArgs; ++I) {
+  llvm::Value *P = Builder.CreateStructGEP(AllocaTy, Alloca, I - 1);
   llvm::Value *Arg = Args[I].RV.getScalarVal();
-  llvm::Type *Ty = Arg->getType();
-  auto Align = DL.getPrefTypeAlignment(Ty);
-
-  // Pad the buffer to Arg's alignment.
-  Offset = llvm::alignTo(Offset, Align);
-
-  // Store Arg into the buffer at Offset.
-  llvm::Value *GEP =
-  Builder.CreateGEP(BufferPtr, llvm::ConstantInt::get(Int32Ty, 
Offset));
-  llvm::Value *Cast = Builder.CreateBitCast(GEP, Ty->getPointerTo());
-  Builder.CreateAlignedStore(Arg, Cast, Align);
-  Offset += DL.getTypeAllocSize(Ty);
+  Builder.CreateAlignedStore(Arg, P, 
DL.getPrefTypeAlignment(Arg->getType()));
 }
+BufferPtr = Builder.CreatePointerCast(Alloca, 
llvm::Type::getInt8PtrTy(Ctx));
   }
 
   // Invoke vprintf and return.

Modified: cfe/trunk/test/CodeGenCUDA/printf.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/printf.cu?rev=259122&r1=259121&r2=259122&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/printf.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/printf.cu Thu Jan 28 17:58:28 2016
@@ -9,45 +9,35 @@
 extern "C" __device__ int vprintf(const char*, const char*);
 
 // Check a simple call to printf end-to-end.
+// CHECK: [[SIMPLE_PRINTF_TY:%[a-zA-Z0-9_]+]] = type { i32, i64, double }
 __device__ int CheckSimple() {
+  // CHECK: [[BUF:%[a-zA-Z0-9_]+]] = alloca [[SIMPLE_PRINTF_TY]]
   // CHECK: [[FMT:%[0-9]+]] = load{{.*}}%fmt
-  const char* fmt = "%d";
-  // CHECK: [[BUF:%[a-zA-Z0-9_]+]] = alloca i8, i32 4, align 4
-  // CHECK: [[PTR:%[0-9]+]] = getelementptr i8, i8* [[BUF]], i32 0
-  // CHECK: [[CAST:%[0-9]+]] = bitcast 

Re: [PATCH] D16664: [CUDA] Generate CUDA's printf alloca in its function's entry block.

2016-01-28 Thread Eric Christopher via cfe-commits
echristo added inline comments.


Comment at: lib/CodeGen/CGCUDABuiltin.cpp:87
@@ +86,3 @@
+  // Construct and fill the args buffer that we'll pass to vprintf.
+  llvm::Value* BufferPtr;
+  if (Args.size() <= 1) {

jlebar wrote:
> echristo wrote:
> > * on the wrong side ;)
> Argh, I really need to set up a linter.  I'm still doing readability reviews, 
> and I cannot brain two styles.  Sorry to keep wasting your time with silly 
> stuff like this.
You could just use clang-format on everything :)


Repository:
  rL LLVM

http://reviews.llvm.org/D16664



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


Re: [PATCH] D16664: [CUDA] Generate CUDA's printf alloca in its function's entry block.

2016-01-28 Thread Justin Lebar via cfe-commits
Do you have a script that will take as input a commit range and git
commit --amend clang-tidy fixes for lines modified in that range?
Because if so,

a) I would be your best friend forever, and
b) It should be simple to convert that into a linter for arc to catch
the case when I forget to run said tool.

On Thu, Jan 28, 2016 at 4:06 PM, Eric Christopher  wrote:
> echristo added inline comments.
>
> 
> Comment at: lib/CodeGen/CGCUDABuiltin.cpp:87
> @@ +86,3 @@
> +  // Construct and fill the args buffer that we'll pass to vprintf.
> +  llvm::Value* BufferPtr;
> +  if (Args.size() <= 1) {
> 
> jlebar wrote:
>> echristo wrote:
>> > * on the wrong side ;)
>> Argh, I really need to set up a linter.  I'm still doing readability 
>> reviews, and I cannot brain two styles.  Sorry to keep wasting your time 
>> with silly stuff like this.
> You could just use clang-format on everything :)
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D16664
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16664: [CUDA] Generate CUDA's printf alloca in its function's entry block.

2016-01-28 Thread Justin Lebar via cfe-commits
Hm, well, 
https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/git-clang-format
is close...  Not sure if that triggers the bff clause, will consult my
attorney.

On Thu, Jan 28, 2016 at 4:09 PM, Justin Lebar  wrote:
> Do you have a script that will take as input a commit range and git
> commit --amend clang-tidy fixes for lines modified in that range?
> Because if so,
>
> a) I would be your best friend forever, and
> b) It should be simple to convert that into a linter for arc to catch
> the case when I forget to run said tool.
>
> On Thu, Jan 28, 2016 at 4:06 PM, Eric Christopher  wrote:
>> echristo added inline comments.
>>
>> 
>> Comment at: lib/CodeGen/CGCUDABuiltin.cpp:87
>> @@ +86,3 @@
>> +  // Construct and fill the args buffer that we'll pass to vprintf.
>> +  llvm::Value* BufferPtr;
>> +  if (Args.size() <= 1) {
>> 
>> jlebar wrote:
>>> echristo wrote:
>>> > * on the wrong side ;)
>>> Argh, I really need to set up a linter.  I'm still doing readability 
>>> reviews, and I cannot brain two styles.  Sorry to keep wasting your time 
>>> with silly stuff like this.
>> You could just use clang-format on everything :)
>>
>>
>> Repository:
>>   rL LLVM
>>
>> http://reviews.llvm.org/D16664
>>
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16697: Updating .debug_line section version information to match DWARF version.

2016-01-28 Thread Katya Romanova via cfe-commits
kromanova created this revision.
kromanova added reviewers: dblaikie, echristo, probinson.
kromanova added a subscriber: cfe-commits.
kromanova set the repository for this revision to rL LLVM.

Hello,
The compiler always emits .debug_line version 2, though some opcodes from DWARF 
3 (e.g. DW_LNS_set_prologue_end, DW_LNS_set_epilogue_begin or DW_LNS_set_isa) 
and from DWARF 4 could be emitted by the compiler. That's not exactly right.

This patch changes version information of .debug_line to exactly match the 
DWARF version (which is 4 by default).
For .debug_line version 4, a new field maximum_operations_per_instruction is 
emitted. I'm not exactly sure how to set this field correctly for VLIW 
architectures. Hopefully, there are some experts in the community that could 
help out (any Hexagon debuginfo developers out there?).

I’ve tried a few tools to check if they could handle .debug_line version 4.
On a simple testcase, I verified that GDB debugger 7.7 understands .debug_line 
version 4.
Sony’s proprietary debugger can understand it too.
I don't have LLDB built, so I haven’t tried it.
GCC (older version 4.8.2) still emits version 2 for the .debug_line section, 
even though the DWARF version is set to 4. I'm not sure about the latest GCC. 
GNU's readelf (version 2.24) can handle .debug_line version 4.

I added 3 new tests debug-line-version2.ll, debug-line-version3.ll and 
debug-line-version4.ll. The IR is generated from one source using different 
options (-gdwarf-2, -gdwarf-3 and –gdwarf-4). Any idea how to merge these three 
tests into one?

Let me know what do you think about the patch.


Repository:
  rL LLVM

http://reviews.llvm.org/D16697

Files:
  lib/MC/MCDwarf.cpp
  test/DebugInfo/AArch64/line-header.ll
  test/DebugInfo/Generic/debug-line-version2.ll
  test/DebugInfo/Generic/debug-line-version3.ll
  test/DebugInfo/Generic/debug-line-version4.ll
  test/DebugInfo/Generic/empty.ll
  test/DebugInfo/X86/empty.ll
  test/DebugInfo/X86/stmt-list-multiple-compile-units.ll
  test/MC/ELF/debug-line.s
  test/MC/ELF/debug-line2.s
  test/MC/ELF/debug-loc.s
  test/MC/ELF/discriminator.s
  test/MC/ELF/empty-dwarf-lines.s
  test/MC/MachO/file.s
  test/MC/MachO/gen-dwarf.s
  test/MC/MachO/loc.s

Index: test/MC/MachO/loc.s
===
--- test/MC/MachO/loc.s
+++ test/MC/MachO/loc.s
@@ -9,27 +9,27 @@
 // CHECK: Name: __debug_line (5F 5F 64 65 62 75 67 5F 6C 69 6E 65 00 00 00 00)
 // CHECK: Segment: __DWARF (5F 5F 44 57 41 52 46 00 00 00 00 00 00 00 00 00)
 // CHECK: Address: 0x1
-// CHECK: Size: 0x33
+// CHECK: Size: 0x34
 // CHECK: Offset: 237
 // CHECK: Alignment: 0
-// CHECK: RelocationOffset: 0x120
+// CHECK: RelocationOffset: 0x124
 // CHECK: RelocationCount: 1
 // CHECK: Type: 0x0
 // CHECK: Attributes [ (0x2)
 // CHECK:   Debug (0x2)
 // CHECK: ]
 // CHECK: Reserved1: 0x0
 // CHECK: Reserved2: 0x0
 // CHECK: SectionData (
-// CHECK:   : 2F00 02001A00 0101 FB0E0D00  |/...|
-// CHECK:   0010: 01010101 0001 0100 666F6F00  |foo.|
-// CHECK:   0020:  00050200 0003 3F010201  |?...|
-// CHECK:   0030: 000101   |...|
+// CHECK:   : 3000 04001B00 0101 01FB0E0D  |0...|
+// CHECK:   0010: 00010101 0100 0101 00666F6F  |.foo|
+// CHECK:   0020:  0502  033F0102  |.?..|
+// CHECK:   0030: 01000101   
 // CHECK: )
 // CHECK:   }
 // CHECK: ]
 // CHECK: Relocations [
 // CHECK:   Section __debug_line {
-// CHECK: 0x27 0 2 0 GENERIC_RELOC_VANILLA 0 __text
+// CHECK: 0x28 0 2 0 GENERIC_RELOC_VANILLA 0 __text
 // CHECK:   }
 // CHECK: ]
Index: test/MC/MachO/gen-dwarf.s
===
--- test/MC/MachO/gen-dwarf.s
+++ test/MC/MachO/gen-dwarf.s
@@ -89,7 +89,7 @@
 // CHECK: .debug_line contents:
 // CHECK: Line table prologue:
 // We don't check the total_length as it includes lengths of temp paths
-// CHECK: version: 2
+// CHECK: version: 4
 // We don't check the prologue_length as it too includes lengths of temp paths
 // CHECK: min_inst_length: 1
 // CHECK: default_is_stmt: 1
Index: test/MC/MachO/file.s
===
--- test/MC/MachO/file.s
+++ test/MC/MachO/file.s
@@ -8,7 +8,7 @@
 // CHECK-NEXT:Name: __debug_line
 // CHECK-NEXT:Segment: __DWARF
 // CHECK-NEXT:Address: 0x1
-// CHECK-NEXT:Size: 0x28
+// CHECK-NEXT:Size: 0x29
 // CHECK-NEXT:Offset: 237
 // CHECK-NEXT:Alignment: 0
 // CHECK-NEXT:RelocationOffset: 0x0
@@ -20,8 +20,8 @@
 // CHECK-NEXT:Reserved1: 0x0
 // CHECK-NEXT:Reserved2: 0x0
 // CHECK-NEXT:SectionData (
-// CHECK-NEXT:  : 2400 02001E00 0101 FB0E0D00
-// CHECK-NEXT:  0010: 01010101 

Re: [PATCH] D16697: Updating .debug_line section version information to match DWARF version.

2016-01-28 Thread David Blaikie via cfe-commits
+Adrian for Apple/LLDB perspective

One way to merge the tests would be to add another command line argument
into DwarfDebug (see the way the split-dwarf command line argument is
used), just for testing purposes. The command line argument can override
the value specified in the metadata - so you can have one input file for
the 3 different versions.

On Thu, Jan 28, 2016 at 4:28 PM, Katya Romanova via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> kromanova created this revision.
> kromanova added reviewers: dblaikie, echristo, probinson.
> kromanova added a subscriber: cfe-commits.
> kromanova set the repository for this revision to rL LLVM.
>
> Hello,
> The compiler always emits .debug_line version 2, though some opcodes from
> DWARF 3 (e.g. DW_LNS_set_prologue_end, DW_LNS_set_epilogue_begin or
> DW_LNS_set_isa) and from DWARF 4 could be emitted by the compiler. That's
> not exactly right.
>
> This patch changes version information of .debug_line to exactly match the
> DWARF version (which is 4 by default).
> For .debug_line version 4, a new field maximum_operations_per_instruction
> is emitted. I'm not exactly sure how to set this field correctly for VLIW
> architectures. Hopefully, there are some experts in the community that
> could help out (any Hexagon debuginfo developers out there?).
>
> I’ve tried a few tools to check if they could handle .debug_line version 4.
> On a simple testcase, I verified that GDB debugger 7.7 understands
> .debug_line version 4.
> Sony’s proprietary debugger can understand it too.
> I don't have LLDB built, so I haven’t tried it.
> GCC (older version 4.8.2) still emits version 2 for the .debug_line
> section, even though the DWARF version is set to 4. I'm not sure about the
> latest GCC.
> GNU's readelf (version 2.24) can handle .debug_line version 4.
>
> I added 3 new tests debug-line-version2.ll, debug-line-version3.ll and
> debug-line-version4.ll. The IR is generated from one source using different
> options (-gdwarf-2, -gdwarf-3 and –gdwarf-4). Any idea how to merge these
> three tests into one?
>
> Let me know what do you think about the patch.
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D16697
>
> Files:
>   lib/MC/MCDwarf.cpp
>   test/DebugInfo/AArch64/line-header.ll
>   test/DebugInfo/Generic/debug-line-version2.ll
>   test/DebugInfo/Generic/debug-line-version3.ll
>   test/DebugInfo/Generic/debug-line-version4.ll
>   test/DebugInfo/Generic/empty.ll
>   test/DebugInfo/X86/empty.ll
>   test/DebugInfo/X86/stmt-list-multiple-compile-units.ll
>   test/MC/ELF/debug-line.s
>   test/MC/ELF/debug-line2.s
>   test/MC/ELF/debug-loc.s
>   test/MC/ELF/discriminator.s
>   test/MC/ELF/empty-dwarf-lines.s
>   test/MC/MachO/file.s
>   test/MC/MachO/gen-dwarf.s
>   test/MC/MachO/loc.s
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >