================
@@ -3361,6 +3382,194 @@ void PPCAIXAsmPrinter::emitModuleCommandLines(Module 
&M) {
   OutStreamer->emitXCOFFCInfoSym(".GCC.command.line", RSOS.str());
 }
 
+static bool TOCRestoreNeeded(const GlobalIFunc &GI) {
+  auto IsLocalFunc = [&](const Value *V) {
+    if (!isa<Function>(V))
+      return false;
+    auto *F = cast<Function>(V);
+
+    // static functions are local
+    if (F->getLinkage() == GlobalValue::InternalLinkage)
+      return true;
+    // for now, declarations we treat as potentially non-local
+    if (F->isDeclarationForLinker())
+      return false;
+    // hidden visibility definitions cannot be preempted, so treat as local.
+    if (F->getVisibility() == GlobalValue::HiddenVisibility)
----------------
w2yehia wrote:

I was relying on the textual IR to explicitly mention `dso_local`, but then 
realized that when the linkage and visibility imply dso_local then we don't 
list in the textual IR. So the above analysis is invalid.
After running some tests, I think `F->hasExactDefinition() && F->isDSOLocal()` 
is what we need:
```
Func foo_hidden hasExactDefinition = 1, isInterposable = 0, linkage = external, 
dso_local = 1
Func foo_protected hasExactDefinition = 1, isInterposable = 0, linkage = 
external, dso_local = 1
Func foo_internal hasExactDefinition = 1, isInterposable = 0, linkage = 
external, dso_local = 1
Func foo_weak_hidden hasExactDefinition = 0, isInterposable = 1, linkage = 
weak, dso_local = 1
Func foo_weak_protected hasExactDefinition = 0, isInterposable = 1, linkage = 
weak, dso_local = 1
Func foo_weak_internal hasExactDefinition = 0, isInterposable = 1, linkage = 
weak, dso_local = 1
Func foo_weak_extern hasExactDefinition = 0, isInterposable = 1, linkage = 
weak, dso_local = 0
Func foo_extern hasExactDefinition = 1, isInterposable = 0, linkage = external, 
dso_local = 0
Func foo_decl hasExactDefinition = 0, isInterposable = 0, linkage = external, 
dso_local = 0
Func foo_static hasExactDefinition = 1, isInterposable = 0, linkage = internal, 
dso_local = 1
```

https://github.com/llvm/llvm-project/pull/153049
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to