[llvm] [CFI][annotation] Leave alone function pointers in function annotations (PR #80173)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 1 01:21:53 PST 2024


================
@@ -1837,6 +1851,16 @@ LowerTypeTestsModule::LowerTypeTestsModule(
   }
   OS = TargetTriple.getOS();
   ObjectFormat = TargetTriple.getObjectFormat();
+
+  // Function annotation describes or applies to function itself, and
+  // shouldn't be associated with jump table thunk generated for CFI.
+  GlobalAnnotation = M.getGlobalVariable("llvm.global.annotations");
+  if (GlobalAnnotation && GlobalAnnotation->getNumOperands() == 1) {
+    const ConstantArray *CA =
+        cast<ConstantArray>(GlobalAnnotation->getOperand(0));
----------------
nikic wrote:

```suggestion
  if (GlobalAnnotation && GlobalAnnotation->hasInitializer()) {
    const ConstantArray *CA =
        cast<ConstantArray>(GlobalAnnotation->getInitializer());
```

https://github.com/llvm/llvm-project/pull/80173


More information about the llvm-commits mailing list