Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid operand found in inline asm: 'movl %gs:${1:P},$0' #3751

Closed
edwintorok opened this issue Jan 24, 2009 · 4 comments
Closed

Invalid operand found in inline asm: 'movl %gs:${1:P},$0' #3751

edwintorok opened this issue Jan 24, 2009 · 4 comments
Labels
bugzilla Issues migrated from bugzilla

Comments

@edwintorok
Copy link
Contributor

Bugzilla Link 3379
Resolution FIXED
Resolved on Apr 28, 2009 16:52
Version unspecified
OS Linux
Blocks llvm/llvm-bugzilla-archive#4064
CC @asl

Extended Description

Another one from the kernel

typedef unsigned long long u64;
extern typeof(int) per_cpu__cpu_number;
static u64 attribute((section(".data.read_mostly"))) boot_pat_state;
void pat_init(void) {
u64 pat;
printk("<6>" "x86 PAT enabled: cpu %d, old 0x%Lx, new 0x%Lx\n", (({
typeof(per_cpu__cpu_number) ret__;
switch (sizeof(per_cpu__cpu_number)) {
case 4: asm("mov" "l ""%%""gs"":%P" "1"",%0" : "=r" (ret__) : "m" (per_cpu__cpu_number));
}
ret__;
}
)), boot_pat_state, pat);
}

$ llvm-gcc testcase-min.i
Invalid operand found in inline asm: 'movl %gs:${1:P},$0'
INLINEASM <es:movl %gs:${1:P},$0>, 10, %ECX, 36, %reg0, 1, %reg0, ga:per_cpu__cpu_number

With %1 gcc generates this:
movl %gs:per_cpu__cpu_number,%eax

Without %P gcc generates this:
movl %gs:per_cpu__cpu_number(%rip),%eax

@lattner
Copy link
Collaborator

lattner commented Jan 24, 2009

does this patch fix it (and produce the correct suffix)?
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090119/072614.html

If not, please attach a .bc file produced with -emit-llvm, thanks.

@edwintorok
Copy link
Contributor Author

does this patch fix it (and produce the correct suffix)?
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090119/072614.html

If not, please attach a .bc file produced with -emit-llvm, thanks.

I get an error from LLC now, bitcode below

llc: /home/edwin/llvm-bootstrap/llvm/include/llvm/Target/TargetRegisterInfo.h:255: static bool llvm::TargetRegisterInfo::isPhysicalRegister(unsigned int): Assertion `Reg && "this is not a register!"' failed.
0 llc 0x0000000000c6e29f
1 libc.so.6 0x00007f91fb3e0f60
2 libc.so.6 0x00007f91fb3e0ed5 gsignal + 53
3 libc.so.6 0x00007f91fb3e23f3 abort + 387
4 libc.so.6 0x00007f91fb3d9dc9 __assert_fail + 233
5 llc 0x000000000075df7f
6 llc 0x000000000075e91c
7 llc 0x0000000000a0bfaf llvm::AsmPrinter::printInlineAsm(llvm::MachineInstr const*) const + 1647
8 llc 0x000000000075eba1
9 llc 0x000000000075f884
10 llc 0x0000000000c09bfb llvm::FPPassManager::runOnFunction(llvm::Function&) + 347
11 llc 0x0000000000c09ff6 llvm::FunctionPassManagerImpl::run(llvm::Function&) + 134
12 llc 0x0000000000c0a17e llvm::FunctionPassManager::run(llvm::Function&) + 62
13 llc 0x00000000004fbbc1 main + 4193
14 libc.so.6 0x00007f91fb3cd1a6 __libc_start_main + 230
15 llc 0x00000000004fa0b9 std::ios_base::Init::~Init() + 57
Aborted

target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
target triple = "x86_64-unknown-linux-gnu"
@​boot_pat_state = internal global i64 0, section ".data.read_mostly" ; <i64*> [#uses=1]
@​per_cpu__cpu_number = external global i32 ; <i32*> [#uses=1]
@.str = internal constant [50 x i8] c"<6>x86 PAT enabled: cpu %d, old 0x%Lx, new 0x%Lx\0A\00" ; <[50 x i8]*> [#uses=1]

define void @​pat_init() nounwind {
entry:
%ret__ = alloca i32 ; <i32*> [#uses=2]
%pat = alloca i64 ; <i64*> [#uses=1]
%0 = alloca i32 ; <i32*> [#uses=2]
%"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
%1 = load i64* @​boot_pat_state, align 8 ; [#uses=1]
%asmtmp = call i32 asm "movl %gs:${1:P},$0", "=r,m,{dirflag},{fpsr},~{flags}"(i32 @​per_cpu__cpu_number) nounwind ; [#uses=1]
store i32 %asmtmp, i32* %ret__
%2 = load i32* %ret__, align 4 ; [#uses=1]
store i32 %2, i32* %0, align 4
%3 = load i32* %0, align 4 ; [#uses=1]
%4 = load i64* %pat, align 8 ; [#uses=1]
%5 = call i32 (...)* @​printk(i8* getelementptr ([50 x i8]* @.str, i32 0, i64 0), i32 %3, i64 %1, i64 %4) nounwind ; [#uses=0]
br label %return

return: ; preds = %entry
ret void
}

declare i32 @​printk(...)

@asl
Copy link
Collaborator

asl commented Apr 28, 2009

@llvmbot
Copy link
Collaborator

llvmbot commented Nov 27, 2021

mentioned in issue llvm/llvm-bugzilla-archive#4064

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
augusto2112 pushed a commit to augusto2112/llvm-project that referenced this issue Jan 14, 2022
Cherry-pick fix for relative breakpoints
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

4 participants