Przeglądaj źródła

Validation: Allow inner constant GEP for GEP and BitCast instructions

Tex Riddell 5 lat temu
rodzic
commit
74480d1e72
1 zmienionych plików z 6 dodań i 0 usunięć
  1. 6 0
      lib/HLSL/DxilValidation.cpp

+ 6 - 0
lib/HLSL/DxilValidation.cpp

@@ -3531,12 +3531,18 @@ static void ValidateFunctionBody(Function *F, ValidationContext &ValCtx) {
         if (PT->getAddressSpace() == DXIL::kTGSMAddrSpace) {
           if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(&I)) {
             Value *Ptr = GEP->getPointerOperand();
+            // Allow inner constant GEP
+            if (isa<ConstantExpr>(Ptr) && isa<GEPOperator>(Ptr))
+              Ptr = cast<GEPOperator>(Ptr)->getPointerOperand();
             if (!isa<GlobalVariable>(Ptr)) {
               ValCtx.EmitInstrError(
                   &I, ValidationRule::InstrFailToResloveTGSMPointer);
             }
           } else if (BitCastInst *BCI = dyn_cast<BitCastInst>(&I)) {
             Value *Ptr = BCI->getOperand(0);
+            // Allow inner constant GEP
+            if (isa<ConstantExpr>(Ptr) && isa<GEPOperator>(Ptr))
+              Ptr = cast<GEPOperator>(Ptr)->getPointerOperand();
             if (!isa<GetElementPtrInst>(Ptr) && !isa<GlobalVariable>(Ptr)) {
               ValCtx.EmitInstrError(
                   &I, ValidationRule::InstrFailToResloveTGSMPointer);