Skip to content

Commit 792c839

Browse files
committed
Address first round of review comments.
- convert assert to early return. - change dyn_cast<> following an isa<> to a cast<> - remove a null check after a cast<>
1 parent 06d5aef commit 792c839

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,10 @@ static void collectTOCStats(PPCAsmPrinter::TOCEntryType Type) {
477477
static CodeModel::Model getCodeModel(const PPCSubtarget &S,
478478
const TargetMachine &TM,
479479
const MachineOperand &MO) {
480-
assert(S.isAIXABI() && "ELF per global code model not supported yet");
481-
482480
CodeModel::Model ModuleModel = TM.getCodeModel();
481+
// Per global code model is only support on AIX.
482+
if (!S.isAIXABI())
483+
return ModuleModel;
483484

484485
// If the operand is not a global address then there is no
485486
// global variable to carry an attribute.
@@ -493,7 +494,7 @@ static CodeModel::Model getCodeModel(const PPCSubtarget &S,
493494
return ModuleModel;
494495

495496
std::optional<CodeModel::Model> MaybeCodeModel =
496-
dyn_cast<GlobalVariable>(GV)->getCodeModel();
497+
cast<GlobalVariable>(GV)->getCodeModel();
497498
if (MaybeCodeModel)
498499
return *MaybeCodeModel;
499500

llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -575,11 +575,7 @@ static CodeModel::Model getCodeModel(const PPCSubtarget &Subtarget,
575575
if (!isa<GlobalAddressSDNode>(Operand))
576576
return ModuleModel;
577577

578-
GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(Operand);
579-
if (!GA)
580-
return ModuleModel;
581-
582-
const GlobalValue *GV = GA->getGlobal();
578+
const GlobalValue *GV = cast<GlobalAddressSDNode>(Operand)->getGlobal();
583579
if (!GV || !isa<GlobalVariable>(GV))
584580
return ModuleModel;
585581

0 commit comments

Comments
 (0)