[llvm] [Bitcode][Asm] Read metadata value from operand bundles in and out (PR #89649)

via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 22 11:29:57 PDT 2024


https://github.com/Prabhuk created https://github.com/llvm/llvm-project/pull/89649

Metadata operand bundle value is garbage when LLVM IR is compiled to
bitcode. A small reproducer and a potential test that tests the fix for
this problem.

Differential revision: https://reviews.llvm.org/D107039


>From 2ee635ac795c064c1db88e07cdff05aff828c21e Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Mon, 22 Apr 2024 11:29:44 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1
---
 .../2021-07-22-Metadata-Operand-Bundles.ll    | 12 +++++++++++
 llvm/test/Bitcode/compatibility.ll            | 21 +++++++++++++++++++
 llvm/test/Bitcode/operand-bundles.ll          | 20 ++++++++++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 llvm/test/Bitcode/2021-07-22-Metadata-Operand-Bundles.ll

diff --git a/llvm/test/Bitcode/2021-07-22-Metadata-Operand-Bundles.ll b/llvm/test/Bitcode/2021-07-22-Metadata-Operand-Bundles.ll
new file mode 100644
index 00000000000000..8080e13af67fc3
--- /dev/null
+++ b/llvm/test/Bitcode/2021-07-22-Metadata-Operand-Bundles.ll
@@ -0,0 +1,12 @@
+; This test ensures that we get a metadata operand bundle value in and out.
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+declare void @callee()
+
+; CHECK-LABEL: call_with_operand_bundle(
+define void @call_with_operand_bundle() {
+  ; CHECK: call void @op_bundle_callee() [ "op_type"(metadata !"metadata_string") ]
+  call void @callee() [ "op_type"(metadata !"metadata_string") ]
+
+  ret void
+}
diff --git a/llvm/test/Bitcode/compatibility.ll b/llvm/test/Bitcode/compatibility.ll
index b374924516d665..935e7af9a599c8 100644
--- a/llvm/test/Bitcode/compatibility.ll
+++ b/llvm/test/Bitcode/compatibility.ll
@@ -1819,6 +1819,14 @@ define void @call_with_operand_bundle4(ptr %ptr) {
   ret void
 }
 
+define void @call_with_operand_bundle5(ptr %ptr) {
+; CHECK-LABEL: call_with_operand_bundle5(
+ entry:
+  call void @op_bundle_callee_0() [ "foo"(metadata !"metadata_string") ]
+; CHECK: call void @op_bundle_callee_0() [ "foo"(metadata !"metadata_string") ]
+  ret void
+}
+
 ; Invoke versions of the above tests:
 
 
@@ -1914,6 +1922,19 @@ normal:
   ret void
 }
 
+define void @invoke_with_operand_bundle5(ptr %ptr) personality i8 3 {
+; CHECK-LABEL: @invoke_with_operand_bundle5(
+ entry:
+  invoke void @op_bundle_callee_0() [ "foo"(metadata !"metadata_string") ] to label %normal unwind label %exception
+; CHECK: invoke void @op_bundle_callee_0() [ "foo"(metadata !"metadata_string") ]
+
+exception:
+  %cleanup = landingpad i8 cleanup
+  br label %normal
+normal:
+  ret void
+}
+
 declare void @vaargs_func(...)
 define void @invoke_with_operand_bundle_vaarg(ptr %ptr) personality i8 3 {
 ; CHECK-LABEL: @invoke_with_operand_bundle_vaarg(
diff --git a/llvm/test/Bitcode/operand-bundles.ll b/llvm/test/Bitcode/operand-bundles.ll
index ab28cffd84aa29..99591672656e87 100644
--- a/llvm/test/Bitcode/operand-bundles.ll
+++ b/llvm/test/Bitcode/operand-bundles.ll
@@ -58,6 +58,13 @@ define void @f4(i32* %ptr) {
 
 ; Invoke versions of the above tests:
 
+define void @f5(i32* %ptr) {
+; CHECK-LABEL: @f5(
+ entry:
+  call void @callee0() [ "foo"(metadata !"metadata_string") ]
+; CHECK: call void @callee0() [ "foo"(metadata !"metadata_string") ]
+  ret void
+}
 
 define void @g0(i32* %ptr) personality i8 3 {
 ; CHECK-LABEL: @g0(
@@ -150,3 +157,16 @@ exception:
 normal:
   ret void
 }
+
+define void @g5(i32* %ptr) personality i8 3 {
+; CHECK-LABEL: @g5(
+ entry:
+  invoke void @callee0() [ "foo"(metadata !"metadata_string") ] to label %normal unwind label %exception
+; CHECK: invoke void @callee0() [ "foo"(metadata !"metadata_string") ]
+
+exception:
+  %cleanup = landingpad i8 cleanup
+  br label %normal
+normal:
+  ret void
+}
\ No newline at end of file



More information about the llvm-commits mailing list