Skip to content

Commit 4b0276d

Browse files
Revert "[llvm][AArch64] Autoupgrade function attributes from Module attributes." (#85291)
Reverts #82763 because caused a regressions with inlining. See #84494 (comment)
1 parent 33960c9 commit 4b0276d

File tree

6 files changed

+3
-122
lines changed

6 files changed

+3
-122
lines changed

llvm/include/llvm/IR/AutoUpgrade.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ namespace llvm {
8888
/// info. Return true if module is modified.
8989
bool UpgradeDebugInfo(Module &M);
9090

91-
/// Copies module attributes to the functions in the module.
92-
void CopyModuleAttrToFunctions(Module &M);
93-
9491
/// Check whether a string looks like an old loop attachment tag.
9592
inline bool mayBeOldLoopAttachmentTag(StringRef Name) {
9693
return Name.starts_with("llvm.vectorizer.");

llvm/lib/IR/AutoUpgrade.cpp

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -5178,72 +5178,6 @@ void llvm::UpgradeFunctionAttributes(Function &F) {
51785178
Arg.removeAttrs(AttributeFuncs::typeIncompatible(Arg.getType()));
51795179
}
51805180

5181-
// Check if the module attribute is present and not zero.
5182-
static bool isModuleAttributeSet(Module &M, const StringRef &ModAttr) {
5183-
const auto *Attr =
5184-
mdconst::extract_or_null<ConstantInt>(M.getModuleFlag(ModAttr));
5185-
return Attr && Attr->getZExtValue();
5186-
}
5187-
5188-
// Copy an attribute from module to the function if exists.
5189-
// First value of the pair is used when the module attribute is not zero
5190-
// the second otherwise.
5191-
static void
5192-
CopyModuleAttributeToFunction(Function &F, StringRef FnAttrName,
5193-
StringRef ModAttrName,
5194-
std::pair<StringRef, StringRef> Values) {
5195-
if (F.hasFnAttribute(FnAttrName))
5196-
return;
5197-
F.addFnAttr(FnAttrName, isModuleAttributeSet(*F.getParent(), ModAttrName)
5198-
? Values.first
5199-
: Values.second);
5200-
}
5201-
5202-
// Copy a boolean attribute from module to the function if exists.
5203-
// Module attribute treated false if zero otherwise true.
5204-
static void CopyModuleAttributeToFunction(Function &F, StringRef AttrName) {
5205-
CopyModuleAttributeToFunction(
5206-
F, AttrName, AttrName,
5207-
std::make_pair<StringRef, StringRef>("true", "false"));
5208-
}
5209-
5210-
// Copy an attribute from module to the function if exists.
5211-
// First value of the pair is used when the module attribute is not zero
5212-
// the second otherwise.
5213-
static void
5214-
CopyModuleAttributeToFunction(Function &F, StringRef AttrName,
5215-
std::pair<StringRef, StringRef> Values) {
5216-
CopyModuleAttributeToFunction(F, AttrName, AttrName, Values);
5217-
}
5218-
5219-
void llvm::CopyModuleAttrToFunctions(Module &M) {
5220-
Triple T(M.getTargetTriple());
5221-
if (!T.isThumb() && !T.isARM() && !T.isAArch64())
5222-
return;
5223-
5224-
for (Function &F : M.getFunctionList()) {
5225-
if (F.isDeclaration())
5226-
continue;
5227-
5228-
if (!F.hasFnAttribute("sign-return-address")) {
5229-
StringRef SignType = "none";
5230-
if (isModuleAttributeSet(M, "sign-return-address"))
5231-
SignType = "non-leaf";
5232-
5233-
if (isModuleAttributeSet(M, "sign-return-address-all"))
5234-
SignType = "all";
5235-
5236-
F.addFnAttr("sign-return-address", SignType);
5237-
}
5238-
CopyModuleAttributeToFunction(F, "branch-target-enforcement");
5239-
CopyModuleAttributeToFunction(F, "branch-protection-pauth-lr");
5240-
CopyModuleAttributeToFunction(F, "guarded-control-stack");
5241-
CopyModuleAttributeToFunction(
5242-
F, "sign-return-address-key",
5243-
std::make_pair<StringRef, StringRef>("b_key", "a_key"));
5244-
}
5245-
}
5246-
52475181
static bool isOldLoopArgument(Metadata *MD) {
52485182
auto *T = dyn_cast_or_null<MDTuple>(MD);
52495183
if (!T)

llvm/lib/Linker/IRMover.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,11 +1606,6 @@ Error IRLinker::run() {
16061606
// Loop over all of the linked values to compute type mappings.
16071607
computeTypeMapping();
16081608

1609-
// Convert module level attributes to function level attributes because
1610-
// after merging modules the attributes might change and would have different
1611-
// effect on the functions as the original module would have.
1612-
CopyModuleAttrToFunctions(*SrcM);
1613-
16141609
std::reverse(Worklist.begin(), Worklist.end());
16151610
while (!Worklist.empty()) {
16161611
GlobalValue *GV = Worklist.back();

llvm/test/LTO/AArch64/link-branch-target-enforcement.ll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ entry:
3232
; CHECK-DUMP: <main>:
3333
; CHECK-DUMP: bl 0x8 <main+0x8>
3434
; CHECK-DUMP: <foo>:
35-
; CHECK-DUMP: paciasp
3635

3736
; `main` doesn't support BTI while `foo` does, so in the binary
3837
; we should see only PAC which is supported by both.

llvm/test/LTO/AArch64/link-sign-return-address.ll

Lines changed: 0 additions & 43 deletions
This file was deleted.

llvm/test/Linker/link-arm-and-thumb.ll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ entry:
1313
ret i32 %add
1414
}
1515

16-
; CHECK: define i32 @main() [[MAIN_ATTRS:#[0-9]+]]
16+
; CHECK: define i32 @main() {
1717
; CHECK: define i32 @foo(i32 %a, i32 %b) [[ARM_ATTRS:#[0-9]+]]
1818
; CHECK: define i32 @bar(i32 %a, i32 %b) [[THUMB_ATTRS:#[0-9]+]]
1919

20-
; CHECK: attributes [[MAIN_ATTRS]] = { {{.*}} }
21-
; CHECK: attributes [[ARM_ATTRS]] = { {{.*}} "target-features"="-thumb-mode" }
22-
; CHECK: attributes [[THUMB_ATTRS]] = { {{.*}} "target-features"="+thumb-mode" }
20+
; CHECK: attributes [[ARM_ATTRS]] = { "target-features"="-thumb-mode" }
21+
; CHECK: attributes [[THUMB_ATTRS]] = { "target-features"="+thumb-mode" }
2322

2423
; STDERR-NOT: warning: Linking two modules of different target triples:

0 commit comments

Comments
 (0)