[PATCH] D96087: Option to ignore llvm[.compiler].used uses in hasAddressTaken()

Madhur Amilkanthwar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 9 23:35:46 PST 2021


madhur13490 added inline comments.


================
Comment at: llvm/lib/IR/Function.cpp:1583
 /// other than direct calls or invokes to it. Optionally ignores callback
 /// uses.
 bool Function::hasAddressTaken(const User **PutOffender,
----------------
Need to enhance this comment to accommodate new arguments.


================
Comment at: llvm/lib/IR/Function.cpp:1587
+                               bool IgnoreAssumeLikeCalls,
+                               bool IngoreLLVMUsed) const {
   for (const Use &U : uses()) {
----------------
%s/Ingore/Ignore


================
Comment at: llvm/lib/IR/Function.cpp:1617
+                     (GV->getName().equals("llvm.compiler.used") ||
+                      GV->getName().equals("llvm.used"));
+            return false;
----------------
rampitec wrote:
> madhur13490 wrote:
> > Can you please add a test which has non-bitcast value of function pointers? Something like below;
> > 
> > ```
> > @llvm.used = appending global [2 x float()*] [void()* @foo, void()* @bar]
> > ```
> > 
> > IIRC, the above simple cast to GlobalVariable is not sufficient in this case. You need to handle it with some more extra checks.
> Does this really happen? My understanding these arrays shall have i8* type, so a function pointer always needs a bitcast.
Yes, as per the spec, "This array contains a list of pointers to named global variables, functions and aliases **which may optionally have a pointer cast **formed of bitcast or getelementptr". So the pointer cast is optional. You can have plain function pointers in the array. The newly added code will handle only bitcast cast case but not general. You need to handle the general case and find if one of the users if GlobalVariable. 

```
@llvm.used = appending global [2 x void()*] [void()* @foo, void()* @bar]
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96087/new/

https://reviews.llvm.org/D96087



More information about the llvm-commits mailing list