From b75a3bbad80f91e5176d41a457e26c4d0038237a Mon Sep 17 00:00:00 2001 From: Churkin Aleksey Date: Thu, 17 Sep 2026 14:17:38 +0300 Subject: [PATCH] llvm2alive: skip string attributes in handleParamAttrs Guard the loop the same way handleRetAttrs and handleFnAttrs already do: only enum, int and type attributes reach the switch. --- llvm_util/llvm2alive.cpp | 4 ++++ tests/alive-tv/attrs/string-param-attr.srctgt.ll | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/alive-tv/attrs/string-param-attr.srctgt.ll diff --git a/llvm_util/llvm2alive.cpp b/llvm_util/llvm2alive.cpp index 393408177..b7e821f99 100644 --- a/llvm_util/llvm2alive.cpp +++ b/llvm_util/llvm2alive.cpp @@ -1574,6 +1574,10 @@ class llvm2alive_ : public llvm::InstVisitor> { Value **val, bool is_callsite) { bool precise = true; for (const llvm::Attribute &llvmattr : aset) { + if (!llvmattr.isEnumAttribute() && !llvmattr.isIntAttribute() && + !llvmattr.isTypeAttribute()) + continue; + switch (llvmattr.getKindAsEnum()) { case llvm::Attribute::InReg: attrs.set(ParamAttrs::InReg); diff --git a/tests/alive-tv/attrs/string-param-attr.srctgt.ll b/tests/alive-tv/attrs/string-param-attr.srctgt.ll new file mode 100644 index 000000000..24537d7a2 --- /dev/null +++ b/tests/alive-tv/attrs/string-param-attr.srctgt.ll @@ -0,0 +1,16 @@ +; string attributes are legal on parameters (LLVM-C frontends emit them as a +; fallback when LLVMGetEnumAttributeKindForName returns 0). handleParamAttrs +; used to call getKindAsEnum() on them, which asserts. +define i32 @src(ptr "foo"="bar" %p) { + %v = load i32, ptr %p + call void @g(ptr "baz"="qux" %p) + ret i32 %v +} + +define i32 @tgt(ptr "foo"="bar" %p) { + %v = load i32, ptr %p + call void @g(ptr "baz"="qux" %p) + ret i32 %v +} + +declare void @g(ptr)