================
@@ -163,20 +206,90 @@ static void EmitRuntimeFunction(MCStreamer &streamer,
                                              context), 4);
 }
 
+static std::optional<int64_t>
+GetOptionalAbsDifference(const MCAssembler &Assembler, const MCSymbol *LHS,
+                         const MCSymbol *RHS) {
+  MCContext &Context = Assembler.getContext();
+  const MCExpr *Diff =
+      MCBinaryExpr::createSub(MCSymbolRefExpr::create(LHS, Context),
+                              MCSymbolRefExpr::create(RHS, Context), Context);
+  // It should normally be possible to calculate the length of a function
+  // at this point, but it might not be possible in the presence of certain
+  // unusual constructs, like an inline asm with an alignment directive.
----------------
dpaoliello wrote:

This is actually pre-existing code that I moved earlier since I needed to call 
it in a different function.

It's definitely caused issues for me: you'll note that I only use this to 
measure the size of an epilog, so it's always measuring within the same block 
across a known set of instructions.

For the distance between an epilog and the end of the function I had to create 
a custom fixup for exactly the reason that you mention.

https://github.com/llvm/llvm-project/pull/129142
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to