-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement overrides for llvm.is.fpclass and friends (#1110)
This is primarily motivated by Clang 17 being more eager to compile the `isnan` function into `llvm.is.fpclass`, so this patch is required to make the `isnan.c` test case pass with Clang 17 or later. The machinery used to implement an override for `llvm.is.fpclass` can also be used to implement overrides for the related `isinf` function, so we also do this. Checks off some boxes in #187.
- Loading branch information
1 parent
602cb8f
commit 3bdafe4
Showing
17 changed files
with
1,071 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#define _GNU_SOURCE | ||
#include <crucible.h> | ||
#include <math.h> | ||
|
||
int main(void) { | ||
//////////// | ||
// double // | ||
//////////// | ||
double d1 = 42.5; // Finite | ||
double d2 = INFINITY; // Infinite | ||
double d3 = NAN; // Not infinite (and also not finite) | ||
|
||
check(isfinite(d1)); | ||
check(!(isfinite(d2))); | ||
check(!(isfinite(d3))); | ||
|
||
check(__builtin_isfinite(d1)); | ||
check(!(__builtin_isfinite(d2))); | ||
check(!(__builtin_isfinite(d3))); | ||
|
||
/////////// | ||
// float // | ||
/////////// | ||
float f1 = 42.5f; // Finite | ||
float f2 = INFINITY; // Infinite | ||
float f3 = NAN; // Not infinite (and also not finite) | ||
|
||
check(isfinite(f1)); | ||
check(!(isfinite(f2))); | ||
check(!(isfinite(f3))); | ||
|
||
check(__builtin_isfinite(f1)); | ||
check(!(__builtin_isfinite(f2))); | ||
check(!(__builtin_isfinite(f3))); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
opt-level: 0 | ||
solver: "z3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[Crux] Overall status: Valid. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#define _GNU_SOURCE | ||
#include <crucible.h> | ||
#include <math.h> | ||
|
||
int main(void) { | ||
//////////// | ||
// double // | ||
//////////// | ||
double d1 = 42.5; // Finite | ||
double d2 = INFINITY; // Infinite | ||
double d3 = -INFINITY; // Infinite | ||
double d4 = NAN; // Not infinite (and also not finite) | ||
|
||
check(isinf(d1) == 0); | ||
check(isinf(d2) == 1); | ||
check(isinf(d3) == -1); | ||
check(isinf(d4) == 0); | ||
|
||
// The parentheses around (isinf) are important here, as this instructs Clang | ||
// to compile isinf as a direct function call rather than as a macro. | ||
check((isinf)(d1) == 0); | ||
check((isinf)(d2) == 1); | ||
check((isinf)(d3) == -1); | ||
check((isinf)(d4) == 0); | ||
|
||
check(__isinf(d1) == 0); | ||
check(__isinf(d2) == 1); | ||
check(__isinf(d3) == -1); | ||
check(__isinf(d4) == 0); | ||
|
||
check(__builtin_isinf_sign(d1) == 0); | ||
check(__builtin_isinf_sign(d2) == 1); | ||
check(__builtin_isinf_sign(d3) == -1); | ||
check(__builtin_isinf_sign(d4) == 0); | ||
|
||
/////////// | ||
// float // | ||
/////////// | ||
float f1 = 42.5f; // Finite | ||
float f2 = INFINITY; // Infinite | ||
float f3 = -INFINITY; // Infinite | ||
float f4 = NAN; // Not infinite (and also not finite) | ||
|
||
check(isinf(f1) == 0); | ||
check(isinf(f2) == 1); | ||
check(isinf(f3) == -1); | ||
check(isinf(f4) == 0); | ||
|
||
check((isinf)(f1) == 0); | ||
check((isinf)(f2) == 1); | ||
check((isinf)(f3) == -1); | ||
check((isinf)(f4) == 0); | ||
|
||
check(__isinff(f1) == 0); | ||
check(__isinff(f2) == 1); | ||
check(__isinff(f3) == -1); | ||
check(__isinff(f4) == 0); | ||
|
||
check(__builtin_isinf_sign(f1) == 0); | ||
check(__builtin_isinf_sign(f2) == 1); | ||
check(__builtin_isinf_sign(f3) == -1); | ||
check(__builtin_isinf_sign(f4) == 0); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
opt-level: 0 | ||
solver: "z3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[Crux] Overall status: Valid. |
Oops, something went wrong.