-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
The following program miscompiles.
#include <nautilus/core.hpp>
#include <nautilus/Engine.hpp>
#include <cassert>
using namespace nautilus;
#define max(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
void test(val<int*> x) {
*x = (val<int>) max(
(val<int>) (*x)
,
(val<int>) 100
);
}
int main() {
engine::Options options;
options.setOption("engine.Compilation", true);
options.setOption("dump.all", true);
auto engine = engine::NautilusEngine(options);
auto function = engine.registerFunction(test);
int x = 0;
function(&x);
std::cout << x << std::endl;
assert(x == 100);
}With d434082, I get the following after_ssa.trace:
B0($1:ptr)
LOAD $5 $1 :i32
CONST $6 100 :i32
GT $7 $5 $6 :bool
CMP $8 $7 B1($1,$5) B2($1,$5) :void
B1($2:ptr,$5:i32)
JMP $0 B3($2,$5) :void
B2($2:ptr,$5:i32)
JMP $0 B3($2,$5) :void
B3($2:ptr,$5:i32) ControlFlowMerge
STORE $12 $2 $5 :void
RETURN $0 :void
So afaics the final value of x is always its initial value and never 100.
Metadata
Metadata
Assignees
Labels
No labels