Skip to content

Commit 9016514

Browse files
committed
Revert "[clang][Interp] Implement __builtin_isnan()"
This reverts commit 8ad9dcb. This breaks builders: https://lab.llvm.org/buildbot/#/builders/139/builds/46363/steps/6/logs/FAIL__Clang__constant-builtins-fmin_cpp Revert while I figure out what's going wrong.
1 parent 8ad9dcb commit 9016514

File tree

6 files changed

+3
-56
lines changed

6 files changed

+3
-56
lines changed

clang/lib/AST/Interp/Function.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "Function.h"
10-
#include "Opcode.h"
1110
#include "Program.h"
11+
#include "Opcode.h"
1212
#include "clang/AST/Decl.h"
1313
#include "clang/AST/DeclCXX.h"
14-
#include "clang/Basic/Builtins.h"
1514

1615
using namespace clang;
1716
using namespace clang::interp;
@@ -48,9 +47,3 @@ bool Function::isVirtual() const {
4847
return M->isVirtual();
4948
return false;
5049
}
51-
52-
bool Function::needsRuntimeArgPop(const ASTContext &Ctx) const {
53-
if (!isBuiltin())
54-
return false;
55-
return Ctx.BuiltinInfo.hasCustomTypechecking(getBuiltinID());
56-
}

clang/lib/AST/Interp/Function.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,6 @@ class Function final {
171171

172172
unsigned getBuiltinID() const { return F->getBuiltinID(); }
173173

174-
bool isBuiltin() const { return F->getBuiltinID() != 0; }
175-
176-
/// Does this function need its arguments to be classified at runtime
177-
/// rather than at bytecode-compile-time?
178-
bool needsRuntimeArgPop(const ASTContext &Ctx) const;
179-
180174
unsigned getNumParams() const { return ParamTypes.size(); }
181175

182176
unsigned getParamOffset(unsigned ParamIndex) const {

clang/lib/AST/Interp/Interp.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,6 @@ static bool CheckGlobal(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
122122
namespace clang {
123123
namespace interp {
124124

125-
bool popBuiltinArgs(InterpState &S, CodePtr OpPC) {
126-
assert(S.Current && S.Current->getFunction()->needsRuntimeArgPop(S.getCtx()));
127-
const Expr *E = S.Current->getExpr(OpPC);
128-
assert(isa<CallExpr>(E));
129-
const CallExpr *CE = cast<CallExpr>(E);
130-
for (const auto *A : llvm::reverse(CE->arguments())) {
131-
PrimType Ty = S.getContext().classify(A->getType()).value_or(PT_Ptr);
132-
TYPE_SWITCH(Ty, S.Stk.discard<T>());
133-
}
134-
return true;
135-
}
136-
137125
bool CheckExtern(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
138126
if (!Ptr.isExtern())
139127
return true;

clang/lib/AST/Interp/Interp.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,6 @@ enum class ArithOp { Add, Sub };
181181
// Returning values
182182
//===----------------------------------------------------------------------===//
183183

184-
/// Pop arguments of builtins defined as func-name(...).
185-
bool popBuiltinArgs(InterpState &S, CodePtr OpPC);
186-
187184
template <PrimType Name, class T = typename PrimConv<Name>::T>
188185
bool Ret(InterpState &S, CodePtr &PC, APValue &Result) {
189186
const T &Ret = S.Stk.pop<T>();
@@ -200,16 +197,8 @@ bool Ret(InterpState &S, CodePtr &PC, APValue &Result) {
200197
}
201198

202199
assert(S.Current->getFrameOffset() == S.Stk.size() && "Invalid frame");
203-
if (!S.checkingPotentialConstantExpression() || S.Current->Caller) {
204-
// Certain builtin functions are declared as func-name(...), so the
205-
// parameters are checked in Sema and only available through the CallExpr.
206-
// The interp::Function we create for them has 0 parameters, so we need to
207-
// remove them from the stack by checking the CallExpr.
208-
if (S.Current && S.Current->getFunction()->needsRuntimeArgPop(S.getCtx()))
209-
popBuiltinArgs(S, PC);
210-
else
211-
S.Current->popArgs();
212-
}
200+
if (!S.checkingPotentialConstantExpression() || S.Current->Caller)
201+
S.Current->popArgs();
213202

214203
if (InterpFrame *Caller = S.Current->Caller) {
215204
PC = S.Current->getRetPC();

clang/lib/AST/Interp/InterpBuiltin.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,6 @@ static bool interp__builtin_fmin(InterpState &S, CodePtr OpPC,
162162
return true;
163163
}
164164

165-
/// Defined as __builtin_isnan(...), to accommodate the fact that it can
166-
/// take a float, double, long double, etc.
167-
/// But for us, that's all a Floating anyway.
168-
static bool interp__builtin_isnan(InterpState &S, CodePtr OpPC,
169-
const InterpFrame *Frame, const Function *F) {
170-
const Floating &Arg = S.Stk.peek<Floating>();
171-
172-
S.Stk.push<Integral<32, true>>(Integral<32, true>::from(Arg.isNan()));
173-
return true;
174-
}
175-
176165
bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F) {
177166
InterpFrame *Frame = S.Current;
178167
APValue Dummy;
@@ -234,11 +223,6 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F) {
234223
return Ret<PT_Float>(S, OpPC, Dummy);
235224
break;
236225

237-
case Builtin::BI__builtin_isnan:
238-
if (interp__builtin_isnan(S, OpPC, Frame, F))
239-
return Ret<PT_Sint32>(S, OpPC, Dummy);
240-
break;
241-
242226
default:
243227
return false;
244228
}

clang/test/Sema/constant-builtins-fmin.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
2-
// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -fexperimental-new-constant-interpreter %s
32
// expected-no-diagnostics
43

54
constexpr double NaN = __builtin_nan("");

0 commit comments

Comments
 (0)