@@ -167,7 +167,7 @@ function optimize_module!(@nospecialize(job::CompilerJob{PTXCompilerTarget}),
167
167
# but Julia's pass sequence only invokes the simple unroller.
168
168
add! (fpm, LoopUnrollPass (LoopUnrollOptions (; job. config. opt_level)))
169
169
add! (fpm, InstCombinePass ()) # clean-up redundancy
170
- add! (fpm, NewPMLoopPassManager) do lpm
170
+ add! (fpm, NewPMLoopPassManager, #= UseMemorySSA =# true ) do lpm
171
171
add! (lpm, LICMPass ()) # the inner runtime check might be
172
172
# outer loop invariant
173
173
end
@@ -439,20 +439,42 @@ function nvvm_reflect!(fun::LLVM.Function)
439
439
for use in uses (reflect_function)
440
440
call = user (use)
441
441
isa (call, LLVM. CallInst) || continue
442
- length (operands (call)) == 2 || error (" Wrong number of operands to __nvvm_reflect function" )
442
+ if length (operands (call)) != 2
443
+ @error """ Unrecognized format of __nvvm_reflect call:
444
+ $(string (call))
445
+ Wrong number of operands: expected 2, got $(length (operands (call))) ."""
446
+ continue
447
+ end
443
448
444
449
# decode the string argument
445
- str = operands (call)[1 ]
446
- isa (str, LLVM. ConstantExpr) || error (" Format of __nvvm__reflect function not recognized" )
447
- sym = operands (str)[1 ]
448
- if isa (sym, LLVM. ConstantExpr) && opcode (sym) == LLVM. API. LLVMGetElementPtr
449
- # CUDA 11.0 or below
450
- sym = operands (sym)[1 ]
450
+ if LLVM. version () >= v " 17"
451
+ sym = operands (call)[1 ]
452
+ else
453
+ str = operands (call)[1 ]
454
+ if ! isa (str, LLVM. ConstantExpr) || opcode (str) != LLVM. API. LLVMGetElementPtr
455
+ @safe_error """ Unrecognized format of __nvvm_reflect call:
456
+ $(string (call))
457
+ Operand should be a GEP instruction, got a $(typeof (str)) . Please file an issue."""
458
+ continue
459
+ end
460
+ sym = operands (str)[1 ]
461
+ if isa (sym, LLVM. ConstantExpr) && opcode (sym) == LLVM. API. LLVMGetElementPtr
462
+ # CUDA 11.0 or below
463
+ sym = operands (sym)[1 ]
464
+ end
465
+ end
466
+ if ! isa (sym, LLVM. GlobalVariable)
467
+ @safe_error """ Unrecognized format of __nvvm_reflect call:
468
+ $(string (call))
469
+ Operand should be a global variable, got a $(typeof (sym)) . Please file an issue."""
470
+ continue
451
471
end
452
- isa (sym, LLVM. GlobalVariable) || error (" Format of __nvvm__reflect function not recognized" )
453
472
sym_op = operands (sym)[1 ]
454
- isa (sym_op, LLVM. ConstantArray) || isa (sym_op, LLVM. ConstantDataArray) ||
455
- error (" Format of __nvvm__reflect function not recognized" )
473
+ if ! isa (sym_op, LLVM. ConstantArray) && ! isa (sym_op, LLVM. ConstantDataArray)
474
+ @safe_error """ Unrecognized format of __nvvm_reflect call:
475
+ $(string (call))
476
+ Operand should be a constant array, got a $(typeof (sym_op)) . Please file an issue."""
477
+ end
456
478
chars = convert .(Ref (UInt8), collect (sym_op))
457
479
reflect_arg = String (chars[1 : end - 1 ])
458
480
@@ -477,7 +499,10 @@ function nvvm_reflect!(fun::LLVM.Function)
477
499
elseif reflect_arg == " __CUDA_ARCH"
478
500
ConstantInt (reflect_typ, job. config. target. cap. major* 100 + job. config. target. cap. minor* 10 )
479
501
else
480
- @warn " Unknown __nvvm_reflect argument: $reflect_arg . Please file an issue."
502
+ @safe_error """ Unrecognized format of __nvvm_reflect call:
503
+ $(string (call))
504
+ Unknown argument $reflect_arg . Please file an issue."""
505
+ continue
481
506
end
482
507
483
508
replace_uses! (call, reflect_val)
0 commit comments