This patch puts together a lot more of the CIR infrastructure for function attributes, plus adds a bunch of 'TODO' messages for areas that have been skipped. Along the way, we also implement 8 attributes in some way: -Convergent gets a little more work, to make the `noconvergent` C attribute have an effect -optsize/minsize are implemented, sourced from the command line -nobuiltin is a call-only attribute that tells not to replace the individual call with a builtin. This is a touch confusing, since no-builtins is an attribute that means "don't replace anything in the body of this function with builtins (from this list)". The spelling confusion is existing, and it seems that changing the names away from LLVM would be confusing. -save_reg_params & zero_call_used_regs are boht pretty simple registers -temp-func-name just passes a string to LLVM, consistent with existing implementation. -default-func-attrs is a difficult one. It takes command line arguments and passes them as LLVM-IR attributes directly on functions/calls. In the dialect, we are capturing these in their own attribute to pass them on correctly. However, this is one we cannot recover from LLVM-IR for obvious reasons, so we instead choose to let the 'passthrough' mechanism work for those.
34 lines
1.2 KiB
C++
34 lines
1.2 KiB
C++
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -ftrap-function=trap_func -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 -ftrap-function=trap_func -fclangir -emit-llvm %s -o %t.ll
|
|
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
|
|
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -ftrap-function=trap_func -emit-llvm %s -o %t.ll
|
|
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
|
|
|
|
extern "C" {
|
|
void normal() {}
|
|
// CIR: cir.func{{.*}}@normal()
|
|
// CIR-NOT: trap_func_name
|
|
// LLVM: define{{.*}}@normal() #[[FUNC_ATTR:.*]] {
|
|
void trap_func(){}
|
|
// CIR: cir.func{{.*}}@trap_func()
|
|
// CIR-NOT: trap_func_name
|
|
// LLVM: define{{.*}}@trap_func() #[[FUNC_ATTR]] {
|
|
|
|
void caller() {
|
|
normal();
|
|
// CIR: cir.call{{.*}}normal()
|
|
// CIR-SAME: trap_func_name = "trap_func"
|
|
// LLVM: call void{{.*}} @normal() #[[CALL_ATTR:.*]]
|
|
trap_func();
|
|
// CIR: cir.call{{.*}}trap_func()
|
|
// CIR-SAME: trap_func_name = "trap_func"
|
|
// LLVM: call void{{.*}} @trap_func() #[[CALL_ATTR]]
|
|
}
|
|
}
|
|
|
|
// LLVM: attributes #[[FUNC_ATTR]]
|
|
// LLVM-NOT: trap-func-name
|
|
// LLVM: attributes #[[CALL_ATTR]]
|
|
// LLVM-SAME: "trap-func-name"="trap_func"
|