[PATCH] D48443: [WIP] Add no-prototype attribute to prototype-less C functions

2018-06-21 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google added a comment.

Looks very reasonable and straightforward. LGTM in spirit, but I'll wait for 
someone who knows Clang better.


Repository:
  rC Clang

https://reviews.llvm.org/D48443



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


[PATCH] D66035: [WebAssembly] WIP: Add support for reference types

2019-08-12 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google added a comment.

Overall direction looks good to me as well.

Ditto that tests would be useful just to make it clearer how this is 
represented in IR.




Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h:47
+  MVT getPointerTy(const DataLayout &DL, uint32_t AS = 0) const override {
+return AS == 1 ? MVT::anyref :
+  MVT::getIntegerVT(DL.getPointerSizeInBits(AS));

We'll almost-surely want to pull this `1` out into a constant, 
`WasmAnyrefAddressSpace` or something


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66035



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


[PATCH] D36989: [clang-diff] Refactor stop-after command-line flag

2017-08-21 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google created this revision.
Herald added subscribers: aheejin, klimek.

Rename stop-after to stop-after-topdown. When building LLVM with
-DLLVM_BUILD_LLVM_DYLIB=ON, stop-after collides with the stop-after
already present in LLVM.

This also refactors the flag to a boolean, to reflect that it can only
be in two states.


https://reviews.llvm.org/D36989

Files:
  lib/Tooling/ASTDiff/ASTDiff.cpp
  test/Tooling/clang-diff-topdown.cpp
  tools/clang-diff/ClangDiff.cpp


Index: tools/clang-diff/ClangDiff.cpp
===
--- tools/clang-diff/ClangDiff.cpp
+++ tools/clang-diff/ClangDiff.cpp
@@ -21,7 +21,7 @@
 using namespace clang;
 using namespace clang::tooling;
 
-static cl::OptionCategory ClangDiffCategory("clang-diff options");
+cl::OptionCategory ClangDiffCategory("clang-diff options");
 
 static cl::opt
 ASTDump("ast-dump",
@@ -50,11 +50,6 @@
 cl::Optional,
 cl::cat(ClangDiffCategory));
 
-static cl::opt StopAfter("stop-after",
-  cl::desc(""),
-  cl::Optional, cl::init(""),
-  cl::cat(ClangDiffCategory));
-
 static cl::opt MaxSize("s", cl::desc(""), cl::Optional,
 cl::init(-1), cl::cat(ClangDiffCategory));
 
@@ -442,14 +437,6 @@
   diff::ComparisonOptions Options;
   if (MaxSize != -1)
 Options.MaxSize = MaxSize;
-  if (!StopAfter.empty()) {
-if (StopAfter == "topdown")
-  Options.StopAfterTopDown = true;
-else if (StopAfter != "bottomup") {
-  llvm::errs() << "Error: Invalid argument for -stop-after\n";
-  return 1;
-}
-  }
   diff::SyntaxTree SrcTree(Src->getASTContext());
   diff::SyntaxTree DstTree(Dst->getASTContext());
   diff::ASTDiff Diff(SrcTree, DstTree, Options);
Index: test/Tooling/clang-diff-topdown.cpp
===
--- test/Tooling/clang-diff-topdown.cpp
+++ test/Tooling/clang-diff-topdown.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -E %s > %t.src.cpp
 // RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST
-// RUN: clang-diff -dump-matches -stop-after=topdown %t.src.cpp %t.dst.cpp -- 
-std=c++11 | FileCheck %s
+// RUN: clang-diff -dump-matches -stop-after-topdown %t.src.cpp %t.dst.cpp -- 
-std=c++11 | FileCheck %s
 //
 // Test the top-down matching of identical subtrees only.
 
Index: lib/Tooling/ASTDiff/ASTDiff.cpp
===
--- lib/Tooling/ASTDiff/ASTDiff.cpp
+++ lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -16,14 +16,21 @@
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/PriorityQueue.h"
+#include "llvm/Support/CommandLine.h"
 
 #include 
 #include 
 #include 
 
 using namespace llvm;
 using namespace clang;
 
+extern cl::OptionCategory ClangDiffCategory;
+static cl::opt StopAfterTopDown("stop-after-topdown",
+  cl::desc("Stops after top-down 
matching"),
+  cl::Optional, cl::init(false),
+  cl::cat(ClangDiffCategory));
+
 namespace clang {
 namespace diff {
 
@@ -891,7 +898,7 @@
 
 void ASTDiff::Impl::computeMapping() {
   TheMapping = matchTopDown();
-  if (Options.StopAfterTopDown)
+  if (StopAfterTopDown)
 return;
   matchBottomUp(TheMapping);
 }


Index: tools/clang-diff/ClangDiff.cpp
===
--- tools/clang-diff/ClangDiff.cpp
+++ tools/clang-diff/ClangDiff.cpp
@@ -21,7 +21,7 @@
 using namespace clang;
 using namespace clang::tooling;
 
-static cl::OptionCategory ClangDiffCategory("clang-diff options");
+cl::OptionCategory ClangDiffCategory("clang-diff options");
 
 static cl::opt
 ASTDump("ast-dump",
@@ -50,11 +50,6 @@
 cl::Optional,
 cl::cat(ClangDiffCategory));
 
-static cl::opt StopAfter("stop-after",
-  cl::desc(""),
-  cl::Optional, cl::init(""),
-  cl::cat(ClangDiffCategory));
-
 static cl::opt MaxSize("s", cl::desc(""), cl::Optional,
 cl::init(-1), cl::cat(ClangDiffCategory));
 
@@ -442,14 +437,6 @@
   diff::ComparisonOptions Options;
   if (MaxSize != -1)
 Options.MaxSize = MaxSize;
-  if (!StopAfter.empty()) {
-if (StopAfter == "topdown")
-  Options.StopAfterTopDown = true;
-else if (StopAfter != "bottomup") {
-  llvm::errs() << "Error: Invalid argument for -stop-after\n";
-  return 1;
-}
-  }
   diff::SyntaxTree SrcTree(Src->getASTContext());
   diff::SyntaxTree DstTree(Dst->getASTContext());
   diff::ASTDiff Diff(SrcTree, DstTree, Options);
Index: test/Tooling/clang-diff-topdown.cpp
==

[PATCH] D36989: [clang-diff] Refactor stop-after command-line flag

2017-08-22 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google added a comment.

If you have more stop-after options it'd probably be simpler to leave it as one 
field. I'll just rename it to "stop-diff-after" to avoid the name collision.


https://reviews.llvm.org/D36989



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


[PATCH] D36989: [clang-diff] Refactor stop-after command-line flag

2017-08-22 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google updated this revision to Diff 112193.
jgravelle-google added a comment.

- Undo refactor, just change name


https://reviews.llvm.org/D36989

Files:
  test/Tooling/clang-diff-topdown.cpp
  tools/clang-diff/ClangDiff.cpp


Index: tools/clang-diff/ClangDiff.cpp
===
--- tools/clang-diff/ClangDiff.cpp
+++ tools/clang-diff/ClangDiff.cpp
@@ -50,7 +50,7 @@
 cl::Optional,
 cl::cat(ClangDiffCategory));
 
-static cl::opt StopAfter("stop-after",
+static cl::opt StopAfter("stop-diff-after",
   cl::desc(""),
   cl::Optional, cl::init(""),
   cl::cat(ClangDiffCategory));
Index: test/Tooling/clang-diff-topdown.cpp
===
--- test/Tooling/clang-diff-topdown.cpp
+++ test/Tooling/clang-diff-topdown.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -E %s > %t.src.cpp
 // RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST
-// RUN: clang-diff -dump-matches -stop-after=topdown %t.src.cpp %t.dst.cpp -- 
-std=c++11 | FileCheck %s
+// RUN: clang-diff -dump-matches -stop-diff-after=topdown %t.src.cpp 
%t.dst.cpp -- -std=c++11 | FileCheck %s
 //
 // Test the top-down matching of identical subtrees only.
 


Index: tools/clang-diff/ClangDiff.cpp
===
--- tools/clang-diff/ClangDiff.cpp
+++ tools/clang-diff/ClangDiff.cpp
@@ -50,7 +50,7 @@
 cl::Optional,
 cl::cat(ClangDiffCategory));
 
-static cl::opt StopAfter("stop-after",
+static cl::opt StopAfter("stop-diff-after",
   cl::desc(""),
   cl::Optional, cl::init(""),
   cl::cat(ClangDiffCategory));
Index: test/Tooling/clang-diff-topdown.cpp
===
--- test/Tooling/clang-diff-topdown.cpp
+++ test/Tooling/clang-diff-topdown.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -E %s > %t.src.cpp
 // RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST
-// RUN: clang-diff -dump-matches -stop-after=topdown %t.src.cpp %t.dst.cpp -- -std=c++11 | FileCheck %s
+// RUN: clang-diff -dump-matches -stop-diff-after=topdown %t.src.cpp %t.dst.cpp -- -std=c++11 | FileCheck %s
 //
 // Test the top-down matching of identical subtrees only.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28381: [WebAssembly] Always inline atomics

2017-01-05 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google created this revision.
jgravelle-google added reviewers: dschuff, sunfish.
jgravelle-google added a subscriber: cfe-commits.
Herald added a subscriber: jfb.

Wasm MVP doesn't have any mechanism to respect atomicity. Skip emitting
libcalls for the time being.


https://reviews.llvm.org/D28381

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8610,7 +8610,7 @@
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_INT_LOCK_FREE 2
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LONG_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_POINTER_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 2
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8137,7 +8137,8 @@
   explicit WebAssembly32TargetInfo(const llvm::Triple &T,
const TargetOptions &Opts)
   : WebAssemblyTargetInfo(T, Opts) {
-MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
+// WebAssembly MVP has no way to express atomics, so always inline them
+MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128");
   }
 


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8610,7 +8610,7 @@
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_INT_LOCK_FREE 2
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LONG_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_POINTER_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 2
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8137,7 +8137,8 @@
   explicit WebAssembly32TargetInfo(const llvm::Triple &T,
const TargetOptions &Opts)
   : WebAssemblyTargetInfo(T, Opts) {
-MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
+// WebAssembly MVP has no way to express atomics, so always inline them
+MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128");
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28381: [WebAssembly] Always inline atomics

2017-01-06 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google added a comment.

In https://reviews.llvm.org/D28381#637915, @sunfish wrote:

> Would it be difficult to enable atomic.c in Emscripten's compiler-rt build, 
> to define these libcalls (assuming that the problem is just that they're not 
> currently defined)?


Tried it and it seems to work. I needed to add `-mthread-model single` to the 
compiler_rt build flags to get it to build. Which makes me think we'll have 
issues when we actually support "posix".

> Alternatively, could we make the change in the patch guarded by `if 
> (CodeGenOpts.ThreadModel == "single")` or so, so that it doesn't affect the 
> "posix" case?

We don't have access to `GodeGenOpts` in the constructor as far as I know, and 
the only `TargetInfo` method that does is `adjustTargetOptions`, which is 
`const` for the target.

My ideal patch here is to make the smallest change that doesn't need to be 
totally undone later, that also avoids making assumptions about how we'll 
implement wasm atomics down the line.
Talked with @dschuff, and we're probably going to go the compiler-rt route. 
Need to first explore whether it'd be saner to just drop in the real atomic.c 
or to stub one out for now.


https://reviews.llvm.org/D28381



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


[PATCH] D28381: [WebAssembly] Always inline atomics

2017-01-13 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google abandoned this revision.
jgravelle-google added a comment.

Abandoning this in favor of https://github.com/kripken/emscripten/pull/4846


https://reviews.llvm.org/D28381



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


[PATCH] D29736: [WebAssembly] Add target specific overrides for lgamma family functions

2017-02-08 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google created this revision.
Herald added a subscriber: jfb.

Current WebAssembly implementations use musl libc, which writes to
signgam in its lgamma functions. We want the rest of the builtins to be
const under -fno-math-errno, so overwrite lgamma's builtin definitions
to be never-const.


https://reviews.llvm.org/D29736

Files:
  include/clang/Basic/BuiltinsWebAssembly.def


Index: include/clang/Basic/BuiltinsWebAssembly.def
===
--- include/clang/Basic/BuiltinsWebAssembly.def
+++ include/clang/Basic/BuiltinsWebAssembly.def
@@ -16,9 +16,21 @@
 
 // The format of this database matches clang/Basic/Builtins.def.
 
+#if defined(BUILTIN) && !defined(LIBBUILTIN)
+#  define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
 // Note that current_memory is not "c" (readnone) because it must be sequenced
 // with respect to grow_memory calls.
 BUILTIN(__builtin_wasm_current_memory, "z", "n")
 BUILTIN(__builtin_wasm_grow_memory, "zz", "n")
 
+// Redeclaring lgamma from Builtins.def as non-const to allow for POSIX
+// compatibility. Specifically lgamma writes to a user-visible global, signgam,
+// that is available in POSIX-compliant libcs.
+LIBBUILTIN(lgamma, "dd", "fn", "math.h")
+LIBBUILTIN(lgammaf, "ff", "fn", "math.h")
+LIBBUILTIN(lgammal, "LdLd", "fn", "math.h")
+
 #undef BUILTIN
+#undef LIBBUILTIN


Index: include/clang/Basic/BuiltinsWebAssembly.def
===
--- include/clang/Basic/BuiltinsWebAssembly.def
+++ include/clang/Basic/BuiltinsWebAssembly.def
@@ -16,9 +16,21 @@
 
 // The format of this database matches clang/Basic/Builtins.def.
 
+#if defined(BUILTIN) && !defined(LIBBUILTIN)
+#  define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
 // Note that current_memory is not "c" (readnone) because it must be sequenced
 // with respect to grow_memory calls.
 BUILTIN(__builtin_wasm_current_memory, "z", "n")
 BUILTIN(__builtin_wasm_grow_memory, "zz", "n")
 
+// Redeclaring lgamma from Builtins.def as non-const to allow for POSIX
+// compatibility. Specifically lgamma writes to a user-visible global, signgam,
+// that is available in POSIX-compliant libcs.
+LIBBUILTIN(lgamma, "dd", "fn", "math.h")
+LIBBUILTIN(lgammaf, "ff", "fn", "math.h")
+LIBBUILTIN(lgammal, "LdLd", "fn", "math.h")
+
 #undef BUILTIN
+#undef LIBBUILTIN
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29736: [WebAssembly] Add target specific overrides for lgamma family functions

2017-02-09 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google added a comment.

https://clang.llvm.org/compatibility.html doesn't mention anything about POSIX, 
only C11 compliance, so I didn't think Clang in general cared about POSIX.
That being said I can definitely agree that Clang shouldn't preclude POSIX. 
I'll open a more-general diff.


https://reviews.llvm.org/D29736



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


[PATCH] D29778: Declare lgamma library builtins as never being const

2017-02-09 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google created this revision.

POSIX requires lgamma writes to an external global variable, signgam.
This prevents annotating lgamma with readnone, which is incorrect on
targets that write to signgam.


https://reviews.llvm.org/D29778

Files:
  include/clang/Basic/Builtins.def
  test/CodeGen/libcall-declarations.c


Index: test/CodeGen/libcall-declarations.c
===
--- test/CodeGen/libcall-declarations.c
+++ test/CodeGen/libcall-declarations.c
@@ -402,9 +402,9 @@
 // CHECK-NOERRNO: declare i32 @ilogb(double) [[NUW]]
 // CHECK-NOERRNO: declare i32 @ilogbf(float) [[NUW]]
 // CHECK-NOERRNO: declare i32 @ilogbl(x86_fp80) [[NUW]]
-// CHECK-NOERRNO: declare double @lgamma(double) [[NUW]]
-// CHECK-NOERRNO: declare float @lgammaf(float) [[NUW]]
-// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NUW]]
+// CHECK-NOERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-NOERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
 // CHECK-NOERRNO: declare i64 @llrint(double) [[NUW]]
 // CHECK-NOERRNO: declare i64 @llrintf(float) [[NUW]]
 // CHECK-NOERRNO: declare i64 @llrintl(x86_fp80) [[NUW]]
@@ -554,6 +554,9 @@
 // CHECK-ERRNO: declare double @fmin(double, double) [[NUW]]
 // CHECK-ERRNO: declare float @fminf(float, float) [[NUW]]
 // CHECK-ERRNO: declare x86_fp80 @fminl(x86_fp80, x86_fp80) [[NUW]]
+// CHECK-ERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-ERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-ERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
 // CHECK-ERRNO: declare double @nearbyint(double) [[NUW]]
 // CHECK-ERRNO: declare float @nearbyintf(float) [[NUW]]
 // CHECK-ERRNO: declare x86_fp80 @nearbyintl(x86_fp80) [[NUW]]
@@ -612,5 +615,11 @@
 // CHECK-ERRNO: declare <2 x float> @ctanhf(<2 x float>) [[NUW]]
 
 // CHECK-NOERRNO: attributes [[NUW]] = { nounwind readnone{{.*}} }
+// CHECK-NOERRNO: attributes [[NONCONST]] = {
+// CHECK-NOERRNO-NOT: readnone
+// CHECK-NOERRNO-SAME: nounwind{{.*}} }
 
+// CHECK-ERRNO: attributes [[NONCONST]] = {
+// CHECK-ERRNO-NOT: readnone
+// CHECK-ERRNO-SAME: nounwind{{.*}} }
 // CHECK-ERRNO: attributes [[NUW]] = { nounwind readnone{{.*}} }
Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -1086,9 +1086,9 @@
 LIBBUILTIN(ilogbf, "if", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(ilogbl, "iLd", "fne", "math.h", ALL_LANGUAGES)
 
-LIBBUILTIN(lgamma, "dd", "fne", "math.h", ALL_LANGUAGES)
-LIBBUILTIN(lgammaf, "ff", "fne", "math.h", ALL_LANGUAGES)
-LIBBUILTIN(lgammal, "LdLd", "fne", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(lgamma, "dd", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(lgammaf, "ff", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(lgammal, "LdLd", "fn", "math.h", ALL_LANGUAGES)
 
 LIBBUILTIN(llrint, "LLid", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(llrintf, "LLif", "fne", "math.h", ALL_LANGUAGES)


Index: test/CodeGen/libcall-declarations.c
===
--- test/CodeGen/libcall-declarations.c
+++ test/CodeGen/libcall-declarations.c
@@ -402,9 +402,9 @@
 // CHECK-NOERRNO: declare i32 @ilogb(double) [[NUW]]
 // CHECK-NOERRNO: declare i32 @ilogbf(float) [[NUW]]
 // CHECK-NOERRNO: declare i32 @ilogbl(x86_fp80) [[NUW]]
-// CHECK-NOERRNO: declare double @lgamma(double) [[NUW]]
-// CHECK-NOERRNO: declare float @lgammaf(float) [[NUW]]
-// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NUW]]
+// CHECK-NOERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-NOERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
 // CHECK-NOERRNO: declare i64 @llrint(double) [[NUW]]
 // CHECK-NOERRNO: declare i64 @llrintf(float) [[NUW]]
 // CHECK-NOERRNO: declare i64 @llrintl(x86_fp80) [[NUW]]
@@ -554,6 +554,9 @@
 // CHECK-ERRNO: declare double @fmin(double, double) [[NUW]]
 // CHECK-ERRNO: declare float @fminf(float, float) [[NUW]]
 // CHECK-ERRNO: declare x86_fp80 @fminl(x86_fp80, x86_fp80) [[NUW]]
+// CHECK-ERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-ERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-ERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
 // CHECK-ERRNO: declare double @nearbyint(double) [[NUW]]
 // CHECK-ERRNO: declare float @nearbyintf(float) [[NUW]]
 // CHECK-ERRNO: declare x86_fp80 @nearbyintl(x86_fp80) [[NUW]]
@@ -612,5 +615,11 @@
 // CHECK-ERRNO: declare <2 x float> @ctanhf(<2 x float>) [[NUW]]
 
 // CHECK-NOERRNO: attributes [[NUW]] = { nounwind readnone{{.*}} }
+// CHECK-NOERRNO: attributes [[NONCONST]] = {
+// CHECK-NOERRNO-NOT: readnone
+// CHECK-NOERRNO-SAME: nounwind{{.*}} }
 
+// CHECK-ERRNO: attributes [[NONCONST]] = {
+// CHECK-ERRNO-NOT: readnone
+// CHECK-ERRNO-SAME: nounwind{{.*}} 

[PATCH] D29778: Declare lgamma library builtins as never being const

2017-02-15 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google updated this revision to Diff 88629.
jgravelle-google added a comment.

- Add comment to lgamma builtins


https://reviews.llvm.org/D29778

Files:
  include/clang/Basic/Builtins.def
  test/CodeGen/libcall-declarations.c


Index: test/CodeGen/libcall-declarations.c
===
--- test/CodeGen/libcall-declarations.c
+++ test/CodeGen/libcall-declarations.c
@@ -402,9 +402,9 @@
 // CHECK-NOERRNO: declare i32 @ilogb(double) [[NUW]]
 // CHECK-NOERRNO: declare i32 @ilogbf(float) [[NUW]]
 // CHECK-NOERRNO: declare i32 @ilogbl(x86_fp80) [[NUW]]
-// CHECK-NOERRNO: declare double @lgamma(double) [[NUW]]
-// CHECK-NOERRNO: declare float @lgammaf(float) [[NUW]]
-// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NUW]]
+// CHECK-NOERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-NOERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
 // CHECK-NOERRNO: declare i64 @llrint(double) [[NUW]]
 // CHECK-NOERRNO: declare i64 @llrintf(float) [[NUW]]
 // CHECK-NOERRNO: declare i64 @llrintl(x86_fp80) [[NUW]]
@@ -554,6 +554,9 @@
 // CHECK-ERRNO: declare double @fmin(double, double) [[NUW]]
 // CHECK-ERRNO: declare float @fminf(float, float) [[NUW]]
 // CHECK-ERRNO: declare x86_fp80 @fminl(x86_fp80, x86_fp80) [[NUW]]
+// CHECK-ERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-ERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-ERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
 // CHECK-ERRNO: declare double @nearbyint(double) [[NUW]]
 // CHECK-ERRNO: declare float @nearbyintf(float) [[NUW]]
 // CHECK-ERRNO: declare x86_fp80 @nearbyintl(x86_fp80) [[NUW]]
@@ -612,5 +615,11 @@
 // CHECK-ERRNO: declare <2 x float> @ctanhf(<2 x float>) [[NUW]]
 
 // CHECK-NOERRNO: attributes [[NUW]] = { nounwind readnone{{.*}} }
+// CHECK-NOERRNO: attributes [[NONCONST]] = {
+// CHECK-NOERRNO-NOT: readnone
+// CHECK-NOERRNO-SAME: nounwind{{.*}} }
 
+// CHECK-ERRNO: attributes [[NONCONST]] = {
+// CHECK-ERRNO-NOT: readnone
+// CHECK-ERRNO-SAME: nounwind{{.*}} }
 // CHECK-ERRNO: attributes [[NUW]] = { nounwind readnone{{.*}} }
Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -1086,9 +1086,11 @@
 LIBBUILTIN(ilogbf, "if", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(ilogbl, "iLd", "fne", "math.h", ALL_LANGUAGES)
 
-LIBBUILTIN(lgamma, "dd", "fne", "math.h", ALL_LANGUAGES)
-LIBBUILTIN(lgammaf, "ff", "fne", "math.h", ALL_LANGUAGES)
-LIBBUILTIN(lgammal, "LdLd", "fne", "math.h", ALL_LANGUAGES)
+// POSIX math.h declares a global, signgam, that lgamma writes to, so these
+// shouldn't have "e" or "c" attributes
+LIBBUILTIN(lgamma, "dd", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(lgammaf, "ff", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(lgammal, "LdLd", "fn", "math.h", ALL_LANGUAGES)
 
 LIBBUILTIN(llrint, "LLid", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(llrintf, "LLif", "fne", "math.h", ALL_LANGUAGES)


Index: test/CodeGen/libcall-declarations.c
===
--- test/CodeGen/libcall-declarations.c
+++ test/CodeGen/libcall-declarations.c
@@ -402,9 +402,9 @@
 // CHECK-NOERRNO: declare i32 @ilogb(double) [[NUW]]
 // CHECK-NOERRNO: declare i32 @ilogbf(float) [[NUW]]
 // CHECK-NOERRNO: declare i32 @ilogbl(x86_fp80) [[NUW]]
-// CHECK-NOERRNO: declare double @lgamma(double) [[NUW]]
-// CHECK-NOERRNO: declare float @lgammaf(float) [[NUW]]
-// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NUW]]
+// CHECK-NOERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-NOERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
 // CHECK-NOERRNO: declare i64 @llrint(double) [[NUW]]
 // CHECK-NOERRNO: declare i64 @llrintf(float) [[NUW]]
 // CHECK-NOERRNO: declare i64 @llrintl(x86_fp80) [[NUW]]
@@ -554,6 +554,9 @@
 // CHECK-ERRNO: declare double @fmin(double, double) [[NUW]]
 // CHECK-ERRNO: declare float @fminf(float, float) [[NUW]]
 // CHECK-ERRNO: declare x86_fp80 @fminl(x86_fp80, x86_fp80) [[NUW]]
+// CHECK-ERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-ERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-ERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
 // CHECK-ERRNO: declare double @nearbyint(double) [[NUW]]
 // CHECK-ERRNO: declare float @nearbyintf(float) [[NUW]]
 // CHECK-ERRNO: declare x86_fp80 @nearbyintl(x86_fp80) [[NUW]]
@@ -612,5 +615,11 @@
 // CHECK-ERRNO: declare <2 x float> @ctanhf(<2 x float>) [[NUW]]
 
 // CHECK-NOERRNO: attributes [[NUW]] = { nounwind readnone{{.*}} }
+// CHECK-NOERRNO: attributes [[NONCONST]] = {
+// CHECK-NOERRNO-NOT: readnone
+// CHECK-NOERRNO-SAME: nounwind{{.*}} }
 
+// CHECK-ERRNO: attributes [[NONCONST]] = {
+// CHECK-ERRNO-NOT: readnone
+// CHE

[PATCH] D29778: Declare lgamma library builtins as never being const

2017-02-15 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google marked an inline comment as done.
jgravelle-google added a comment.

Thanks, added a comment


https://reviews.llvm.org/D29778



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