Skip to content

Commit 1858a4e

Browse files
authored
Revert "[flang]Add new intrinsic function backtrace and complete the TODO of abort" (#117990)
Reverts #117603 due to failed buildbot https://lab.llvm.org/buildbot/#/builders/152/builds/710 The important bit of the log was ``` FAILED: CMakeFiles/FortranRuntime.dir/stop.cpp.o ccache /usr/bin/g++ -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DRT_USE_LIBCUDACXX=1 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbot/worker/as-builder-7/ramdisk/flang-runtime-cuda-gcc/llvm-project/flang/runtime/../include -I/home/buildbot/worker/as-builder-7/ramdisk/flang-runtime-cuda-gcc/build -I/home/buildbot/worker/third-party/nv/cccl/libcudacxx/include -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wimplicit-fallthrough -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-lto -O3 -DNDEBUG -U_GLIBCXX_ASSERTIONS -U_LIBCPP_ENABLE_ASSERTIONS -UNDEBUG -std=c++17 -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -MD -MT CMakeFiles/FortranRuntime.dir/stop.cpp.o -MF CMakeFiles/FortranRuntime.dir/stop.cpp.o.d -o CMakeFiles/FortranRuntime.dir/stop.cpp.o -c /home/buildbot/worker/as-builder-7/ramdisk/flang-runtime-cuda-gcc/llvm-project/flang/runtime/stop.cpp /home/buildbot/worker/as-builder-7/ramdisk/flang-runtime-cuda-gcc/llvm-project/flang/runtime/stop.cpp:19:10: fatal error: llvm/Config/config.h: No such file or directory 19 | #include "llvm/Config/config.h" | ^~~~~~~~~~~~~~~~~~~~~~ compilation terminated. ``` CC @dty2
1 parent 159e601 commit 1858a4e

File tree

8 files changed

+1
-61
lines changed

8 files changed

+1
-61
lines changed

flang/include/flang/Optimizer/Builder/IntrinsicCall.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ struct IntrinsicLibrary {
196196
fir::ExtendedValue genAssociated(mlir::Type,
197197
llvm::ArrayRef<fir::ExtendedValue>);
198198
mlir::Value genAtand(mlir::Type, llvm::ArrayRef<mlir::Value>);
199-
void genBacktrace(llvm::ArrayRef<fir::ExtendedValue>);
200199
fir::ExtendedValue genBesselJn(mlir::Type,
201200
llvm::ArrayRef<fir::ExtendedValue>);
202201
fir::ExtendedValue genBesselYn(mlir::Type,

flang/include/flang/Optimizer/Builder/Runtime/Stop.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ void genExit(fir::FirOpBuilder &, mlir::Location, mlir::Value status);
3030
/// Generate call to ABORT intrinsic runtime routine.
3131
void genAbort(fir::FirOpBuilder &, mlir::Location);
3232

33-
/// Generate call to BACKTRACE intrinsic runtime routine.
34-
void genBacktrace(fir::FirOpBuilder &builder, mlir::Location loc);
35-
3633
/// Generate call to crash the program with an error message when detecting
3734
/// an invalid situation at runtime.
3835
void genReportFatalUserError(fir::FirOpBuilder &, mlir::Location,

flang/include/flang/Runtime/stop.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ NORETURN void RTNAME(ProgramEndStatement)(NO_ARGUMENTS);
2929
// Extensions
3030
NORETURN void RTNAME(Exit)(int status DEFAULT_VALUE(EXIT_SUCCESS));
3131
NORETURN void RTNAME(Abort)(NO_ARGUMENTS);
32-
void RTNAME(Backtrace)(NO_ARGUMENTS);
3332

3433
// Crash with an error message when the program dynamically violates a Fortran
3534
// constraint.

flang/lib/Evaluate/intrinsics.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,6 @@ static const IntrinsicInterface intrinsicSubroutine[]{
13361336
{"stat", AnyInt, Rank::scalar, Optionality::optional,
13371337
common::Intent::Out}},
13381338
{}, Rank::elemental, IntrinsicClass::atomicSubroutine},
1339-
{"backtrace", {}, {}, Rank::elemental, IntrinsicClass::pureSubroutine},
13401339
{"co_broadcast",
13411340
{{"a", AnyData, Rank::anyOrAssumedRank, Optionality::required,
13421341
common::Intent::InOut},

flang/lib/Optimizer/Builder/IntrinsicCall.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ static constexpr IntrinsicHandler handlers[]{
150150
{"atan2pi", &I::genAtanpi},
151151
{"atand", &I::genAtand},
152152
{"atanpi", &I::genAtanpi},
153-
{"backtrace", &I::genBacktrace},
154153
{"bessel_jn",
155154
&I::genBesselJn,
156155
{{{"n1", asValue}, {"n2", asValue}, {"x", asValue}}},
@@ -2683,12 +2682,6 @@ IntrinsicLibrary::genBesselJn(mlir::Type resultType,
26832682
}
26842683
}
26852684

2686-
// Backtrace
2687-
void IntrinsicLibrary::genBacktrace(llvm::ArrayRef<fir::ExtendedValue> args) {
2688-
assert(args.size() == 0);
2689-
fir::runtime::genBacktrace(builder, loc);
2690-
}
2691-
26922685
// BESSEL_YN
26932686
fir::ExtendedValue
26942687
IntrinsicLibrary::genBesselYn(mlir::Type resultType,

flang/lib/Optimizer/Builder/Runtime/Stop.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ void fir::runtime::genAbort(fir::FirOpBuilder &builder, mlir::Location loc) {
2828
builder.create<fir::CallOp>(loc, abortFunc, std::nullopt);
2929
}
3030

31-
void fir::runtime::genBacktrace(fir::FirOpBuilder &builder,
32-
mlir::Location loc) {
33-
mlir::func::FuncOp backtraceFunc =
34-
fir::runtime::getRuntimeFunc<mkRTKey(Backtrace)>(loc, builder);
35-
builder.create<fir::CallOp>(loc, backtraceFunc, std::nullopt);
36-
}
37-
3831
void fir::runtime::genReportFatalUserError(fir::FirOpBuilder &builder,
3932
mlir::Location loc,
4033
llvm::StringRef message) {

flang/runtime/stop.cpp

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
#include <cstdio>
1717
#include <cstdlib>
1818

19-
#include "llvm/Config/config.h"
20-
#ifdef HAVE_BACKTRACE
21-
#include BACKTRACE_HEADER
22-
#endif
23-
2419
extern "C" {
2520

2621
static void DescribeIEEESignaledExceptions() {
@@ -157,36 +152,11 @@ void RTNAME(PauseStatementText)(const char *code, std::size_t length) {
157152
std::exit(status);
158153
}
159154

160-
static void PrintBacktrace() {
161-
#ifdef HAVE_BACKTRACE
162-
// TODO: Need to parse DWARF information to print function line numbers
163-
constexpr int MAX_CALL_STACK{999};
164-
void *buffer[MAX_CALL_STACK];
165-
int nptrs{backtrace(buffer, MAX_CALL_STACK)};
166-
167-
if (char **symbols{backtrace_symbols(buffer, nptrs)}) {
168-
for (int i = 0; i < nptrs; i++) {
169-
Fortran::runtime::Terminator{}.PrintCrashArgs("#%d %s\n", i, symbols[i]);
170-
}
171-
free(symbols);
172-
}
173-
174-
#else
175-
176-
// TODO: Need to implement the version for other platforms.
177-
Fortran::runtime::Terminator{}.PrintCrashArgs(
178-
"Handle the case when a backtrace is not available");
179-
180-
#endif
181-
}
182-
183155
[[noreturn]] void RTNAME(Abort)() {
184-
PrintBacktrace();
156+
// TODO: Add backtrace call, unless with `-fno-backtrace`.
185157
std::abort();
186158
}
187159

188-
void RTNAME(Backtrace)() { PrintBacktrace(); }
189-
190160
[[noreturn]] void RTNAME(ReportFatalUserError)(
191161
const char *message, const char *source, int line) {
192162
Fortran::runtime::Terminator{source, line}.Crash(message);

flang/test/Lower/Intrinsics/backtrace.f90

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)