Skip to content

Commit f38c271

Browse files
jiaolutsymalla-AMD
authored andcommitted
Add ImmutableString str
The global variable created from ImmutableString must have str name. or it can not be used from inlineFunction
1 parent ec61062 commit f38c271

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

include/llvm-dialects/Dialect/Dialect.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def : AttrLlvmType<AttrI32, I32>;
280280
def : AttrLlvmType<AttrI64, I64>;
281281

282282
def ImmutableStringAttr : Attr<"::llvm::StringRef"> {
283-
let toLlvmValue = [{ $_builder.CreateGlobalString($0) }];
283+
let toLlvmValue = [{ $_builder.CreateGlobalString($0, "str") }];
284284
let fromLlvmValue = [{ ::llvm::cast<::llvm::ConstantDataArray>(::llvm::cast<::llvm::GlobalVariable>($0)->getInitializer())->getAsString() }];
285285
let isImmutable = true;
286286
}

test/example/generated/ExampleDialect.cpp.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2064,7 +2064,7 @@ initial
20642064

20652065

20662066
::llvm::SmallVector<::llvm::Value*, 1> args = {
2067-
b.CreateGlobalString(val)
2067+
b.CreateGlobalString(val, "str")
20682068
};
20692069

20702070
return ::llvm::cast<StringAttrOp>(b.CreateCall(fn, args, instName));

test/example/test-builder.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
; RUN: llvm-dialects-example - | FileCheck --check-prefixes=CHECK %s
44

55
;.
6-
; CHECK: @[[GLOB0:[0-9]+]] = private unnamed_addr constant [13 x i8] c"Hello world!\00", align 1
6+
; CHECK: @[[GLOB0:.*]] = private unnamed_addr constant [13 x i8] c"Hello world!\00", align 1
77
;.
88
; CHECK-LABEL: @example(
99
; CHECK-NEXT: entry:
@@ -45,6 +45,6 @@
4545
; CHECK-NEXT: [[TWO_VARARGS:%.*]] = call i32 (...) @xd.inst.name.conflict.varargs(ptr [[P1]], i8 [[P2]])
4646
; CHECK-NEXT: [[THREE_VARARGS:%.*]] = call i32 (...) @xd.inst.name.conflict.varargs(ptr [[P1]], i8 [[P2]], i32 3)
4747
; CHECK-NEXT: [[FOUR_VARARGS:%.*]] = call i32 (...) @xd.inst.name.conflict.varargs(ptr [[P1]], i8 [[P2]], i32 3, i32 4)
48-
; CHECK-NEXT: call void @xd.string.attr.op(ptr @[[GLOB0:[0-9]+]])
48+
; CHECK-NEXT: call void @xd.string.attr.op(ptr @[[GLOB0]])
4949
; CHECK-NEXT: ret void
5050
;

0 commit comments

Comments
 (0)