[llvm] d7bb842 - [llubi] Use correct tag bitwidth to recover provenances (#230852)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 11 02:51:00 PDT 2026
Author: Yingwei Zheng
Date: 2026-10-11T17:50:56+08:00
New Revision: d7bb8422bcf0d327b98fbf0525d6284fdf87e748
URL: https://github.com/llvm/llvm-project/commit/d7bb8422bcf0d327b98fbf0525d6284fdf87e748
DIFF: https://github.com/llvm/llvm-project/commit/d7bb8422bcf0d327b98fbf0525d6284fdf87e748.diff
LOG: [llubi] Use correct tag bitwidth to recover provenances (#230852)
Tag always uses the pointer width rather than the padded one. Previously
the tag lookup always missed due to the width mismatch.
The test is generated by DeepSeek-V4.1-Flash.
Added:
llvm/test/tools/llubi/non_byte_size_ptr.ll
Modified:
llvm/tools/llubi/lib/Context.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llubi/non_byte_size_ptr.ll b/llvm/test/tools/llubi/non_byte_size_ptr.ll
new file mode 100644
index 0000000000000..1b12c813bd3eb
--- /dev/null
+++ b/llvm/test/tools/llubi/non_byte_size_ptr.ll
@@ -0,0 +1,24 @@
+; NOTE: Assertions have been autogenerated by utils/update_llubi_test_checks.py UTC_ARGS: --version 6
+; RUN: llubi --verbose < %s 2>&1 | FileCheck %s
+
+target datalayout = "e-p:52:64"
+
+ at g = global i8 0
+
+; The pointer is padded with 4 bits. Make sure we use the tag with correct bitwidth to recover
+; the provenance.
+
+define void @main() {
+ %p = alloca ptr
+ store ptr @g, ptr %p
+ %q = load ptr, ptr %p
+ load i8, ptr %q
+ ret void
+}
+; CHECK: Entering function: main
+; CHECK-NEXT: %p = alloca ptr, align 8 => ptr 0x10 [p]
+; CHECK-NEXT: store ptr @g, ptr %p, align 8
+; CHECK-NEXT: %q = load ptr, ptr %p, align 8 => ptr 0x8 [@g]
+; CHECK-NEXT: %1 = load i8, ptr %q, align 1 => i8 0
+; CHECK-NEXT: ret void
+; CHECK-NEXT: Exiting function: main
diff --git a/llvm/tools/llubi/lib/Context.cpp b/llvm/tools/llubi/lib/Context.cpp
index 1650d09fa1456..924f6a1bea993 100644
--- a/llvm/tools/llubi/lib/Context.cpp
+++ b/llvm/tools/llubi/lib/Context.cpp
@@ -561,7 +561,7 @@ AnyValue Context::fromBytes(ConstBytesView Bytes, Type *Ty,
assert(Ty->isPointerTy() && "Expect a pointer type");
// Try to recover provenance from the tag.
if (IsTagValid) {
- APInt Tag(NumBitsToExtract, RawTagBits);
+ APInt Tag(NumBits, RawTagBits);
if (auto Prov = TaggedProvenances.lookup(Tag))
return Pointer(std::move(Prov), Bits);
}
More information about the llvm-commits
mailing list