Move stripping of bitcasts in inline asm arguments
authorDale Johannesen <dalej@apple.com>
Mon, 20 Jul 2009 23:27:39 +0000 (23:27 +0000)
committerDale Johannesen <dalej@apple.com>
Mon, 20 Jul 2009 23:27:39 +0000 (23:27 +0000)
to a place where it affects everything.  Occurs
only on calls AFAIK.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76502 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
lib/CodeGen/SelectionDAG/TargetLowering.cpp

index 05622f2d6c731b6e26f02c561775a23f257eb657..3fa6047ad54fdbc0cbf8b6d581b4668c0bf65044 100644 (file)
@@ -5059,6 +5059,11 @@ void SelectionDAGLowering::visitInlineAsm(CallSite CS) {
     // If this is an input or an indirect output, process the call argument.
     // BasicBlocks are labels, currently appearing only in asm's.
     if (OpInfo.CallOperandVal) {
+      // Strip bitcasts, if any.  This mostly comes up for functions.
+      ConstantExpr* CE = NULL;
+      while ((CE = dyn_cast<ConstantExpr>(OpInfo.CallOperandVal)) &&
+             CE->getOpcode()==Instruction::BitCast)
+        OpInfo.CallOperandVal = CE->getOperand(0);
       if (BasicBlock *BB = dyn_cast<BasicBlock>(OpInfo.CallOperandVal)) {
         OpInfo.CallOperand = DAG.getBasicBlock(FuncInfo.MBBMap[BB]);
       } else {
index dc25041da60cd3c514c53ae7b24c56428a866f04..1ee181fb69d86fbf066eac7d634208b40077d560 100644 (file)
@@ -2406,20 +2406,10 @@ void TargetLowering::ComputeConstraintToUse(AsmOperandInfo &OpInfo,
   
   // 'X' matches anything.
   if (OpInfo.ConstraintCode == "X" && OpInfo.CallOperandVal) {
-    // Look through bitcasts over functions.  In the context of an asm
-    // argument we don't care about bitcasting function types; the parameters
-    // to the function, if any, will have been handled elsewhere.
-    Value *v = OpInfo.CallOperandVal;
-    ConstantExpr *CE = NULL;
-    while ((CE = dyn_cast<ConstantExpr>(v)) &&
-           CE->getOpcode()==Instruction::BitCast)
-      v = CE->getOperand(0);
-    if (!isa<Function>(v))
-      v = OpInfo.CallOperandVal;
     // Labels and constants are handled elsewhere ('X' is the only thing
     // that matches labels).  For Functions, the type here is the type of
-    // the result, which is not what we want to look at; leave them alone
-    // (minus any bitcasts).
+    // the result, which is not what we want to look at; leave them alone.
+    Value *v = OpInfo.CallOperandVal;
     if (isa<BasicBlock>(v) || isa<ConstantInt>(v) || isa<Function>(v)) {
       OpInfo.CallOperandVal = v;
       return;