Skip to content

Commit 7a0a794

Browse files
authored
Revert "[flang] Implement GETUID and GETGID intrinsics" (llvm#110531)
Reverts llvm#108017
1 parent 8815328 commit 7a0a794

File tree

17 files changed

+2
-138
lines changed

17 files changed

+2
-138
lines changed

flang/docs/Intrinsics.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ This phase currently supports all the intrinsic procedures listed above but the
765765
| Coarray intrinsic functions | COSHAPE |
766766
| Object characteristic inquiry functions | ALLOCATED, ASSOCIATED, EXTENDS_TYPE_OF, IS_CONTIGUOUS, PRESENT, RANK, SAME_TYPE, STORAGE_SIZE |
767767
| Type inquiry intrinsic functions | BIT_SIZE, DIGITS, EPSILON, HUGE, KIND, MAXEXPONENT, MINEXPONENT, NEW_LINE, PRECISION, RADIX, RANGE, TINY|
768-
| Non-standard intrinsic functions | AND, OR, XOR, SHIFT, ZEXT, IZEXT, COSD, SIND, TAND, ACOSD, ASIND, ATAND, ATAN2D, COMPL, EQV, NEQV, INT8, JINT, JNINT, KNINT, QCMPLX, DREAL, DFLOAT, QEXT, QFLOAT, QREAL, DNUM, NUM, JNUM, KNUM, QNUM, RNUM, RAN, RANF, ILEN, SIZEOF, MCLOCK, SECNDS, COTAN, IBCHNG, ISHA, ISHC, ISHL, IXOR, IARG, IARGC, NARGS, GETPID, NUMARG, BADDRESS, IADDR, CACHESIZE, EOF, FP_CLASS, INT_PTR_KIND, ISNAN, MALLOC, GETUID, GETGID |
768+
| Non-standard intrinsic functions | AND, OR, XOR, SHIFT, ZEXT, IZEXT, COSD, SIND, TAND, ACOSD, ASIND, ATAND, ATAN2D, COMPL, EQV, NEQV, INT8, JINT, JNINT, KNINT, QCMPLX, DREAL, DFLOAT, QEXT, QFLOAT, QREAL, DNUM, NUM, JNUM, KNUM, QNUM, RNUM, RAN, RANF, ILEN, SIZEOF, MCLOCK, SECNDS, COTAN, IBCHNG, ISHA, ISHC, ISHL, IXOR, IARG, IARGC, NARGS, GETPID, NUMARG, BADDRESS, IADDR, CACHESIZE, EOF, FP_CLASS, INT_PTR_KIND, ISNAN, MALLOC |
769769
| Intrinsic subroutines |MVBITS (elemental), CPU_TIME, DATE_AND_TIME, EVENT_QUERY, EXECUTE_COMMAND_LINE, GET_COMMAND, GET_COMMAND_ARGUMENT, GET_ENVIRONMENT_VARIABLE, MOVE_ALLOC, RANDOM_INIT, RANDOM_NUMBER, RANDOM_SEED, SIGNAL, SLEEP, SYSTEM, SYSTEM_CLOCK |
770770
| Atomic intrinsic subroutines | ATOMIC_ADD |
771771
| Collective intrinsic subroutines | CO_REDUCE |

flang/include/flang/Evaluate/target.h

-6
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,6 @@ class TargetCharacteristics {
102102
bool isPPC() const { return isPPC_; }
103103
void set_isPPC(bool isPPC = false);
104104

105-
bool isOSWindows() const { return isOSWindows_; }
106-
void set_isOSWindows(bool isOSWindows = false) {
107-
isOSWindows_ = isOSWindows;
108-
};
109-
110105
IeeeFeatures &ieeeFeatures() { return ieeeFeatures_; }
111106
const IeeeFeatures &ieeeFeatures() const { return ieeeFeatures_; }
112107

@@ -116,7 +111,6 @@ class TargetCharacteristics {
116111
std::uint8_t align_[common::TypeCategory_enumSize][maxKind]{};
117112
bool isBigEndian_{false};
118113
bool isPPC_{false};
119-
bool isOSWindows_{false};
120114
bool areSubnormalsFlushedToZero_{false};
121115
Rounding roundingMode_{defaultRounding};
122116
std::size_t procedurePointerByteSize_{8};

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

-4
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,6 @@ struct IntrinsicLibrary {
256256
llvm::ArrayRef<mlir::Value> args);
257257
void genGetCommandArgument(mlir::ArrayRef<fir::ExtendedValue> args);
258258
void genGetEnvironmentVariable(llvm::ArrayRef<fir::ExtendedValue>);
259-
mlir::Value genGetGID(mlir::Type resultType,
260-
llvm::ArrayRef<mlir::Value> args);
261-
mlir::Value genGetUID(mlir::Type resultType,
262-
llvm::ArrayRef<mlir::Value> args);
263259
fir::ExtendedValue genIall(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
264260
mlir::Value genIand(mlir::Type, llvm::ArrayRef<mlir::Value>);
265261
fir::ExtendedValue genIany(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);

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

-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ void genDateAndTime(fir::FirOpBuilder &, mlir::Location,
4747
void genEtime(fir::FirOpBuilder &builder, mlir::Location loc,
4848
mlir::Value values, mlir::Value time);
4949

50-
mlir::Value genGetUID(fir::FirOpBuilder &, mlir::Location);
51-
mlir::Value genGetGID(fir::FirOpBuilder &, mlir::Location);
52-
5350
void genRandomInit(fir::FirOpBuilder &, mlir::Location, mlir::Value repeatable,
5451
mlir::Value imageDistinct);
5552
void genRandomNumber(fir::FirOpBuilder &, mlir::Location, mlir::Value harvest);

flang/include/flang/Runtime/extensions.h

-14
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@
2020
#include <cstddef>
2121
#include <cstdint>
2222

23-
#ifdef _WIN32
24-
// UID and GID don't exist on Windows, these exist to avoid errors.
25-
typedef std::uint32_t uid_t;
26-
typedef std::uint32_t gid_t;
27-
#else
28-
#include "sys/types.h" //pid_t
29-
#endif
30-
3123
extern "C" {
3224

3325
// CALL FLUSH(n) antedates the Fortran 2003 FLUSH statement.
@@ -43,12 +35,6 @@ std::int32_t FORTRAN_PROCEDURE_NAME(iargc)();
4335
void FORTRAN_PROCEDURE_NAME(getarg)(
4436
std::int32_t &n, char *arg, std::int64_t length);
4537

46-
// Calls getgid()
47-
gid_t RTNAME(GetGID)();
48-
49-
// Calls getuid()
50-
uid_t RTNAME(GetUID)();
51-
5238
// GNU extension subroutine GETLOG(C).
5339
void FORTRAN_PROCEDURE_NAME(getlog)(char *name, std::int64_t length);
5440

flang/include/flang/Tools/TargetSetup.h

-3
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ namespace Fortran::tools {
5959
if (targetTriple.isPPC())
6060
targetCharacteristics.set_isPPC(true);
6161

62-
if (targetTriple.isOSWindows())
63-
targetCharacteristics.set_isOSWindows(true);
64-
6562
// TODO: use target machine data layout to set-up the target characteristics
6663
// type size and alignment info.
6764
}

flang/lib/Evaluate/intrinsics.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,7 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
523523
{{"c", DefaultChar, Rank::scalar, Optionality::required,
524524
common::Intent::Out}},
525525
TypePattern{IntType, KindCode::greaterOrEqualToKind, 4}},
526-
{"getgid", {}, DefaultInt},
527526
{"getpid", {}, DefaultInt},
528-
{"getuid", {}, DefaultInt},
529527
{"huge",
530528
{{"x", SameIntOrReal, Rank::anyOrAssumedRank, Optionality::required,
531529
common::Intent::In, {ArgFlag::canBeMoldNull}}},

flang/lib/Optimizer/Builder/IntrinsicCall.cpp

-18
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,7 @@ static constexpr IntrinsicHandler handlers[]{
293293
&I::genGetCwd,
294294
{{{"c", asBox}, {"status", asAddr, handleDynamicOptional}}},
295295
/*isElemental=*/false},
296-
{"getgid", &I::genGetGID},
297296
{"getpid", &I::genGetPID},
298-
{"getuid", &I::genGetUID},
299297
{"iachar", &I::genIchar},
300298
{"iall",
301299
&I::genIall,
@@ -3652,14 +3650,6 @@ void IntrinsicLibrary::genGetCommand(llvm::ArrayRef<fir::ExtendedValue> args) {
36523650
}
36533651
}
36543652

3655-
// GETGID
3656-
mlir::Value IntrinsicLibrary::genGetGID(mlir::Type resultType,
3657-
llvm::ArrayRef<mlir::Value> args) {
3658-
assert(args.size() == 0 && "getgid takes no input");
3659-
return builder.createConvert(loc, resultType,
3660-
fir::runtime::genGetGID(builder, loc));
3661-
}
3662-
36633653
// GETPID
36643654
mlir::Value IntrinsicLibrary::genGetPID(mlir::Type resultType,
36653655
llvm::ArrayRef<mlir::Value> args) {
@@ -3668,14 +3658,6 @@ mlir::Value IntrinsicLibrary::genGetPID(mlir::Type resultType,
36683658
fir::runtime::genGetPID(builder, loc));
36693659
}
36703660

3671-
// GETUID
3672-
mlir::Value IntrinsicLibrary::genGetUID(mlir::Type resultType,
3673-
llvm::ArrayRef<mlir::Value> args) {
3674-
assert(args.size() == 0 && "getgid takes no input");
3675-
return builder.createConvert(loc, resultType,
3676-
fir::runtime::genGetUID(builder, loc));
3677-
}
3678-
36793661
// GET_COMMAND_ARGUMENT
36803662
void IntrinsicLibrary::genGetCommandArgument(
36813663
llvm::ArrayRef<fir::ExtendedValue> args) {

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

-16
Original file line numberDiff line numberDiff line change
@@ -120,22 +120,6 @@ void fir::runtime::genEtime(fir::FirOpBuilder &builder, mlir::Location loc,
120120
builder.create<fir::CallOp>(loc, runtimeFunc, args);
121121
}
122122

123-
mlir::Value fir::runtime::genGetGID(fir::FirOpBuilder &builder,
124-
mlir::Location loc) {
125-
auto runtimeFunc =
126-
fir::runtime::getRuntimeFunc<mkRTKey(GetGID)>(loc, builder);
127-
128-
return builder.create<fir::CallOp>(loc, runtimeFunc).getResult(0);
129-
}
130-
131-
mlir::Value fir::runtime::genGetUID(fir::FirOpBuilder &builder,
132-
mlir::Location loc) {
133-
auto runtimeFunc =
134-
fir::runtime::getRuntimeFunc<mkRTKey(GetUID)>(loc, builder);
135-
136-
return builder.create<fir::CallOp>(loc, runtimeFunc).getResult(0);
137-
}
138-
139123
void fir::runtime::genRandomInit(fir::FirOpBuilder &builder, mlir::Location loc,
140124
mlir::Value repeatable,
141125
mlir::Value imageDistinct) {

flang/lib/Semantics/check-call.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -2028,22 +2028,6 @@ bool CheckPPCIntrinsic(const Symbol &generic, const Symbol &specific,
20282028
return false;
20292029
}
20302030

2031-
bool CheckWindowsIntrinsic(
2032-
const Symbol &intrinsic, evaluate::FoldingContext &foldingContext) {
2033-
parser::ContextualMessages &messages{foldingContext.messages()};
2034-
// TODO: there are other intrinsics that are unsupported on Windows that
2035-
// should be added here.
2036-
if (intrinsic.name() == "getuid") {
2037-
messages.Say(
2038-
"User IDs do not exist on Windows. This function will always return 1"_warn_en_US);
2039-
}
2040-
if (intrinsic.name() == "getgid") {
2041-
messages.Say(
2042-
"Group IDs do not exist on Windows. This function will always return 1"_warn_en_US);
2043-
}
2044-
return true;
2045-
}
2046-
20472031
bool CheckArguments(const characteristics::Procedure &proc,
20482032
evaluate::ActualArguments &actuals, SemanticsContext &context,
20492033
const Scope &scope, bool treatingExternalAsImplicit,

flang/lib/Semantics/check-call.h

-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ bool CheckArguments(const evaluate::characteristics::Procedure &,
4141
bool CheckPPCIntrinsic(const Symbol &generic, const Symbol &specific,
4242
const evaluate::ActualArguments &actuals,
4343
evaluate::FoldingContext &context);
44-
bool CheckWindowsIntrinsic(
45-
const Symbol &intrinsic, evaluate::FoldingContext &context);
4644
bool CheckArgumentIsConstantExprInRange(
4745
const evaluate::ActualArguments &actuals, int index, int lowerBound,
4846
int upperBound, parser::ContextualMessages &messages);

flang/lib/Semantics/expression.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -2916,9 +2916,6 @@ auto ExpressionAnalyzer::GetCalleeAndArguments(const parser::Name &name,
29162916
} else {
29172917
resolution = symbol;
29182918
}
2919-
if (resolution && context_.targetCharacteristics().isOSWindows()) {
2920-
semantics::CheckWindowsIntrinsic(*resolution, GetFoldingContext());
2921-
}
29222919
if (!resolution || resolution->attrs().test(semantics::Attr::INTRINSIC)) {
29232920
auto name{resolution ? resolution->name() : ultimate.name()};
29242921
if (std::optional<SpecificCall> specificCall{context_.intrinsics().Probe(

flang/runtime/extensions.cpp

-19
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,6 @@ extern "C" {
5858

5959
namespace Fortran::runtime {
6060

61-
gid_t RTNAME(GetGID)() {
62-
#ifdef _WIN32
63-
// Group IDs don't exist on Windows, return 1 to avoid errors
64-
return 1;
65-
#else
66-
return getgid();
67-
#endif
68-
}
69-
70-
uid_t RTNAME(GetUID)() {
71-
#ifdef _WIN32
72-
// User IDs don't exist on Windows, return 1 to avoid errors
73-
return 1;
74-
#else
75-
return getuid();
76-
#endif
77-
}
78-
7961
void GetUsernameEnvVar(const char *envName, char *arg, std::int64_t length) {
8062
Descriptor name{*Descriptor::Create(
8163
1, std::strlen(envName) + 1, const_cast<char *>(envName), 0)};
@@ -84,7 +66,6 @@ void GetUsernameEnvVar(const char *envName, char *arg, std::int64_t length) {
8466
RTNAME(GetEnvVariable)
8567
(name, &value, nullptr, false, nullptr, __FILE__, __LINE__);
8668
}
87-
8869
namespace io {
8970
// SUBROUTINE FLUSH(N)
9071
// FLUSH N

flang/test/Semantics/windows.f90

-12
This file was deleted.

flang/unittests/Optimizer/Builder/Runtime/CommandTest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ TEST_F(RuntimeCallTest, genGetPID) {
5050
mlir::Value result = fir::runtime::genGetPID(*firBuilder, loc);
5151
checkCallOp(result.getDefiningOp(), "_FortranAGetPID", /*nbArgs=*/0,
5252
/*addLocArgs=*/false);
53-
}
53+
}

flang/unittests/Optimizer/Builder/Runtime/IntrinsicsTest.cpp

-17
This file was deleted.

flang/unittests/Optimizer/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ add_flang_unittest(FlangOptimizerTests
2525
Builder/Runtime/CommandTest.cpp
2626
Builder/Runtime/CharacterTest.cpp
2727
Builder/Runtime/DerivedTest.cpp
28-
Builder/Runtime/IntrinsicsTest.cpp
2928
Builder/Runtime/NumericTest.cpp
3029
Builder/Runtime/RaggedTest.cpp
3130
Builder/Runtime/ReductionTest.cpp

0 commit comments

Comments
 (0)