Skip to content

Commit 47df94c

Browse files
committed
Revert "[CIR][ABI][NFC] Add CC lowering for void CallOps (#668)"
This reverts commit 66bb15b. This broke the build: ``` /usr/bin/ld: lib/libMLIRCIRTransforms.a(LoweringPrepare.cpp.o): in function `(anonymous namespace)::LoweringPreparePass::lowerVAArgOp(mlir::cir::VAArgOp)': /local/home/dolsen/clangir/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp:340: undefined reference to `cir::CIRDataLayout::CIRDataLayout(mlir::ModuleOp)' /usr/bin/ld: lib/libTargetLowering.a(LowerTypes.cpp.o): in function `cir::CIRDataLayout::CIRDataLayout(llvm::StringRef, mlir::ModuleOp)': /local/home/dolsen/clangir/clang/include/clang/CIR/Dialect/IR/CIRDataLayout.h:31: undefined reference to `cir::CIRDataLayout::reset(llvm::StringRef)'`' ``` Steps to reproduce: ``` $ cmake -GNinja -DCMAKE_INSTALL_PREFIX=/<some-path>/clangir-install "-DLLVM_ENABLE_PROJECTS=clang;mlir" -DCLANG_ENABLE_CIR=ON -DLLVM_TARGETS_TO_BUILD=host -DCMAKE_BUILD_TYPE=Debug ../clangir/llvm $ ninja install ```
1 parent e91ada4 commit 47df94c

31 files changed

+42
-851
lines changed

clang/include/clang/CIR/Dialect/IR/CIRDataLayout.h

-13
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "mlir/Dialect/DLTI/DLTI.h"
1616
#include "mlir/IR/BuiltinOps.h"
1717
#include "clang/CIR/Dialect/IR/CIRTypes.h"
18-
#include "llvm/ADT/StringRef.h"
1918

2019
namespace cir {
2120

@@ -25,18 +24,6 @@ class CIRDataLayout {
2524
public:
2625
mlir::DataLayout layout;
2726

28-
/// Constructs a DataLayout from a specification string. See reset().
29-
explicit CIRDataLayout(llvm::StringRef dataLayout, mlir::ModuleOp module)
30-
: layout(module) {
31-
reset(dataLayout);
32-
}
33-
34-
/// Parse a data layout string (with fallback to default values).
35-
void reset(llvm::StringRef dataLayout);
36-
37-
// Free all internal data structures.
38-
void clear();
39-
4027
CIRDataLayout(mlir::ModuleOp modOp);
4128
bool isBigEndian() const { return bigEndian; }
4229

clang/include/clang/CIR/FnInfoOpts.h

-37
This file was deleted.

clang/include/clang/CIR/MissingFeatures.h

+6-31
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ struct MissingFeatures {
156156
static bool zeroInitializer() { return false; }
157157
static bool targetCodeGenInfoIsProtoCallVariadic() { return false; }
158158
static bool targetCodeGenInfoGetNullPointer() { return false; }
159+
static bool chainCalls() { return false; }
159160
static bool operandBundles() { return false; }
160161
static bool exceptions() { return false; }
161162
static bool metaDataNode() { return false; }
@@ -189,50 +190,24 @@ struct MissingFeatures {
189190

190191
//===--- ABI lowering --===//
191192

192-
//-- Missing AST queries
193-
194-
static bool recordDeclCanPassInRegisters() { return false; }
195-
196-
//-- Missing types
197-
198-
static bool vectorType() { return false; }
199-
200-
//-- Other missing features
201-
202-
// Calls with a static chain pointer argument may be optimized (p.e. freeing
203-
// up argument registers), but we do not yet track such cases.
204-
static bool chainCall() { return false; }
205-
206-
// ABI-lowering has special handling for regcall calling convention (tries to
207-
// pass every argument in regs). We don't support it just yet.
208-
static bool regCall() { return false; }
209-
210-
// Some ABIs (e.g. x86) require special handling for returning large structs
211-
// by value. The sret argument parameter aids in this, but it is current NYI.
212-
static bool sretArgs() { return false; }
213-
214-
// Inalloca parameter attributes are mostly used for Windows x86_32 ABI. We
215-
// do not yet support this yet.
216-
static bool inallocaArgs() { return false; }
217-
218193
// Parameters may have additional attributes (e.g. [[noescape]]) that affect
219194
// the compiler. This is not yet supported in CIR.
220-
static bool extParamInfo() { return false; }
195+
static bool extParamInfo() { return true; }
221196

222197
// LangOpts may affect lowering, but we do not carry this information into CIR
223198
// just yet. Right now, it only instantiates the default lang options.
224-
static bool langOpts() { return false; }
199+
static bool langOpts() { return true; }
225200

226201
// Several type qualifiers are not yet supported in CIR, but important when
227202
// evaluating ABI-specific lowering.
228-
static bool qualifiedTypes() { return false; }
203+
static bool qualifiedTypes() { return true; }
229204

230205
// We're ignoring several details regarding ABI-halding for Swift.
231-
static bool swift() { return false; }
206+
static bool swift() { return true; }
232207

233208
// Despite carrying some information about variadics, we are currently
234209
// ignoring this to focus only on the code necessary to lower non-variadics.
235-
static bool variadicFunctions() { return false; }
210+
static bool variadicFunctions() { return true; }
236211
};
237212

238213
} // namespace cir

clang/include/clang/CIR/Target/x86.h

-32
This file was deleted.

clang/lib/CIR/CodeGen/CIRGenCall.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "clang/AST/GlobalDecl.h"
2424
#include "clang/CIR/Dialect/IR/CIRDialect.h"
2525
#include "clang/CIR/Dialect/IR/CIRTypes.h"
26-
#include "clang/CIR/FnInfoOpts.h"
2726
#include "llvm/Support/ErrorHandling.h"
2827
#include <cassert>
2928

clang/lib/CIR/CodeGen/CIRGenCall.h

+7
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,13 @@ class ReturnValueSlot {
290290
Address getAddress() const { return Addr; }
291291
};
292292

293+
enum class FnInfoOpts {
294+
None = 0,
295+
IsInstanceMethod = 1 << 0,
296+
IsChainCall = 1 << 1,
297+
IsDelegateCall = 1 << 2,
298+
};
299+
293300
} // namespace cir
294301

295302
#endif

clang/lib/CIR/CodeGen/CIRGenExpr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,7 @@ RValue CIRGenFunction::buildCall(clang::QualType CalleeType,
14351435
// Chain calls use the same code path to add the inviisble chain parameter to
14361436
// the function type.
14371437
if (isa<FunctionNoProtoType>(FnType) || Chain) {
1438-
assert(!MissingFeatures::chainCall());
1438+
assert(!MissingFeatures::chainCalls());
14391439
assert(!MissingFeatures::addressSpace());
14401440
auto CalleeTy = getTypes().GetFunctionType(FnInfo);
14411441
// get non-variadic function type

clang/lib/CIR/CodeGen/CIRGenTypes.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "clang/AST/GlobalDecl.h"
1717
#include "clang/AST/RecordLayout.h"
1818
#include "clang/CIR/Dialect/IR/CIRTypes.h"
19-
#include "clang/CIR/FnInfoOpts.h"
2019
#include "llvm/ADT/STLExtras.h"
2120
#include "llvm/Support/Casting.h"
2221
#include "llvm/Support/ErrorHandling.h"

clang/lib/CIR/CodeGen/CIRGenTypes.h

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "clang/AST/Type.h"
2323
#include "clang/Basic/ABI.h"
2424
#include "clang/CIR/Dialect/IR/CIRTypes.h"
25-
#include "clang/CIR/FnInfoOpts.h"
2625

2726
#include "llvm/ADT/SmallPtrSet.h"
2827

clang/lib/CIR/CodeGen/CIRRecordLayoutBuilder.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,3 @@ CIRDataLayout::CIRDataLayout(mlir::ModuleOp modOp) : layout{modOp} {
748748
}
749749
}
750750
}
751-
752-
void CIRDataLayout::reset(StringRef Desc) { clear(); }
753-
754-
void CIRDataLayout::clear() {}

clang/lib/CIR/CodeGen/TargetInfo.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "CallingConv.h"
77

88
#include "clang/Basic/TargetInfo.h"
9-
#include "clang/CIR/Target/x86.h"
109

1110
using namespace cir;
1211
using namespace clang;
@@ -80,7 +79,16 @@ namespace {
8079
enum class X86AVXABILevel { None, AVX, AVX512 };
8180

8281
class X86_64ABIInfo : public ABIInfo {
83-
using Class = X86ArgClass;
82+
enum Class {
83+
Integer = 0,
84+
SSE,
85+
SSEUp,
86+
X87,
87+
X87Up,
88+
ComplexX87,
89+
NoClass,
90+
Memory
91+
};
8492

8593
// X86AVXABILevel AVXLevel;
8694
// Some ABIs (e.g. X32 ABI and Native Client OS) use 32 bit pointers on 64-bit

clang/lib/CIR/Dialect/Transforms/CallConvLowering.cpp

+1-17
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ LowerModule createLowerModule(FuncOp op, PatternRewriter &rewriter) {
4545
// FIXME(cir): This just uses the default language options. We need to account
4646
// for custom options.
4747
// Create context.
48-
assert(!::cir::MissingFeatures::langOpts());
48+
assert(::cir::MissingFeatures::langOpts());
4949
clang::LangOptions langOpts;
5050
auto context = CIRLowerContext(module.getContext(), langOpts);
5151
context.initBuiltinTypes(*targetInfo);
@@ -64,27 +64,11 @@ struct CallConvLoweringPattern : public OpRewritePattern<FuncOp> {
6464

6565
LogicalResult matchAndRewrite(FuncOp op,
6666
PatternRewriter &rewriter) const final {
67-
const auto module = op->getParentOfType<mlir::ModuleOp>();
68-
6967
if (!op.getAst())
7068
return op.emitError("function has no AST information");
7169

7270
LowerModule lowerModule = createLowerModule(op, rewriter);
7371

74-
// Rewrite function calls before definitions. This should be done before
75-
// lowering the definition.
76-
auto calls = op.getSymbolUses(module);
77-
if (calls.has_value()) {
78-
for (auto call : calls.value()) {
79-
auto callOp = cast<CallOp>(call.getUser());
80-
if (lowerModule.rewriteFunctionCall(callOp, op).failed())
81-
return failure();
82-
}
83-
}
84-
85-
// Rewrite function definition.
86-
// FIXME(cir): This is a workaround to avoid an infinite loop in the driver.
87-
rewriter.replaceOp(op, rewriter.clone(*op));
8872
return success();
8973
}
9074
};

clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfo.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,12 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
#include "ABIInfo.h"
15-
#include "CIRCXXABI.h"
16-
#include "LowerTypes.h"
1715

1816
namespace mlir {
1917
namespace cir {
2018

2119
// Pin the vtable to this file.
2220
ABIInfo::~ABIInfo() = default;
2321

24-
CIRCXXABI &ABIInfo::getCXXABI() const { return LT.getCXXABI(); }
25-
2622
} // namespace cir
2723
} // namespace mlir

clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfo.h

-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
#ifndef LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_ABIINFO_H
1515
#define LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_ABIINFO_H
1616

17-
#include "CIRCXXABI.h"
18-
#include "LowerFunctionInfo.h"
1917
#include "llvm/IR/CallingConv.h"
2018

2119
namespace mlir {
@@ -34,10 +32,6 @@ class ABIInfo {
3432
public:
3533
ABIInfo(LowerTypes &LT) : LT(LT), RuntimeCC(llvm::CallingConv::C) {}
3634
virtual ~ABIInfo();
37-
38-
CIRCXXABI &getCXXABI() const;
39-
40-
virtual void computeInfo(LowerFunctionInfo &FI) const = 0;
4135
};
4236

4337
} // namespace cir

clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfoImpl.cpp

-22
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,3 @@
1010
// adapted to operate on the CIR dialect, however.
1111
//
1212
//===----------------------------------------------------------------------===//
13-
14-
#include "ABIInfo.h"
15-
#include "CIRCXXABI.h"
16-
#include "LowerFunctionInfo.h"
17-
#include "llvm/Support/ErrorHandling.h"
18-
19-
namespace mlir {
20-
namespace cir {
21-
22-
bool classifyReturnType(const CIRCXXABI &CXXABI, LowerFunctionInfo &FI,
23-
const ABIInfo &Info) {
24-
Type Ty = FI.getReturnType();
25-
26-
if (const auto RT = Ty.dyn_cast<StructType>()) {
27-
llvm_unreachable("NYI");
28-
}
29-
30-
return CXXABI.classifyReturnType(FI);
31-
}
32-
33-
} // namespace cir
34-
} // namespace mlir

clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfoImpl.h

+1-10
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,8 @@
1414
#ifndef LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_ABIINFOIMPL_H
1515
#define LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_ABIINFOIMPL_H
1616

17-
#include "ABIInfo.h"
18-
#include "CIRCXXABI.h"
19-
#include "LowerFunctionInfo.h"
20-
2117
namespace mlir {
22-
namespace cir {
23-
24-
bool classifyReturnType(const CIRCXXABI &CXXABI, LowerFunctionInfo &FI,
25-
const ABIInfo &Info);
26-
27-
} // namespace cir
18+
namespace cir {} // namespace cir
2819
} // namespace mlir
2920

3021
#endif // LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_ABIINFOIMPL_H

clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRCXXABI.h

-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#ifndef LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_CIRCXXABI_H
1515
#define LLVM_CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_CIRCXXABI_H
1616

17-
#include "LowerFunctionInfo.h"
1817
#include "mlir/IR/Value.h"
1918
#include "clang/CIR/Dialect/Builder/CIRBaseBuilder.h"
2019
#include "clang/CIR/Dialect/IR/CIRDataLayout.h"
@@ -35,10 +34,6 @@ class CIRCXXABI {
3534

3635
public:
3736
virtual ~CIRCXXABI();
38-
39-
/// If the C++ ABI requires the given type be returned in a particular way,
40-
/// this method sets RetAI and returns true.
41-
virtual bool classifyReturnType(LowerFunctionInfo &FI) const = 0;
4237
};
4338

4439
/// Creates an Itanium-family ABI.

clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRLowerContext.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Type CIRLowerContext::initBuiltinType(clang::BuiltinType::Kind K) {
3131
Type Ty;
3232

3333
// NOTE(cir): Clang does more stuff here. Not sure if we need to do the same.
34-
assert(!::cir::MissingFeatures::qualifiedTypes());
34+
assert(::cir::MissingFeatures::qualifiedTypes());
3535
switch (K) {
3636
case clang::BuiltinType::Char_S:
3737
Ty = IntType::get(getMLIRContext(), 8, true);

0 commit comments

Comments
 (0)