Always emitting framepointers in generated ELFs (#3987)

diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/AOT/internal/UnixLinkerTool.cpp b/iree/compiler/Dialect/HAL/Target/LLVM/AOT/internal/UnixLinkerTool.cpp
index fcd1986..5e14e8a 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/AOT/internal/UnixLinkerTool.cpp
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/AOT/internal/UnixLinkerTool.cpp
@@ -36,7 +36,18 @@
 
   LogicalResult configureModule(llvm::Module *llvmModule,
                                 ArrayRef<StringRef> entryPointNames) override {
-    // Possibly a no-op in ELF files; needs to be verified.
+    // Enable frame pointers to ensure that stack unwinding works, e.g. in
+    // Tracy. In principle this could also be achieved by enabling unwind
+    // tables, but we tried that and that didn't work in Tracy (which uses
+    // libbacktrace), while enabling frame pointers worked.
+    // https://github.com/google/iree/issues/3957
+    for (auto &func : *llvmModule) {
+      auto attrs = func.getAttributes();
+      attrs = attrs.addAttribute(llvmModule->getContext(),
+                                 llvm::AttributeList::FunctionIndex,
+                                 "frame-pointer", "all");
+      func.setAttributes(attrs);
+    }
     return success();
   }