Skip to content

Commit 12a5ee0

Browse files
authored
Fix batched attribute usage (#2678)
* Fix batched attribute usage * fix
1 parent 0139f27 commit 12a5ee0

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

enzyme/Enzyme/CApi.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,7 @@ void EnzymeFixupBatchedJuliaCallingConvention(LLVMValueRef F_C) {
14411441
} else if (attr.isStringAttribute() &&
14421442
attr.getKindAsString() == "enzymejl_returnRoots_v") {
14431443
sretv = true;
1444-
kind = "enzymejl_returnRoots_v";
1444+
kind = "enzymejl_returnRoots";
14451445
value = attr.getValueAsString();
14461446
} else {
14471447
NewAttrs = NewAttrs.addAttribute(
@@ -1465,6 +1465,7 @@ void EnzymeFixupBatchedJuliaCallingConvention(LLVMValueRef F_C) {
14651465
}
14661466
}
14671467
}
1468+
assert(!sretv);
14681469
types.push_back(T);
14691470
}
14701471
if (changed.size() == 0)
@@ -1560,17 +1561,17 @@ void EnzymeFixupBatchedJuliaCallingConvention(LLVMValueRef F_C) {
15601561
attr.getKindAsString() == "enzyme_sret_v") {
15611562
sretv = true;
15621563
kind = "enzyme_sret";
1563-
attr.getValueAsString();
1564+
value = attr.getValueAsString();
15641565
} else if (attr.isStringAttribute() &&
15651566
attr.getKindAsString() == "enzymejl_returnRoots_v") {
15661567
sretv = true;
15671568
kind = "enzymejl_returnRoots";
1568-
attr.getValueAsString();
1569+
value = attr.getValueAsString();
15691570
} else if (attr.isStringAttribute() &&
15701571
attr.getKindAsString() == "enzymejl_rooted_typ_v") {
15711572
sretv = true;
15721573
kind = "enzymejl_rooted_typ_v";
1573-
attr.getValueAsString();
1574+
value = attr.getValueAsString();
15741575
}
15751576
}
15761577
for (unsigned i = 0; i < AT->getNumElements(); i++) {
@@ -1591,17 +1592,20 @@ void EnzymeFixupBatchedJuliaCallingConvention(LLVMValueRef F_C) {
15911592
attr.getKindAsString() == "enzyme_sret_v") {
15921593
NewAttrs = NewAttrs.addAttribute(
15931594
F->getContext(), AttributeList::FirstArgIndex + vals.size(),
1594-
Attribute::get(F->getContext(), "enzyme_sret"));
1595+
Attribute::get(F->getContext(), "enzyme_sret",
1596+
attr.getValueAsString()));
15951597
} else if (attr.isStringAttribute() &&
15961598
attr.getKindAsString() == "enzymejl_returnRoots_v") {
15971599
NewAttrs = NewAttrs.addAttribute(
15981600
F->getContext(), AttributeList::FirstArgIndex + vals.size(),
1599-
Attribute::get(F->getContext(), "enzymejl_returnRoots"));
1601+
Attribute::get(F->getContext(), "enzymejl_returnRoots",
1602+
attr.getValueAsString()));
16001603
} else if (attr.isStringAttribute() &&
16011604
attr.getKindAsString() == "enzymejl_rooted_typ_v") {
16021605
NewAttrs = NewAttrs.addAttribute(
16031606
F->getContext(), AttributeList::FirstArgIndex + vals.size(),
1604-
Attribute::get(F->getContext(), "enzymejl_rooted_typ"));
1607+
Attribute::get(F->getContext(), "enzymejl_rooted_typ",
1608+
attr.getValueAsString()));
16051609
} else {
16061610
NewAttrs = NewAttrs.addAttribute(
16071611
F->getContext(), AttributeList::FirstArgIndex + vals.size(),

0 commit comments

Comments
 (0)