66//
77// ===----------------------------------------------------------------------===//
88// /
9- // / \file This file contains pases and utilities to convert a modern LLVM
9+ // / \file This file contains passes and utilities to convert a modern LLVM
1010// / module into a module compatible with the LLVM 3.7-based DirectX Intermediate
1111// / Language (DXIL).
1212// ===----------------------------------------------------------------------===//
2727#include " llvm/IR/Module.h"
2828#include " llvm/InitializePasses.h"
2929#include " llvm/Pass.h"
30- #include " llvm/Support/Compiler.h"
3130#include " llvm/Support/VersionTuple.h"
3231
3332#define DEBUG_TYPE " dxil-prepare"
@@ -224,7 +223,7 @@ class DXILPrepareModule : public ModulePass {
224223 const dxil::ModuleMetadataInfo MetadataInfo =
225224 getAnalysis<DXILMetadataAnalysisWrapperPass>().getModuleMetadata ();
226225 VersionTuple ValVer = MetadataInfo.ValidatorVersion ;
227- bool SkipValidation = ValVer.getMajor () == 0 && ValVer.getMinor () == 0 ;
226+ bool AllowExperimental = ValVer.getMajor () == 0 && ValVer.getMinor () == 0 ;
228227
229228 // construct allowlist of valid metadata node kinds
230229 std::array<unsigned , 6 > DXILCompatibleMDs = getCompatibleInstructionMDs (M);
@@ -235,7 +234,7 @@ class DXILPrepareModule : public ModulePass {
235234 // Only remove string attributes if we are not skipping validation.
236235 // This will reserve the experimental attributes when validation version
237236 // is 0.0 for experiment mode.
238- removeStringFunctionAttributes (F, SkipValidation );
237+ removeStringFunctionAttributes (F, AllowExperimental );
239238 for (size_t Idx = 0 , End = F.arg_size (); Idx < End; ++Idx)
240239 F.removeParamAttrs (Idx, AttrMask);
241240
@@ -245,9 +244,17 @@ class DXILPrepareModule : public ModulePass {
245244
246245 I.dropUnknownNonDebugMetadata (DXILCompatibleMDs);
247246
247+ if (auto *CB = dyn_cast<CallBase>(&I)) {
248+ CB->removeFnAttrs (AttrMask);
249+ CB->removeRetAttrs (AttrMask);
250+ for (size_t Idx = 0 , End = CB->arg_size (); Idx < End; ++Idx)
251+ CB->removeParamAttrs (Idx, AttrMask);
252+ continue ;
253+ }
254+
248255 // Emtting NoOp bitcast instructions allows the ValueEnumerator to be
249256 // unmodified as it reserves instruction IDs during contruction.
250- if (auto LI = dyn_cast<LoadInst>(&I)) {
257+ if (auto * LI = dyn_cast<LoadInst>(&I)) {
251258 if (Value *NoOpBitcast = maybeGenerateBitcast (
252259 Builder, PointerTypes, I, LI->getPointerOperand (),
253260 LI->getType ())) {
@@ -257,7 +264,7 @@ class DXILPrepareModule : public ModulePass {
257264 }
258265 continue ;
259266 }
260- if (auto SI = dyn_cast<StoreInst>(&I)) {
267+ if (auto * SI = dyn_cast<StoreInst>(&I)) {
261268 if (Value *NoOpBitcast = maybeGenerateBitcast (
262269 Builder, PointerTypes, I, SI->getPointerOperand (),
263270 SI->getValueOperand ()->getType ())) {
@@ -268,20 +275,13 @@ class DXILPrepareModule : public ModulePass {
268275 }
269276 continue ;
270277 }
271- if (auto GEP = dyn_cast<GetElementPtrInst>(&I)) {
278+ if (auto * GEP = dyn_cast<GetElementPtrInst>(&I)) {
272279 if (Value *NoOpBitcast = maybeGenerateBitcast (
273280 Builder, PointerTypes, I, GEP->getPointerOperand (),
274281 GEP->getSourceElementType ()))
275282 GEP->setOperand (0 , NoOpBitcast);
276283 continue ;
277284 }
278- if (auto *CB = dyn_cast<CallBase>(&I)) {
279- CB->removeFnAttrs (AttrMask);
280- CB->removeRetAttrs (AttrMask);
281- for (size_t Idx = 0 , End = CB->arg_size (); Idx < End; ++Idx)
282- CB->removeParamAttrs (Idx, AttrMask);
283- continue ;
284- }
285285 }
286286 }
287287 }
0 commit comments