@@ -318,48 +318,49 @@ Error lowerPointer64AuthEdgesToSigningFunction(LinkGraph &G) {
318318
319319 for (auto *B : G.blocks ()) {
320320 for (auto &E : B->edges ()) {
321- if (E.getKind () == aarch64::Pointer64Authenticated) {
322- uint64_t EncodedInfo = E.getAddend ();
323- int32_t RealAddend = (uint32_t )(EncodedInfo & 0xffffffff );
324- uint32_t InitialDiscriminator = (EncodedInfo >> 32 ) & 0xffff ;
325- bool AddressDiversify = (EncodedInfo >> 48 ) & 0x1 ;
326- uint32_t Key = (EncodedInfo >> 49 ) & 0x3 ;
327- uint32_t HighBits = EncodedInfo >> 51 ;
328- auto ValueToSign = E.getTarget ().getAddress () + RealAddend;
329-
330- if (HighBits != 0x1000 )
331- return make_error<JITLinkError>(
332- " Pointer64Auth edge at " +
333- formatv (" {0:x}" , B->getFixupAddress (E).getValue ()) +
334- " has invalid encoded addend " + formatv (" {0:x}" , EncodedInfo));
335-
336- LLVM_DEBUG ({
337- const char *const KeyNames[] = {" IA" , " IB" , " DA" , " DB" };
338- dbgs () << " " << B->getFixupAddress (E) << " <- " << ValueToSign
339- << " : key = " << KeyNames[Key] << " , discriminator = "
340- << formatv (" {0:x4}" , InitialDiscriminator)
341- << " , address diversified = "
342- << (AddressDiversify ? " yes" : " no" ) << " \n " ;
343- });
344-
345- // Materialize pointer value.
346- cantFail (
347- writeMovRegImm64Seq (AppendInstr, Reg1, ValueToSign.getValue ()));
348-
349- // Materialize fixup pointer.
350- cantFail (writeMovRegImm64Seq (AppendInstr, Reg2,
351- B->getFixupAddress (E).getValue ()));
352-
353- // Write signing instruction(s).
354- cantFail (writePACSignSeq (AppendInstr, Reg1, ValueToSign, Reg2, Reg3,
355- Key, InitialDiscriminator, AddressDiversify));
356-
357- // Store signed pointer.
358- cantFail (writeStoreRegSeq (AppendInstr, Reg2, Reg1));
359-
360- // Replace edge with a keep-alive to preserve dependence info.
361- E.setKind (Edge::KeepAlive);
362- }
321+ // We're only concerned with Pointer64Authenticated edges here.
322+ if (E.getKind () != aarch64::Pointer64Authenticated)
323+ continue ;
324+
325+ uint64_t EncodedInfo = E.getAddend ();
326+ int32_t RealAddend = (uint32_t )(EncodedInfo & 0xffffffff );
327+ uint32_t InitialDiscriminator = (EncodedInfo >> 32 ) & 0xffff ;
328+ bool AddressDiversify = (EncodedInfo >> 48 ) & 0x1 ;
329+ uint32_t Key = (EncodedInfo >> 49 ) & 0x3 ;
330+ uint32_t HighBits = EncodedInfo >> 51 ;
331+ auto ValueToSign = E.getTarget ().getAddress () + RealAddend;
332+
333+ if (HighBits != 0x1000 )
334+ return make_error<JITLinkError>(
335+ " Pointer64Auth edge at " +
336+ formatv (" {0:x}" , B->getFixupAddress (E).getValue ()) +
337+ " has invalid encoded addend " + formatv (" {0:x}" , EncodedInfo));
338+
339+ LLVM_DEBUG ({
340+ const char *const KeyNames[] = {" IA" , " IB" , " DA" , " DB" };
341+ dbgs () << " " << B->getFixupAddress (E) << " <- " << ValueToSign
342+ << " : key = " << KeyNames[Key] << " , discriminator = "
343+ << formatv (" {0:x4}" , InitialDiscriminator)
344+ << " , address diversified = "
345+ << (AddressDiversify ? " yes" : " no" ) << " \n " ;
346+ });
347+
348+ // Materialize pointer value.
349+ cantFail (writeMovRegImm64Seq (AppendInstr, Reg1, ValueToSign.getValue ()));
350+
351+ // Materialize fixup pointer.
352+ cantFail (writeMovRegImm64Seq (AppendInstr, Reg2,
353+ B->getFixupAddress (E).getValue ()));
354+
355+ // Write signing instruction(s).
356+ cantFail (writePACSignSeq (AppendInstr, Reg1, ValueToSign, Reg2, Reg3, Key,
357+ InitialDiscriminator, AddressDiversify));
358+
359+ // Store signed pointer.
360+ cantFail (writeStoreRegSeq (AppendInstr, Reg2, Reg1));
361+
362+ // Replace edge with a keep-alive to preserve dependence info.
363+ E.setKind (Edge::KeepAlive);
363364 }
364365 }
365366
0 commit comments