[llvm] 924696d - [AsmPrinter] Avoid pointer element type access

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 8 06:06:11 PST 2022


Author: Nikita Popov
Date: 2022-02-08T15:06:02+01:00
New Revision: 924696d271cabdda066088c40a0fa98bd240b86a

URL: https://github.com/llvm/llvm-project/commit/924696d271cabdda066088c40a0fa98bd240b86a
DIFF: https://github.com/llvm/llvm-project/commit/924696d271cabdda066088c40a0fa98bd240b86a.diff

LOG: [AsmPrinter] Avoid pointer element type access

Instead of checking for a bitcast from a function type, check
whether the aliasee is a function after stripping bitcasts. This
is not strictly equivalent, but serves the same purpose.

Added: 
    

Modified: 
    llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 3e8e190eecc3f..345cdb7c5597a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1617,10 +1617,7 @@ void AsmPrinter::emitGlobalAlias(Module &M, const GlobalAlias &GA) {
   // Treat bitcasts of functions as functions also. This is important at least
   // on WebAssembly where object and function addresses can't alias each other.
   if (!IsFunction)
-    if (auto *CE = dyn_cast<ConstantExpr>(GA.getAliasee()))
-      if (CE->getOpcode() == Instruction::BitCast)
-        IsFunction =
-          CE->getOperand(0)->getType()->getPointerElementType()->isFunctionTy();
+    IsFunction = isa<Function>(GA.getAliasee()->stripPointerCasts());
 
   // AIX's assembly directive `.set` is not usable for aliasing purpose,
   // so AIX has to use the extra-label-at-definition strategy. At this


        


More information about the llvm-commits mailing list