Skip to content

Commit

Permalink
feat: keep function names
Browse files Browse the repository at this point in the history
  • Loading branch information
ajlekcahdp4 committed Nov 19, 2024
1 parent 2f538de commit 4a45fad
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions lib/lifter/block-ir-builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,13 @@ void materialize_registers(MachineFunction &mf, Function &func, reg2vals &rmap,
auto *generate_function_object(Module &m, MachineFunction &mf, reg2vals &rmap,
MachineModuleInfo &mmi, StructType &state) {
auto *ret_type = Type::getIntNTy(m.getContext(), 64);
auto &reg_info = mf.getRegInfo();
auto *func_type = FunctionType::get(
ret_type, ArrayRef<Type *>{PointerType::getUnqual(m.getContext())},
/* is var arg */ false);
auto name_str = mf.getName().str();
mf.getFunction().setName(mf.getName().str() + ".old");
auto *func =
Function::Create(func_type, Function::ExternalLinkage, mf.getName(), m);
Function::Create(func_type, Function::ExternalLinkage, name_str, m);
return func;
}

Expand Down
2 changes: 1 addition & 1 deletion test/tools/llvm-bleach/ir-addsub.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# CHECK: %register_state = type { [32 x i64] }

# CHECK: define i64 @foo.1(ptr %0) {
# CHECK: define i64 @foo(ptr %0) {
# CHECK-NEXT: %GPRS = getelementptr %register_state, ptr %0, i64 0, i64 0
# CHECK-NEXT: %2 = getelementptr inbounds [32 x i64], ptr %GPRS, i64 0, i64 0
# CHECK-NEXT: %X0 = load i64, ptr %2, align 8
Expand Down
2 changes: 1 addition & 1 deletion test/tools/llvm-bleach/ir-logical-branches.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# RUN: %bin/llvm-bleach %S/inputs/logical-branches.mir \
# RUN: --instructions=%S/inputs/logical.yaml -noinline-instr | filecheck %s

# CHECK: define i64 @foo.1(ptr %0) {
# CHECK: define i64 @foo(ptr %0) {
# CHECK-NEXT: %GPRS = getelementptr %register_state, ptr %0, i64 0, i64 0
# CHECK-NEXT: %2 = getelementptr inbounds [32 x i64], ptr %GPRS, i64 0, i64 0
# CHECK-NEXT: %X0 = load i64, ptr %2, align 8
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# RUN: %bin/llvm-bleach %S/inputs/logical-cond-branches-no-blocks.mir \
# RUN: --instructions=%S/inputs/logical.yaml -noinline-instr | filecheck %s

# CHECK: define i64 @foo.1(ptr %0) {
# CHECK: define i64 @foo(ptr %0) {
# CHECK-NEXT: %GPRS = getelementptr %register_state, ptr %0, i64 0, i64 0
# CHECK-NEXT: %2 = getelementptr inbounds [32 x i64], ptr %GPRS, i64 0, i64 0
# CHECK-NEXT: %X0 = load i64, ptr %2, align 8
Expand Down
2 changes: 1 addition & 1 deletion test/tools/llvm-bleach/ir-logical-cond-branches.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# RUN: %bin/llvm-bleach %S/inputs/logical-cond-branches.mir \
# RUN: --instructions=%S/inputs/logical.yaml -noinline-instr | filecheck %s

# CHECK: define i64 @foo.1(ptr %0) {
# CHECK: define i64 @foo(ptr %0) {
# CHECK-NEXT: %GPRS = getelementptr %register_state, ptr %0, i64 0, i64 0
# CHECK-NEXT: %2 = getelementptr inbounds [32 x i64], ptr %GPRS, i64 0, i64 0
# CHECK-NEXT: %X0 = load i64, ptr %2, align 8
Expand Down
2 changes: 1 addition & 1 deletion test/tools/llvm-bleach/ir-logical.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# RUN: %bin/llvm-bleach %S/inputs/logical.mir \
# RUN: --instructions=%S/inputs/logical.yaml -noinline-instr | filecheck %s

# CHECK: define i64 @foo.1(ptr %0) {
# CHECK: define i64 @foo(ptr %0) {
# CHECK-NEXT: %GPRS = getelementptr %register_state, ptr %0, i64 0, i64 0
# CHECK-NEXT: %2 = getelementptr inbounds [32 x i64], ptr %GPRS, i64 0, i64 0
# CHECK-NEXT: %X0 = load i64, ptr %2, align 8
Expand Down
2 changes: 1 addition & 1 deletion test/tools/llvm-bleach/many-branches-noinline.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# RUN: %bin/llvm-bleach %S/inputs/many-branches.mir \
# RUN: --instructions=%S/inputs/logical.yaml -noinline-instr | filecheck %s

# CHECK: define i64 @SnippyFunction.1(ptr %0) {
# CHECK: define i64 @SnippyFunction(ptr %0) {
# CHECK-NEXT: %GPRS = getelementptr %register_state, ptr %0, i64 0, i64 0
# CHECK-NEXT: %2 = getelementptr inbounds [32 x i64], ptr %GPRS, i64 0, i64 0
# CHECK-NEXT: %X0 = load i64, ptr %2, align 8
Expand Down
4 changes: 2 additions & 2 deletions test/tools/llvm-bleach/many-branches.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# RUN: %bin/llvm-bleach %S/inputs/many-branches.mir \
# RUN: --instructions=%S/inputs/logical.yaml | filecheck %s

# CHECK: define i64 @SnippyFunction.1(ptr %0) {
# CHECK: define i64 @SnippyFunction(ptr %0) {
# CHECK-NEXT: %GPRS = getelementptr %register_state, ptr %0, i64 0, i64 0
# CHECK-NEXT: %2 = getelementptr inbounds [32 x i64], ptr %GPRS, i64 0, i64 0
# CHECK-NEXT: %X0 = load i64, ptr %2, align 8
Expand Down Expand Up @@ -59,7 +59,7 @@
# CHECK-NEXT: %X26 = load i64, ptr %28, align 8
# CHECK-NEXT: %29 = getelementptr inbounds [32 x i64], ptr %GPRS, i64 0, i64 27
# CHECK-NEXT: %X27 = load i64, ptr %29, align 8
# -NEXT: %30 = getelementptr inbounds [32 x i64], ptr %GPRS, i64 0, i64 28
# CHECK-NEXT: %30 = getelementptr inbounds [32 x i64], ptr %GPRS, i64 0, i64 28
# CHECK-NEXT: %X28 = load i64, ptr %30, align 8
# CHECK-NEXT: %31 = getelementptr inbounds [32 x i64], ptr %GPRS, i64 0, i64 29
# CHECK-NEXT: %X29 = load i64, ptr %31, align 8
Expand Down

0 comments on commit 4a45fad

Please sign in to comment.