From 9bc2c3f30f60cd6d17a11d7521a4fc4a249894d5 Mon Sep 17 00:00:00 2001 From: Iti Shree Date: Sun, 28 Apr 2024 23:18:36 +0100 Subject: [PATCH] Fix handling of constants in FixStackmapSpillReloads pass. Compiling yklua with backend optimisations enabled in -O0 triggers bug in yk with error: "Unrecoginized operand type". This commit fix the bug by completing the switch case for ConstantOp in FixStackmapSpillReloads.cpp. --- .../CodeGen/Yk/FixStackmapsSpillReloads.cpp | 6 +++- .../yk-stackmaps-spillreloads-fix-consts.ll | 33 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 llvm/test/CodeGen/X86/yk-stackmaps-spillreloads-fix-consts.ll diff --git a/llvm/lib/CodeGen/Yk/FixStackmapsSpillReloads.cpp b/llvm/lib/CodeGen/Yk/FixStackmapsSpillReloads.cpp index 5985df6574bf75..a0eee236392c30 100644 --- a/llvm/lib/CodeGen/Yk/FixStackmapsSpillReloads.cpp +++ b/llvm/lib/CodeGen/Yk/FixStackmapsSpillReloads.cpp @@ -210,7 +210,11 @@ bool FixStackmapsSpillReloads::runOnMachineFunction(MachineFunction &MF) { MIB.add(*MOI); // Offset break; } - case StackMaps::ConstantOp: {break;} + case StackMaps::ConstantOp: { + MOI++; + MIB.add(*MOI); + break; + } case StackMaps::NextLive: {break;} } MOI++; diff --git a/llvm/test/CodeGen/X86/yk-stackmaps-spillreloads-fix-consts.ll b/llvm/test/CodeGen/X86/yk-stackmaps-spillreloads-fix-consts.ll new file mode 100644 index 00000000000000..d32dd1c7e506f7 --- /dev/null +++ b/llvm/test/CodeGen/X86/yk-stackmaps-spillreloads-fix-consts.ll @@ -0,0 +1,33 @@ +; RUN: llc -stop-after fix-stackmaps-spill-reloads --yk-insert-stackmaps --yk-stackmap-spillreloads-fix < %s | FileCheck %s +; CHECK: STACKMAP 1, 0, 0, $rbp, -8, 3, implicit-def dead early-clobber $r11 +@hash_search_j = dso_local global i64 0, align 8 + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @luaH_getint(i64 noundef %0) #0 { + %2 = alloca i64, align 8 + store i64 %0, i64* %2, align 8 + ret void +} + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local i64 @hash_search() #0 { + %1 = alloca i64, align 8 + %2 = load i64, i64* @hash_search_j, align 8 + %3 = icmp ne i64 %2, 0 + br i1 %3, label %4, label %5 + +4: ; preds = %0 + call void @luaH_getint(i64 noundef 9223372036854775807) + store i64 9223372036854775807, i64* %1, align 8 + br label %6 + +5: ; preds = %0 + store i64 0, i64* %1, align 8 + br label %6 + +6: ; preds = %5, %4 + %7 = load i64, i64* %1, align 8 + ret i64 %7 +} + +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }