allow introduction of arg attributes
MODIFY
ir/attrs.cpp
ir/attrs.cpp
@@ -64,35 +64,9 @@ bool ParamAttrs::undefImpliesUB() const {
return ub;
}
-bool ParamAttrs::operator==(const ParamAttrs &rhs) const {
- if (bits != rhs.bits)
- return false;
-
- if (has(Dereferenceable) && derefBytes != rhs.derefBytes)
- return false;
- if (has(ByVal) && blockSize != rhs.blockSize)
- return false;
- if (has(Align) && align != rhs.align)
- return false;
-
- return true;
-}
-
bool FnAttrs::undefImpliesUB() const {
bool ub = has(NoUndef);
assert(!ub || poisonImpliesUB());
return ub;
}
-
-bool FnAttrs::operator==(const FnAttrs &rhs) const {
- if (bits != rhs.bits)
- return false;
-
- if (has(Dereferenceable) && derefBytes != rhs.derefBytes)
- return false;
- if (has(Align) && align != rhs.align)
- return false;
-
- return true;
-}
}

MODIFY
ir/attrs.h
ir/attrs.h
@@ -33,9 +33,6 @@ public:
bool undefImpliesUB() const;
friend std::ostream& operator<<(std::ostream &os, const ParamAttrs &attr);
-
- bool operator==(const ParamAttrs &rhs) const;
- bool operator!=(const ParamAttrs &rhs) const { return !(*this == rhs); };
};
@@ -65,9 +62,6 @@ public:
bool undefImpliesUB() const;
friend std::ostream& operator<<(std::ostream &os, const FnAttrs &attr);
-
- bool operator==(const FnAttrs &rhs) const;
- bool operator!=(const FnAttrs &rhs) const { return !(*this == rhs); };
};
}

MODIFY
ir/function.cpp
ir/function.cpp
@@ -219,14 +219,11 @@ bool Function::hasSameInputs(const Function &rhs) const {
while (litr != lend && ritr != rend) {
auto *lv = dynamic_cast<Input *>((*litr).get());
auto *rv = dynamic_cast<Input *>((*ritr).get());
- // TODO: &lv->getType() != &rv->getType() doesn't work because
- // two struct types that are structurally equivalent don't compare equal
- if (lv->getAttributes() != rv->getAttributes()) {
+ if (lv->getType().toString() != rv->getType().toString())
return false;
- }
- litr++;
- ritr++;
+ ++litr;
+ ++ritr;
skip_constinputs();
}
@@ -757,7 +754,7 @@ void Function::print(ostream &os, bool print_header) const {
}
if (print_header) {
- os << "define" << attrs << ' ' << getType() << " @" << name << '(';
+ os << "define " << getType() << " @" << name << '(';
bool first = true;
for (auto &input : getInputs()) {
if (!first)
@@ -767,7 +764,7 @@ void Function::print(ostream &os, bool print_header) const {
}
if (isVarArgs())
os << (first ? "..." : ", ...");
- os << ") {\n";
+ os << ')' << attrs << " {\n";
}
bool first = true;

ADD
tests/alive-tv/attrs/intro-arg-fail.srctgt.ll
+; ERROR: Source is more defined than target
+
+define i8 @src(i8* %p) {
+ store i8 3, i8* %p
+ ret i8 2
+}
+
+define i8 @tgt(i8* readonly %p) {
+ store i8 3, i8* %p
+ ret i8 2
+}

ADD
tests/alive-tv/attrs/intro-arg.srctgt.ll
+define i8 @src(i8* %p) {
+ %v = load i8, i8* %p
+ ret i8 %v
+}
+
+define i8 @tgt(i8* readonly %p) {
+ %v = load i8, i8* %p
+ ret i8 %v
+}

allow introduction of arg attributes