Skip to content

Commit

Permalink
Crashes with report when call getValue() on operands returns null
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengyang92 committed Sep 28, 2018
1 parent 35fdf4f commit 542df03
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/Pass/Pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ struct SouperPass : public ModulePass {
Value *V0 = getValue(I->Ops[0], ReplacedInst, EBC, DT, ReplacedValues,
Builder, M);
if (!V0)
return 0;
report_fatal_error((std::string)"First argument of " +
Inst::getKindName(I->K) +" missing");

switch (I->Ops.size()) {
case 1:
switch (I->K) {
Expand Down Expand Up @@ -241,7 +243,8 @@ struct SouperPass : public ModulePass {
Value *V1 = getValue(I->Ops[1], ReplacedInst, EBC, DT,
ReplacedValues, Builder, M);
if (!V1)
return 0;
report_fatal_error((std::string)"Second argument of " +
Inst::getKindName(I->K) +" missing");
switch (I->K) {
case Inst::And:
if (isa<Constant>(V0))
Expand Down Expand Up @@ -316,8 +319,12 @@ struct SouperPass : public ModulePass {
ReplacedValues, Builder, M);
Value *V2 = getValue(I->Ops[2], ReplacedInst, EBC, DT,
ReplacedValues, Builder, M);
if (!V1 || !V2)
return 0;
if (!V1)
report_fatal_error((std::string)"Second argument of " +
Inst::getKindName(I->K) +" missing");
if (!V2)
report_fatal_error((std::string)"Third argument of " +
Inst::getKindName(I->K) +" missing");
switch (I->K) {
case Inst::Select:
return Builder.CreateSelect(V0, V1, V2);
Expand Down

0 comments on commit 542df03

Please sign in to comment.