This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Simplify BTI/PAC-RET module flags
ClosedPublic

Authored by MaskRay on Jul 19 2022, 10:10 PM.

Details

Summary

These module flags use the Min merge behavior with a default value of
zero, so we don't need to emit them if zero.

Diff Detail

Event Timeline

MaskRay created this revision.Jul 19 2022, 10:10 PM
MaskRay requested review of this revision.Jul 19 2022, 10:10 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
MaskRay updated this revision to Diff 446053.Jul 19 2022, 11:49 PM

remove a test

danielkiss added inline comments.Jul 22 2022, 1:15 AM
llvm/lib/IR/AutoUpgrade.cpp
4415–4430

In a full LTO build the linker will complain about the mis match between the flags if one of the objects compiled with an older compiler that emitted Module:Error for these flags.

MaskRay marked an inline comment as done.Jul 22 2022, 3:25 PM
MaskRay added inline comments.
llvm/lib/IR/AutoUpgrade.cpp
4415–4430

The new approach doesnot emit a flag for 0 value, so there won't be an error even with old bitcode files using Error.

danielkiss added inline comments.Jul 25 2022, 1:18 AM
llvm/lib/IR/AutoUpgrade.cpp
4415–4430

older compiler could emit Module:Error with 0 and with this patch we emit 1 with min so the linker will stop with
ld.lld: error: linking module flags 'branch-target-enforcement': IDs have conflicting behaviors in 'foo.o' and 'ld-temp.o'

clang++-13 -flto=full -c foo.cpp -o foo.o
../build/bin/clang++ -flto=full -c main.cpp -o main.o -mbranch-protection=standard
../build/bin/clang++ -fuse-ld=lld main.o foo.o -o a.out
MaskRay marked an inline comment as done.Jul 25 2022, 9:09 AM
MaskRay added inline comments.
llvm/lib/IR/AutoUpgrade.cpp
4415–4430

Perhaps we should respect the Error for older llvm and not try fixing it for regular LTO? If you feel this is strongly needed, I'll have to restore this chunk. The main purpose is to remove the module flags for 0.

MaskRay updated this revision to Diff 447387.Jul 25 2022, 9:58 AM
MaskRay edited the summary of this revision. (Show Details)

Keep AutoUpgrade.cpp code

danielkiss accepted this revision.Jul 26 2022, 12:59 AM
danielkiss added a subscriber: chill.

AutoUpgrade is added due to similar issue at a user.
LGTM.

This revision is now accepted and ready to land.Jul 26 2022, 12:59 AM
This revision was landed with ongoing or failed builds.Jul 26 2022, 9:48 AM
This revision was automatically updated to reflect the committed changes.
llvm/lib/IR/AutoUpgrade.cpp