@@ -78,7 +78,8 @@ class NVVMReflectLegacyPass : public ModulePass {
7878
7979public:
8080 static char ID;
81- NVVMReflectLegacyPass (const unsigned SmVersion) : ModulePass(ID), Impl(SmVersion) {}
81+ NVVMReflectLegacyPass (const unsigned SmVersion)
82+ : ModulePass(ID), Impl(SmVersion) {}
8283 bool runOnModule (Module &M) override ;
8384};
8485} // namespace
@@ -119,20 +120,25 @@ void NVVMReflect::populateReflectMap(Module &M) {
119120 StringRef OptionRef (Option);
120121 auto [Name, Val] = OptionRef.split (' =' );
121122 if (Name.empty ())
122- report_fatal_error (Twine (" Empty name in nvvm-reflect-add option '" ) + Option + " '" );
123+ report_fatal_error (Twine (" Empty name in nvvm-reflect-add option '" ) +
124+ Option + " '" );
123125 if (Val.empty ())
124- report_fatal_error (Twine (" Missing value in nvvm-reflect-add option '" ) + Option + " '" );
126+ report_fatal_error (Twine (" Missing value in nvvm-reflect-add option '" ) +
127+ Option + " '" );
125128 unsigned ValInt;
126129 if (!to_integer (Val.trim (), ValInt, 10 ))
127- report_fatal_error (Twine (" integer value expected in nvvm-reflect-add option '" ) + Option + " '" );
130+ report_fatal_error (
131+ Twine (" integer value expected in nvvm-reflect-add option '" ) +
132+ Option + " '" );
128133 ReflectMap[Name] = ValInt;
129134 }
130135}
131136
132137// / Process a reflect function by finding all its calls and replacing them with
133138// / appropriate constant values. For __CUDA_FTZ, uses the module flag value.
134139// / For __CUDA_ARCH, uses SmVersion * 10. For all other strings, uses 0.
135- bool NVVMReflect::handleReflectFunction (Module &M, const StringRef ReflectName) {
140+ bool NVVMReflect::handleReflectFunction (Module &M,
141+ const StringRef ReflectName) {
136142 Function *const F = M.getFunction (ReflectName);
137143 if (!F)
138144 return false ;
@@ -149,7 +155,8 @@ bool NVVMReflect::handleReflectFunction(Module &M, const StringRef ReflectName)
149155 // the call (i.e. "__CUDA_ARCH")
150156 auto *const Call = dyn_cast<CallInst>(U);
151157 if (!Call)
152- report_fatal_error (" __nvvm_reflect can only be used in a call instruction" );
158+ report_fatal_error (
159+ " __nvvm_reflect can only be used in a call instruction" );
153160 if (Call->getNumOperands () != 2 )
154161 report_fatal_error (" __nvvm_reflect requires exactly one argument" );
155162
@@ -162,7 +169,8 @@ bool NVVMReflect::handleReflectFunction(Module &M, const StringRef ReflectName)
162169 if (!ConstantStr)
163170 report_fatal_error (" __nvvm_reflect argument must be a string constant" );
164171 if (!ConstantStr->isCString ())
165- report_fatal_error (" __nvvm_reflect argument must be a null-terminated string" );
172+ report_fatal_error (
173+ " __nvvm_reflect argument must be a null-terminated string" );
166174
167175 const StringRef ReflectArg = ConstantStr->getAsString ().drop_back ();
168176 if (ReflectArg.empty ())
@@ -186,11 +194,13 @@ bool NVVMReflect::handleReflectFunction(Module &M, const StringRef ReflectName)
186194 return Changed;
187195}
188196
189- void NVVMReflect::foldReflectCall (CallInst *const Call, Constant *const NewValue) {
197+ void NVVMReflect::foldReflectCall (CallInst *const Call,
198+ Constant *const NewValue) {
190199 SmallVector<Instruction *, 8 > Worklist;
191200 // Replace an instruction with a constant and add all users of the instruction
192201 // to the worklist
193- auto ReplaceInstructionWithConst = [&](Instruction *const I, Constant *const C) {
202+ auto ReplaceInstructionWithConst = [&](Instruction *const I,
203+ Constant *const C) {
194204 for (auto *const U : I->users ())
195205 if (auto *const UI = dyn_cast<Instruction>(U))
196206 Worklist.push_back (UI);
0 commit comments