Skip to content

Commit da9d266

Browse files
authored
Rollup merge of #69836 - JohnTitor:immediate-outputs, r=nagisa
Check if output is immediate value Fixes #62046 r? @nagisa
2 parents e3f040f + d32924f commit da9d266

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

src/librustc_codegen_llvm/asm.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
2929
let mut indirect_outputs = vec![];
3030
for (i, (out, &place)) in ia.outputs.iter().zip(&outputs).enumerate() {
3131
if out.is_rw {
32-
inputs.push(self.load_operand(place).immediate());
32+
let operand = self.load_operand(place);
33+
if let OperandValue::Immediate(_) = operand.val {
34+
inputs.push(operand.immediate());
35+
}
3336
ext_constraints.push(i.to_string());
3437
}
3538
if out.is_indirect {
36-
indirect_outputs.push(self.load_operand(place).immediate());
39+
let operand = self.load_operand(place);
40+
if let OperandValue::Immediate(_) = operand.val {
41+
indirect_outputs.push(operand.immediate());
42+
}
3743
} else {
3844
output_types.push(place.layout.llvm_type(self.cx()));
3945
}

src/test/ui/asm/issue-62046.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// build-fail
2+
// ignore-emscripten no asm! support
3+
4+
#![feature(asm)]
5+
6+
fn main() {
7+
unsafe {
8+
asm!("nop" : "+r"("r15"));
9+
//~^ malformed inline assembly
10+
}
11+
}

src/test/ui/asm/issue-62046.stderr

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0668]: malformed inline assembly
2+
--> $DIR/issue-62046.rs:8:9
3+
|
4+
LL | asm!("nop" : "+r"("r15"));
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0668`.

0 commit comments

Comments
 (0)