@@ -927,6 +927,27 @@ void AsmPrinter::emitDebugValue(const MCExpr *Value, unsigned Size) const {
927
927
928
928
void AsmPrinter::emitFunctionHeaderComment () {}
929
929
930
+ void AsmPrinter::emitFunctionPrefix (ArrayRef<const Constant *> Prefix) {
931
+ const Function &F = MF->getFunction ();
932
+ if (!MAI->hasSubsectionsViaSymbols ()) {
933
+ for (auto &C : Prefix)
934
+ emitGlobalConstant (F.getParent ()->getDataLayout (), C);
935
+ return ;
936
+ }
937
+ // Preserving prefix-like data on platforms which use subsections-via-symbols
938
+ // is a bit tricky. Here we introduce a symbol for the prefix-like data
939
+ // and use the .alt_entry attribute to mark the function's real entry point
940
+ // as an alternative entry point to the symbol that precedes the function..
941
+ OutStreamer->emitLabel (OutContext.createLinkerPrivateTempSymbol ());
942
+
943
+ for (auto &C : Prefix) {
944
+ emitGlobalConstant (F.getParent ()->getDataLayout (), C);
945
+ }
946
+
947
+ // Emit an .alt_entry directive for the actual function symbol.
948
+ OutStreamer->emitSymbolAttribute (CurrentFnSym, MCSA_AltEntry);
949
+ }
950
+
930
951
// / EmitFunctionHeader - This method emits the header for the current
931
952
// / function.
932
953
void AsmPrinter::emitFunctionHeader () {
@@ -966,23 +987,8 @@ void AsmPrinter::emitFunctionHeader() {
966
987
OutStreamer->emitSymbolAttribute (CurrentFnSym, MCSA_Cold);
967
988
968
989
// Emit the prefix data.
969
- if (F.hasPrefixData ()) {
970
- if (MAI->hasSubsectionsViaSymbols ()) {
971
- // Preserving prefix data on platforms which use subsections-via-symbols
972
- // is a bit tricky. Here we introduce a symbol for the prefix data
973
- // and use the .alt_entry attribute to mark the function's real entry point
974
- // as an alternative entry point to the prefix-data symbol.
975
- MCSymbol *PrefixSym = OutContext.createLinkerPrivateTempSymbol ();
976
- OutStreamer->emitLabel (PrefixSym);
977
-
978
- emitGlobalConstant (F.getParent ()->getDataLayout (), F.getPrefixData ());
979
-
980
- // Emit an .alt_entry directive for the actual function symbol.
981
- OutStreamer->emitSymbolAttribute (CurrentFnSym, MCSA_AltEntry);
982
- } else {
983
- emitGlobalConstant (F.getParent ()->getDataLayout (), F.getPrefixData ());
984
- }
985
- }
990
+ if (F.hasPrefixData ())
991
+ emitFunctionPrefix ({F.getPrefixData ()});
986
992
987
993
// Emit KCFI type information before patchable-function-prefix nops.
988
994
emitKCFITypeId (*MF);
@@ -1014,8 +1020,7 @@ void AsmPrinter::emitFunctionHeader() {
1014
1020
1015
1021
auto *PrologueSig = mdconst::extract<Constant>(MD->getOperand (0 ));
1016
1022
auto *TypeHash = mdconst::extract<Constant>(MD->getOperand (1 ));
1017
- emitGlobalConstant (F.getParent ()->getDataLayout (), PrologueSig);
1018
- emitGlobalConstant (F.getParent ()->getDataLayout (), TypeHash);
1023
+ emitFunctionPrefix ({PrologueSig, TypeHash});
1019
1024
}
1020
1025
1021
1026
if (isVerbose ()) {
0 commit comments