Skip to content

Commit

Permalink
[CIR][Lowering][debuginfo] Disable debug info if -g is not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
PikachuHyA committed Nov 20, 2024
1 parent bae7bd9 commit 45a0669
Show file tree
Hide file tree
Showing 31 changed files with 115 additions and 84 deletions.
3 changes: 2 additions & 1 deletion clang/include/clang/CIR/LowerToLLVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ namespace cir {
namespace direct {
std::unique_ptr<llvm::Module> lowerDirectlyFromCIRToLLVMIR(
mlir::ModuleOp theModule, llvm::LLVMContext &llvmCtx,
bool disableVerifier = false, bool disableCCLowering = false);
bool disableVerifier = false, bool disableCCLowering = false,
bool disableDebugInfo = false);
}

// Lower directly from pristine CIR to LLVMIR.
Expand Down
22 changes: 14 additions & 8 deletions clang/lib/CIR/FrontendAction/CIRGenAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ getBackendActionFromOutputType(CIRGenAction::OutputType action) {
static std::unique_ptr<llvm::Module> lowerFromCIRToLLVMIR(
const clang::FrontendOptions &feOptions, mlir::ModuleOp mlirMod,
std::unique_ptr<mlir::MLIRContext> mlirCtx, llvm::LLVMContext &llvmCtx,
bool disableVerifier = false, bool disableCCLowering = false) {
bool disableVerifier = false, bool disableCCLowering = false,
bool disableDebugInfo = false) {
if (feOptions.ClangIRDirectLowering)
return direct::lowerDirectlyFromCIRToLLVMIR(
mlirMod, llvmCtx, disableVerifier, disableCCLowering);
mlirMod, llvmCtx, disableVerifier, disableCCLowering, disableDebugInfo);
else
return lowerFromCIRToMLIRToLLVMIR(mlirMod, std::move(mlirCtx), llvmCtx);
}
Expand Down Expand Up @@ -284,10 +285,12 @@ class CIRGenConsumer : public clang::ASTConsumer {
case CIRGenAction::OutputType::EmitObj:
case CIRGenAction::OutputType::EmitAssembly: {
llvm::LLVMContext llvmCtx;
auto llvmModule =
lowerFromCIRToLLVMIR(feOptions, mlirMod, std::move(mlirCtx), llvmCtx,
feOptions.ClangIRDisableCIRVerifier,
!feOptions.ClangIRCallConvLowering);
bool disableDebugInfo =
codeGenOptions.getDebugInfo() == llvm::codegenoptions::NoDebugInfo;
auto llvmModule = lowerFromCIRToLLVMIR(
feOptions, mlirMod, std::move(mlirCtx), llvmCtx,
feOptions.ClangIRDisableCIRVerifier,
!feOptions.ClangIRCallConvLowering, disableDebugInfo);

BackendAction backendAction = getBackendActionFromOutputType(action);

Expand Down Expand Up @@ -436,10 +439,12 @@ void CIRGenAction::ExecuteAction() {

// FIXME(cir): This compilation path does not account for some flags.
llvm::LLVMContext llvmCtx;
bool disableDebugInfo =
ci.getCodeGenOpts().getDebugInfo() == llvm::codegenoptions::NoDebugInfo;
auto llvmModule = lowerFromCIRToLLVMIR(
ci.getFrontendOpts(), mlirModule.release(),
std::unique_ptr<mlir::MLIRContext>(mlirContext), llvmCtx,
/*disableVerifier=*/false, /*disableCCLowering=*/true);
/*disableVerifier=*/false, /*disableCCLowering=*/true, disableDebugInfo);

if (outstream)
llvmModule->print(*outstream, nullptr);
Expand Down Expand Up @@ -479,7 +484,8 @@ EmitObjAction::EmitObjAction(mlir::MLIRContext *_MLIRContext)
: CIRGenAction(OutputType::EmitObj, _MLIRContext) {}
} // namespace cir

// Used for -fclangir-analysis-only: use CIR analysis but still use original LLVM codegen path
// Used for -fclangir-analysis-only: use CIR analysis but still use original
// LLVM codegen path
void AnalysisOnlyActionBase::anchor() {}
AnalysisOnlyActionBase::AnalysisOnlyActionBase(unsigned _Act,
llvm::LLVMContext *_VMContext)
Expand Down
8 changes: 5 additions & 3 deletions clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4357,7 +4357,8 @@ extern void registerCIRDialectTranslation(mlir::MLIRContext &context);

std::unique_ptr<llvm::Module>
lowerDirectlyFromCIRToLLVMIR(mlir::ModuleOp theModule, LLVMContext &llvmCtx,
bool disableVerifier, bool disableCCLowering) {
bool disableVerifier, bool disableCCLowering,
bool disableDebugInfo) {
llvm::TimeTraceScope scope("lower from CIR to LLVM directly");

mlir::MLIRContext *mlirCtx = theModule.getContext();
Expand All @@ -4367,8 +4368,9 @@ lowerDirectlyFromCIRToLLVMIR(mlir::ModuleOp theModule, LLVMContext &llvmCtx,
// This is necessary to have line tables emitted and basic
// debugger working. In the future we will add proper debug information
// emission directly from our frontend.
pm.addPass(mlir::LLVM::createDIScopeForLLVMFuncOpPass());

if (!disableDebugInfo) {
pm.addPass(mlir::LLVM::createDIScopeForLLVMFuncOpPass());
}
// FIXME(cir): this shouldn't be necessary. It's meant to be a temporary
// workaround until we understand why some unrealized casts are being
// emmited and how to properly avoid them.
Expand Down
6 changes: 3 additions & 3 deletions clang/test/CIR/CodeGen/OpenCL/convergent.cl
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ void non_convfun(void) {
// External functions should be assumed convergent.
void f(void);
// CIR: cir.func{{.+}} @f(){{.*}} extra(#fn_attr[[CONV_DECL_ATTR]])
// LLVM: declare {{.+}} spir_func void @f() local_unnamed_addr #[[CONV_ATTR:[0-9]+]]
// LLVM: declare spir_func void @f() local_unnamed_addr #[[CONV_ATTR:[0-9]+]]
void g(void);
// CIR: cir.func{{.+}} @g(){{.*}} extra(#fn_attr[[CONV_DECL_ATTR]])
// LLVM: declare {{.+}} spir_func void @g() local_unnamed_addr #[[CONV_ATTR]]
// LLVM: declare spir_func void @g() local_unnamed_addr #[[CONV_ATTR]]

// Test two if's are merged and non_convfun duplicated.
void test_merge_if(int a) {
Expand Down Expand Up @@ -68,7 +68,7 @@ void test_merge_if(int a) {

void convfun(void) __attribute__((convergent));
// CIR: cir.func{{.+}} @convfun(){{.*}} extra(#fn_attr[[CONV_DECL_ATTR]])
// LLVM: declare {{.+}} spir_func void @convfun() local_unnamed_addr #[[CONV_ATTR]]
// LLVM: declare spir_func void @convfun() local_unnamed_addr #[[CONV_ATTR]]

// Test two if's are not merged.
void test_no_merge_if(int a) {
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/CodeGen/abstract-cond.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int f6(int a0, struct s6 a1, struct s6 a2) {
// LLVM-LABEL: @f6
// LLVM: %[[LOAD_A0:.*]] = load i32, ptr {{.*}}
// LLVM: %[[COND:.*]] = icmp ne i32 %[[LOAD_A0]], 0
// LLVM: br i1 %[[COND]], label %[[A1_PATH:.*]], label %[[A2_PATH:.*]],
// LLVM: br i1 %[[COND]], label %[[A1_PATH:.*]], label %[[A2_PATH:.*]]
// LLVM: [[A1_PATH]]:
// LLVM: call void @llvm.memcpy.p0.p0.i32(ptr %[[TMP:.*]], ptr {{.*}}, i32 4, i1 false)
// LLVM: br label %[[EXIT:[a-z0-9]+]]
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/CodeGen/annotations-var.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ void local(void) {
// LLVM: call void @llvm.var.annotation.p0.p0(ptr %[[ALLOC2]], ptr @.str.annotation, ptr @.str.1.annotation, i32 24, ptr null)
// LLVM: %[[ALLOC3:.*]] = alloca i32
// LLVM: call void @llvm.var.annotation.p0.p0(ptr %[[ALLOC3]], ptr @.str.3.annotation,
// LLVM-SAME: ptr @.str.1.annotation, i32 25, ptr @.args.annotation),
// LLVM-SAME: ptr @.str.1.annotation, i32 25, ptr @.args.annotation)
}
8 changes: 4 additions & 4 deletions clang/test/CIR/CodeGen/atomic-xchg-field.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ void structAtomicExchange(unsigned referenceCount, wPtr item) {
// LLVM: %[[RES:.*]] = cmpxchg weak ptr %9, i32 %[[EXP]], i32 %[[DES]] seq_cst seq_cst
// LLVM: %[[OLD:.*]] = extractvalue { i32, i1 } %[[RES]], 0
// LLVM: %[[CMP:.*]] = extractvalue { i32, i1 } %[[RES]], 1
// LLVM: %[[Z:.*]] = zext i1 %[[CMP]] to i8, !dbg !16
// LLVM: %[[X:.*]] = xor i8 %[[Z]], 1, !dbg !16
// LLVM: %[[FAIL:.*]] = trunc i8 %[[X]] to i1, !dbg !16
// LLVM: %[[Z:.*]] = zext i1 %[[CMP]] to i8
// LLVM: %[[X:.*]] = xor i8 %[[Z]], 1
// LLVM: %[[FAIL:.*]] = trunc i8 %[[X]] to i1

// LLVM: br i1 %[[FAIL:.*]], label %[[STORE_OLD:.*]], label %[[CONTINUE:.*]],
// LLVM: br i1 %[[FAIL:.*]], label %[[STORE_OLD:.*]], label %[[CONTINUE:.*]]
// LLVM: [[STORE_OLD]]:
// LLVM: store i32 %[[OLD]], ptr
// LLVM: br label %[[CONTINUE]]
Expand Down
10 changes: 5 additions & 5 deletions clang/test/CIR/CodeGen/call-via-class-member-funcptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ void fn1() { f f1; }
// LLVM: %class.f = type { %class.a }
// LLVM: %class.a = type { i8 }
// LLVM: @h = global i32 0
// LLVM: declare {{.*}} ptr @_ZN1a1bEi(i32)
// LLVM: declare ptr @_ZN1a1bEi(i32)

// LLVM: define dso_local ptr @_ZN1f1bEv(ptr [[ARG0:%.*]])
// LLVM: [[ARG0_SAVE:%.*]] = alloca ptr, i64 1, align 8
// LLVM: [[RET_SAVE:%.*]] = alloca ptr, i64 1, align 8
// LLVM: store ptr [[ARG0]], ptr [[ARG0_SAVE]], align 8,
// LLVM: store ptr [[ARG0]], ptr [[ARG0_SAVE]], align 8
// LLVM: [[ARG0_LOAD:%.*]] = load ptr, ptr [[ARG0_SAVE]], align 8
// LLVM: [[FUNC_PTR:%.*]] = getelementptr %class.f, ptr [[ARG0_LOAD]], i32 0, i32 0,
// LLVM: [[FUNC_PTR:%.*]] = getelementptr %class.f, ptr [[ARG0_LOAD]], i32 0, i32 0
// LLVM: [[VAR_H:%.*]] = load i32, ptr @h, align 4
// LLVM: [[RET_VAL:%.*]] = call ptr @_ZN1a1bEi(i32 [[VAR_H]]),
// LLVM: store ptr [[RET_VAL]], ptr [[RET_SAVE]], align 8,
// LLVM: [[RET_VAL:%.*]] = call ptr @_ZN1a1bEi(i32 [[VAR_H]])
// LLVM: store ptr [[RET_VAL]], ptr [[RET_SAVE]], align 8
// LLVM: [[RET_VAL2:%.*]] = load ptr, ptr [[RET_SAVE]], align 8
// LLVM: ret ptr [[RET_VAL2]]

Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/CodeGen/clear_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ char buffer[32] = "This is a largely unused buffer";
// CIR: cir.clear_cache %[[VAL_3]] : !cir.ptr<!void>, %[[VAL_8]],

// LLVM-LABEL: main
// LLVM: call void @llvm.clear_cache(ptr @buffer, ptr getelementptr (i8, ptr @buffer, i64 32)),
// LLVM: call void @llvm.clear_cache(ptr @buffer, ptr getelementptr (i8, ptr @buffer, i64 32))

int main(void) {
__builtin___clear_cache(buffer, buffer+32);
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/CodeGen/fun-ptr.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s -check-prefix=CIR
// RUN: %clang_cc1 -x c++ -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s -check-prefix=CIR
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o - | FileCheck %s -check-prefix=LLVM
// RUN: %clang_cc1 -x c++ -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o - | FileCheck %s -check-prefix=LLVM
// RUN: %clang -c -g -target x86_64-linux-gnu -fclangir -Xclang -emit-llvm %s -o - | FileCheck %s -check-prefix=LLVM
// RUN: %clang -c -g -x c++ -std=c++20 -target x86_64-linux-gnu -fclangir -Xclang -emit-llvm %s -o - | FileCheck %s -check-prefix=LLVM

typedef struct {
int a;
Expand Down
10 changes: 5 additions & 5 deletions clang/test/CIR/CodeGen/func_dsolocal_pie.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ int main() {
// CIR: cir.call @foo([[TMP1]]) : (!s32i) -> ()

// LLVM: define dso_local void @foo(i32 [[TMP3:%.*]])
// LLVM: [[ARG_STACK:%.*]] = alloca i32, i64 1, align 4,
// LLVM: [[ARG_STACK:%.*]] = alloca i32, i64 1, align 4
// LLVM: store i32 [[TMP3]], ptr [[ARG_STACK]], align 4
// LLVM: ret void,
// LLVM: ret void

// LLVM: define dso_local i32 @main()
// LLVM: [[TMP4:%.*]] = alloca i32, i64 1, align 4,
// LLVM: call void @foo(i32 2),
// LLVM: [[TMP4:%.*]] = alloca i32, i64 1, align 4
// LLVM: call void @foo(i32 2)
// LLVM: store i32 0, ptr [[TMP4]], align 4
// LLVM: [[RET_VAL:%.*]] = load i32, ptr [[TMP4]], align 4
// LLVM: ret i32 [[RET_VAL]],
// LLVM: ret i32 [[RET_VAL]]
2 changes: 2 additions & 0 deletions clang/test/CIR/CodeGen/global-new.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// RUN: %clang_cc1 -std=c++20 -triple aarch64-none-linux-android21 -fclangir -emit-cir -mmlir --mlir-print-ir-before=cir-lowering-prepare %s -o %t.cir 2>&1 | FileCheck %s -check-prefix=CIR_BEFORE
// RUN: FileCheck %s -check-prefix=CIR_AFTER --input-file=%t.cir
// RUN: %clang_cc1 -std=c++20 -triple aarch64-none-linux-android21 -fclangir -emit-llvm %s -o %t.ll
// RUN: %clang -c -g -std=c++20 -target aarch64-linux-android21 -fclangir -Xclang -emit-llvm %s -o %t.ll
// RUN: FileCheck %s -check-prefix=LLVM --input-file=%t.ll
// RUN: %clang_cc1 -std=c++20 -triple aarch64-none-linux-android21 -fclangir -emit-cir -fexceptions -fcxx-exceptions %s -o %t.eh.cir
// RUN: FileCheck %s -check-prefix=CIR_EH --input-file=%t.eh.cir
// RUN: %clang_cc1 -std=c++20 -triple aarch64-none-linux-android21 -fclangir -fno-clangir-call-conv-lowering -emit-cir-flat -fno-clangir-call-conv-lowering -fexceptions -fcxx-exceptions %s -o %t.eh.flat.cir
// RUN: FileCheck %s -check-prefix=CIR_FLAT_EH --input-file=%t.eh.flat.cir
// RUN: %clang_cc1 -std=c++20 -triple aarch64-none-linux-android21 -fclangir -emit-llvm -fno-clangir-call-conv-lowering -fexceptions -fcxx-exceptions %s -o %t.eh.ll
// RUN: %clang -c -g -std=c++20 -target aarch64-linux-android21 -fclangir -Xclang -emit-llvm -fno-clangir-call-conv-lowering -fexceptions -fcxx-exceptions %s -o %t.eh.ll
// RUN: FileCheck %s -check-prefix=LLVM_EH --input-file=%t.eh.ll

struct e { e(int); };
Expand Down
34 changes: 17 additions & 17 deletions clang/test/CIR/CodeGen/initlist-ptr-ptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,26 @@ void test() {
// LLVM: @.str.1 = private constant [3 x i8] c"uv\00"

// LLVM: define linkonce_odr void @_ZSt1fIPKcEvSt16initializer_listIT_E(%"class.std::initializer_list<const char *>" [[ARG0:%.*]])
// LLVM: [[LOCAL_PTR:%.*]] = alloca %"class.std::initializer_list<const char *>", i64 1, align 8,
// LLVM: store %"class.std::initializer_list<const char *>" [[ARG0]], ptr [[LOCAL_PTR]], align 8,
// LLVM: ret void,
// LLVM: [[LOCAL_PTR:%.*]] = alloca %"class.std::initializer_list<const char *>", i64 1, align 8
// LLVM: store %"class.std::initializer_list<const char *>" [[ARG0]], ptr [[LOCAL_PTR]], align 8
// LLVM: ret void
// LLVM: }

// LLVM: define dso_local void @_ZSt4testv()
// LLVM: [[INIT_STRUCT:%.*]] = alloca %"class.std::initializer_list<const char *>", i64 1, align 8,
// LLVM: [[ELEM_ARRAY_PTR:%.*]] = alloca [2 x ptr], i64 1, align 8,
// LLVM: br label %[[SCOPE_START:.*]],
// LLVM: [[INIT_STRUCT:%.*]] = alloca %"class.std::initializer_list<const char *>", i64 1, align 8
// LLVM: [[ELEM_ARRAY_PTR:%.*]] = alloca [2 x ptr], i64 1, align 8
// LLVM: br label %[[SCOPE_START:.*]]
// LLVM: [[SCOPE_START]]: ; preds = %0
// LLVM: [[PTR_FIRST_ELEM:%.*]] = getelementptr ptr, ptr [[ELEM_ARRAY_PTR]], i32 0,
// LLVM: store ptr @.str, ptr [[PTR_FIRST_ELEM]], align 8,
// LLVM: [[PTR_SECOND_ELEM:%.*]] = getelementptr ptr, ptr [[PTR_FIRST_ELEM]], i64 1,
// LLVM: store ptr @.str.1, ptr [[PTR_SECOND_ELEM]], align 8,
// LLVM: [[INIT_START_FLD_PTR:%.*]] = getelementptr %"class.std::initializer_list<const char *>", ptr [[INIT_STRUCT]], i32 0, i32 0,
// LLVM: [[INIT_END_FLD_PTR:%.*]] = getelementptr %"class.std::initializer_list<const char *>", ptr [[INIT_STRUCT]], i32 0, i32 1,
// LLVM: [[ELEM_ARRAY_END:%.*]] = getelementptr [2 x ptr], ptr [[ELEM_ARRAY_PTR]], i64 2,
// LLVM: store ptr [[ELEM_ARRAY_END]], ptr [[INIT_END_FLD_PTR]], align 8,
// LLVM: [[ARG2PASS:%.*]] = load %"class.std::initializer_list<const char *>", ptr [[INIT_STRUCT]], align 8,
// LLVM: call void @_ZSt1fIPKcEvSt16initializer_listIT_E(%"class.std::initializer_list<const char *>" [[ARG2PASS]]),
// LLVM: br label %[[SCOPE_END:.*]],
// LLVM: [[PTR_FIRST_ELEM:%.*]] = getelementptr ptr, ptr [[ELEM_ARRAY_PTR]], i32 0
// LLVM: store ptr @.str, ptr [[PTR_FIRST_ELEM]], align 8
// LLVM: [[PTR_SECOND_ELEM:%.*]] = getelementptr ptr, ptr [[PTR_FIRST_ELEM]], i64 1
// LLVM: store ptr @.str.1, ptr [[PTR_SECOND_ELEM]], align 8
// LLVM: [[INIT_START_FLD_PTR:%.*]] = getelementptr %"class.std::initializer_list<const char *>", ptr [[INIT_STRUCT]], i32 0, i32 0
// LLVM: [[INIT_END_FLD_PTR:%.*]] = getelementptr %"class.std::initializer_list<const char *>", ptr [[INIT_STRUCT]], i32 0, i32 1
// LLVM: [[ELEM_ARRAY_END:%.*]] = getelementptr [2 x ptr], ptr [[ELEM_ARRAY_PTR]], i64 2
// LLVM: store ptr [[ELEM_ARRAY_END]], ptr [[INIT_END_FLD_PTR]], align 8
// LLVM: [[ARG2PASS:%.*]] = load %"class.std::initializer_list<const char *>", ptr [[INIT_STRUCT]], align 8
// LLVM: call void @_ZSt1fIPKcEvSt16initializer_listIT_E(%"class.std::initializer_list<const char *>" [[ARG2PASS]])
// LLVM: br label %[[SCOPE_END:.*]]
// LLVM: [[SCOPE_END]]: ; preds = %[[SCOPE_START]]
// LLVM: ret void
26 changes: 13 additions & 13 deletions clang/test/CIR/CodeGen/initlist-ptr-unsigned.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@ void test() {

// LLVM: %"class.std::initializer_list<int>" = type { ptr, i64 }
// LLVM: define linkonce_odr void @_ZSt1fIiEvSt16initializer_listIT_E(%"class.std::initializer_list<int>" [[ARG:%.*]])
// LLVM: [[LOCAL:%.*]] = alloca %"class.std::initializer_list<int>", i64 1, align 8,
// LLVM: store %"class.std::initializer_list<int>" [[ARG]], ptr [[LOCAL]], align 8,
// LLVM: [[LOCAL:%.*]] = alloca %"class.std::initializer_list<int>", i64 1, align 8
// LLVM: store %"class.std::initializer_list<int>" [[ARG]], ptr [[LOCAL]], align 8

// LLVM: define dso_local void @_ZSt4testv()
// LLVM: [[INIT_STRUCT:%.*]] = alloca %"class.std::initializer_list<int>", i64 1, align 8,
// LLVM: [[ELEM_ARRAY:%.*]] = alloca [1 x i32], i64 1, align 4,
// LLVM: br label %[[SCOPE_START:.*]],
// LLVM: [[INIT_STRUCT:%.*]] = alloca %"class.std::initializer_list<int>", i64 1, align 8
// LLVM: [[ELEM_ARRAY:%.*]] = alloca [1 x i32], i64 1, align 4
// LLVM: br label %[[SCOPE_START:.*]]
// LLVM: [[SCOPE_START]]: ; preds = %0
// LLVM: [[PTR_FIRST_ELEM:%.*]] = getelementptr i32, ptr [[ELEM_ARRAY]], i32 0,
// LLVM: store i32 7, ptr [[PTR_FIRST_ELEM]], align 4,
// LLVM: [[ELEM_ARRAY_PTR:%.*]] = getelementptr %"class.std::initializer_list<int>", ptr [[INIT_STRUCT]], i32 0, i32 0,
// LLVM: store ptr [[ELEM_ARRAY]], ptr [[ELEM_ARRAY_PTR]], align 8,
// LLVM: [[INIT_LEN_FLD:%.*]] = getelementptr %"class.std::initializer_list<int>", ptr [[INIT_STRUCT]], i32 0, i32 1,
// LLVM: store i64 1, ptr [[INIT_LEN_FLD]], align 8,
// LLVM: [[ARG2PASS:%.*]] = load %"class.std::initializer_list<int>", ptr [[INIT_STRUCT]], align 8,
// LLVM: [[PTR_FIRST_ELEM:%.*]] = getelementptr i32, ptr [[ELEM_ARRAY]], i32 0
// LLVM: store i32 7, ptr [[PTR_FIRST_ELEM]], align 4
// LLVM: [[ELEM_ARRAY_PTR:%.*]] = getelementptr %"class.std::initializer_list<int>", ptr [[INIT_STRUCT]], i32 0, i32 0
// LLVM: store ptr [[ELEM_ARRAY]], ptr [[ELEM_ARRAY_PTR]], align 8
// LLVM: [[INIT_LEN_FLD:%.*]] = getelementptr %"class.std::initializer_list<int>", ptr [[INIT_STRUCT]], i32 0, i32 1
// LLVM: store i64 1, ptr [[INIT_LEN_FLD]], align 8
// LLVM: [[ARG2PASS:%.*]] = load %"class.std::initializer_list<int>", ptr [[INIT_STRUCT]], align 8
// LLVM: call void @_ZSt1fIiEvSt16initializer_listIT_E(%"class.std::initializer_list<int>" [[ARG2PASS]])
// LLVM: br label %[[SCOPE_END:.*]],
// LLVM: br label %[[SCOPE_END:.*]]
// LLVM: [[SCOPE_END]]: ; preds = %[[SCOPE_START]]
// LLVM: ret void
2 changes: 1 addition & 1 deletion clang/test/CIR/CodeGen/libc.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void *memmove(void *, const void *, unsigned long);
void testMemmove(void *src, const void *dst, unsigned long size) {
memmove(dst, src, size);
// CHECK: cir.libc.memmove %{{.+}} bytes from %{{.+}} to %{{.+}} : !cir.ptr<!void>, !u64i
// LLVM: call void @llvm.memmove.{{.+}}.i64(ptr %{{.+}}, ptr %{{.+}}, i64 %{{.+}}, i1 false),
// LLVM: call void @llvm.memmove.{{.+}}.i64(ptr %{{.+}}, ptr %{{.+}}, i64 %{{.+}}, i1 false)
}

// Should generate CIR's builtin memset op.
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/CodeGen/new-null.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu %s -fclangir -emit-cir -o %t.cir
// RUN: FileCheck --input-file=%t.cir -check-prefix=CIR %s
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu %s -fclangir -emit-llvm -o %t.ll
// RUN: %clang -c -g -std=c++17 -target x86_64-linux-gnu -fclangir -Xclang -emit-llvm %s -o %t.ll
// RUN: FileCheck --input-file=%t.ll -check-prefix=LLVM %s

// TODO: This file is inspired by clang/test/CodeGenCXX/new.cpp, add all tests from it.
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/CodeGen/pass-object-size.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll
// RUN: %clang -c -g -target x86_64-linux-gnu -fclangir -Xclang -emit-llvm %s -o %t.ll
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM

void b(void *__attribute__((pass_object_size(0))));
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/CodeGen/sourcelocation.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll
// RUN: %clang -c -g -target x86_64-linux-gnu -fclangir -Xclang -emit-llvm %s -o %t.ll
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM

int s0(int a, int b) {
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/CodeGen/try-catch-dtors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fcxx-exceptions -fexceptions -mconstructor-aliases -fclangir -emit-cir-flat -fno-clangir-call-conv-lowering %s -o %t.flat.cir
// RUN: FileCheck --input-file=%t.flat.cir --check-prefix=CIR_FLAT %s
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fcxx-exceptions -fexceptions -mconstructor-aliases -fclangir -emit-llvm -fno-clangir-call-conv-lowering %s -o %t.ll
// RUN: %clang -c -g -std=c++20 -target x86_64-linux-gnu -Wno-unused-value -fcxx-exceptions -fexceptions -mconstructor-aliases -fclangir -Xclang -emit-llvm -fno-clangir-call-conv-lowering %s -o %t.ll
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s

struct Vec {
Expand Down
Loading

0 comments on commit 45a0669

Please sign in to comment.