From f38c2715a178a10e4c5509bbb2bf8bcfa992ba13 Mon Sep 17 00:00:00 2001 From: Lu Jiao Date: Mon, 24 Jun 2024 13:51:19 +0800 Subject: [PATCH] Add ImmutableString str The global variable created from ImmutableString must have str name. or it can not be used from inlineFunction --- include/llvm-dialects/Dialect/Dialect.td | 2 +- test/example/generated/ExampleDialect.cpp.inc | 2 +- test/example/test-builder.test | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/llvm-dialects/Dialect/Dialect.td b/include/llvm-dialects/Dialect/Dialect.td index fd4aa27..9a50913 100644 --- a/include/llvm-dialects/Dialect/Dialect.td +++ b/include/llvm-dialects/Dialect/Dialect.td @@ -280,7 +280,7 @@ def : AttrLlvmType; def : AttrLlvmType; def ImmutableStringAttr : Attr<"::llvm::StringRef"> { - let toLlvmValue = [{ $_builder.CreateGlobalString($0) }]; + let toLlvmValue = [{ $_builder.CreateGlobalString($0, "str") }]; let fromLlvmValue = [{ ::llvm::cast<::llvm::ConstantDataArray>(::llvm::cast<::llvm::GlobalVariable>($0)->getInitializer())->getAsString() }]; let isImmutable = true; } diff --git a/test/example/generated/ExampleDialect.cpp.inc b/test/example/generated/ExampleDialect.cpp.inc index 49680c7..67768ca 100644 --- a/test/example/generated/ExampleDialect.cpp.inc +++ b/test/example/generated/ExampleDialect.cpp.inc @@ -2064,7 +2064,7 @@ initial ::llvm::SmallVector<::llvm::Value*, 1> args = { - b.CreateGlobalString(val) + b.CreateGlobalString(val, "str") }; return ::llvm::cast(b.CreateCall(fn, args, instName)); diff --git a/test/example/test-builder.test b/test/example/test-builder.test index eef0f91..ec1e292 100644 --- a/test/example/test-builder.test +++ b/test/example/test-builder.test @@ -3,7 +3,7 @@ ; RUN: llvm-dialects-example - | FileCheck --check-prefixes=CHECK %s ;. -; CHECK: @[[GLOB0:[0-9]+]] = private unnamed_addr constant [13 x i8] c"Hello world!\00", align 1 +; CHECK: @[[GLOB0:.*]] = private unnamed_addr constant [13 x i8] c"Hello world!\00", align 1 ;. ; CHECK-LABEL: @example( ; CHECK-NEXT: entry: @@ -45,6 +45,6 @@ ; CHECK-NEXT: [[TWO_VARARGS:%.*]] = call i32 (...) @xd.inst.name.conflict.varargs(ptr [[P1]], i8 [[P2]]) ; CHECK-NEXT: [[THREE_VARARGS:%.*]] = call i32 (...) @xd.inst.name.conflict.varargs(ptr [[P1]], i8 [[P2]], i32 3) ; CHECK-NEXT: [[FOUR_VARARGS:%.*]] = call i32 (...) @xd.inst.name.conflict.varargs(ptr [[P1]], i8 [[P2]], i32 3, i32 4) -; CHECK-NEXT: call void @xd.string.attr.op(ptr @[[GLOB0:[0-9]+]]) +; CHECK-NEXT: call void @xd.string.attr.op(ptr @[[GLOB0]]) ; CHECK-NEXT: ret void ;